Overview

Skill Level: Intermediate

Arduino, Sensors,

The project is about sending office/room temperature data to Thingspeak. The temperature data would be used to observe and analyze the performance of Air conditioning and take appropriate measures if temperature variation is far from acceptable.

Ingredients

1. ESP8266-12 development board- Wemos D1 R2 mini

2. LM35 Temperature sensor

3. Jumperwires

4. USB cable

5. Breadboard

Apart from above components, one should have Arduino IDE installed.

 

Step-by-step

  1. Connect the circuit as shown

    The circuit connection is easy. Data pin of LM35 is to be connected to analog pin of ESP8266. In case of Wemos board, it is A0 pin also known as pin 17 in ESP8266. The other two pins of LM35 are to be connected to 3.3V and GND pins of Wemos board respectively.

    IMG_20161228_175630

  2. Program in Arduino IDE and Upload to ESP8266

    The program was written in Arduino IDE. The program uses ThingSpeak.h library to send to the data to Thingspeak.

    Before writing the program, a channel was created in Thingspeak to store temperature data. The channel number and write API key are used in the program to send data to Thingspeak. Please check the attached file for the code. Inlcuded libraries are ThingSpeak.h and ESP8266WiFi.h . Program was uploaded to Wemos D1 R2 ESP8266 board using USB. The factor of 0.322 was used to convert analog reading of LM35 to convert to temp in degrees centigrade since sensor was connected to 3.3V of ESP8266.

    Program:

    #include <ThingSpeak.h>

    #include<ESP8266WiFi.h>

     

    const char*ssid= “Your internet id”;

    const char* password=”Your internet password”;

    const char* server= “api.thingspeak.com”;

    float temp= 0;

    int analog=0;

     

    WiFiClient client;

    unsigned long myChannelNumber = your channel number from Thingspeak;

    const char * myWriteAPIKey = “Your api key”;

     

    void setup() {

      // put your setup code here, to run once:

    Serial.begin(9600);

    delay(10);

    WiFi.begin(ssid, password);

    Serial.println();

    Serial.println();

    Serial.print(“Connecting to”);

    Serial.println(ssid);

    WiFi.begin(ssid, password);

    while( WiFi.status()!=WL_CONNECTED){

      delay(500);

    ¬† Serial.print(“.”);

    }

    Serial.println(“”);

    Serial.println(“WiFi connected”);

    ThingSpeak.begin(client);

    }

     

    void loop() {

      // put your main code here, to run repeatedly:

    analog=analogRead(17);

    float temp= 0.322*analog;

     

    ¬† Serial.print(“Temeperature:”);

      Serial.print(temp);

    ¬† Serial.print(“%send to Thingspeak”);

    Serial.println(“Waiting…”);

    ThingSpeak.writeField(myChannelNumber, 1, temp, myWriteAPIKey);

    delay(20000);

    }

  3. Monitor Room Temperature in ThingSpeak from anywhere

    Once the program was loaded, ESP8266 was on the job. Temperature data was sent to ThingSpeak. The data can also be observed on serial monitor.

    Sudden spike in temperature in the attached screen is explained by positioning the sensor near laptop cooler fan blow which is hot.

    Tempdata

     

    Serialmonitor

1 comment on"Internet Monitoring of Room Temperature FromThingSpeak Using ESP8266"

  1. Good article.

Join The Discussion