Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266HTTPClient.h>
- #include <ESP8266WiFi.h>
- const char* ssid = "EUCinternet";
- const char* pass = NULL;
- const char* dest = "quickbillet.dk";
- int WiFiCon() {
- int xCnt = 0;
- if (WiFi.status() != WL_CONNECTED){
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, pass);
- while (WiFi.status() != WL_CONNECTED && xCnt < 50) {
- delay(500);
- xCnt ++;
- }
- if (WiFi.status() != WL_CONNECTED){
- return 0; //never connected
- } else {
- return 1; //1 is initial connection
- }
- } else {
- return 2; //2 is already connected
- }
- }
- void setup() {
- Serial.begin(1200);
- while(WiFi.status() != WL_CONNECTED) {
- WiFiCon();
- }
- }
- void loop() {
- if(WiFi.status()== WL_CONNECTED){
- HTTPClient http;
- http.begin("https://quickbillet.dk/ESP/req.php","CB:BD:10:61:FF:4C:5A:52:0F:B1:DD:73:4F:40:D8:09:6E:BF:A4:9F");
- http.addHeader("Content-Type", "application/x-www-form-urlencoded");
- int responseCode = http.POST("title=foo&body=bar&userId=1");
- String payload = http.getString();
- char temp[10];
- payload.toCharArray(temp, 10);
- Serial.write(temp);
- http.end();
- }else{ }
- delay(10000); //Send a request every 10 seconds
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement