WeMOS: WiFi Thingspeak analogRead2

From OnnoWiki
Revision as of 16:07, 12 November 2019 by Onnowpurbo (talk | contribs) (Created page with " ///////////////////////////////// // Generated with a lot of love// // with TUNIOT FOR ESP8266 // // Website: Easycoding.tn // /////////////////////////////////...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
/////////////////////////////////
// Generated with a lot of love//
// with TUNIOT FOR ESP8266     //
// Website: Easycoding.tn      //
/////////////////////////////////
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

WiFiClient client;

String thingSpeakAddress= "http://api.thingspeak.com/update?";
String request_string;

HTTPClient http;

void setup()
{
  Serial.begin(115200);
  if (WiFi.status() != WL_CONNECTED) {
     WiFi.begin("HUAWEI-1A73","52408495");
  }
  Serial.println("WiFi Connected");  
}

void loop()
{
  Serial.println(analogRead(A0));
  if (client.connect("api.thingspeak.com",80)) {
    request_string = thingSpeakAddress;
    request_string += "key=";
    request_string += "0C2X0PGNFHOEGYZA";
    request_string += "&";
    request_string += "field3";
    request_string += "=";
    request_string += String(analogRead(A0));
    http.begin(request_string);
    http.GET();
    http.end();
  }
  Serial.println("Waiting...");    
  // thingspeak needs minimum 15 sec delay between updates
  delay(15000);
}


Pranala Menarik