IOT | Post Data to Thingspeak Using ESP8266

About: i am electronic Hobbyist. I like to make the things and also make it available to people who need it. Please visit and subscribe my youtube channel for more Embedded related videos.

Nowadays, IoT is trending and lots of machine has data to upload over cloud and analyse the data. Small sensors update the data on cloud and actuator on another end acts on it.
I am going to explain the one of the example of IoT.

I this article and i am going to show and guide to post the data to Thingspeak using ESP8266.

Step 1: Required Component

ESP8266 on Amazon USA -

ESP8266 on Amazon UK -

ESP8266 on Amazon India -

MLX90614 on Amazon USA -

MLX90614 on Amazon UK -

MLX90614 on Amazon India -

Breadboard on Amazon USA -

Breadboard on Amazon UK -

Breadboard on Amazon India -

Step 2: Code

#include #include

String apiKey = "7CDCTE2767Z8AUIL"; // Enter your Write API key from ThingSpeak

const char *ssid = "hidden"; // replace with your wifi ssid and wpa2 key const char *pass = "qwerty12"; const char* server = "";

WiFiClient client; Adafruit_MLX90614 mlx = Adafruit_MLX90614();

int objTemp; int ambTemp;

void setup() { Serial.begin(115200); delay(10); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); mlx.begin(); Wire.begin(D1,D2); } void loop() {

if (client.connect(server,80)) // "" or { objTemp = mlx.readObjectTempC(); ambTemp = mlx.readObjectTempC(); String postStr = apiKey; postStr +="&field1="; postStr += String(objTemp); postStr += "\r\n\r\n";

client.print("POST /update HTTP/1.1\n"); client.print("Host:\n"); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr);

Serial.print("Ambient = "); Serial.print(ambTemp); Serial.print("*C\tObject = "); Serial.print(objTemp); Serial.println("*C");

} client.stop(); delay(2000); }

Step 3: Demo



    • Faux-Real Contest

      Faux-Real Contest
    • Warm and Fuzzy Contest

      Warm and Fuzzy Contest
    • Epilog X Contest

      Epilog X Contest