This example shows how to log data from Arduino to Thingspeak using ESP8266 WiFi module. ThingSpeak is an open source Internet of Things (IoT) application and API to store and retrieve data from things using the HTTP protocol over the Internet or via a Local Area Network. ThingSpeak enables the creation of sensor logging applications, location tracking applications, and a social network of things with status updates.
To log the data to Thingspeak, you need to create a Thingspeak account and then create channel and use that channel's API Key in this code.
In this example we have used
ELClient.h library to log data to Thingspeak. Temperature values from LM35 temperature sensor and Light values from LDR are logged to Thingspeak every 5 minutes for 24 hours. This interval rate and duration is configurable. Thingspeak needs 15 sec delay between updates.
The light Dependent resistor or LDR is a light controlled variable resistor, the resistance of a LDR decreases with increasing light intensity, the resistance of LDR increases when the light intensity is decreasing ,we will monitor this reading with the help of IdIoTware shield and post the data to the ThingSpeak website using ESP WiFi module.
However on the IdIoTware shield, the LDR is wired such that with a higher Light intensity we get a higher Analog Voltage on Pin A3.Temp:
We are using LM35 temperature sensor to monitor the temperature. The IdIoTware shield has a built-in, on-board LM35 sensor. We will post the data over the ThingSpeak website.
- The sensor has a sensitivity of 10mV/oC.
- We use a reciprocal conversion factor , that is 100 oC/V.
- The output voltage varies linearly with temperature.
- The general equation used to convert output analog voltage (Vout) to temperature is:
- Temperature ( oC) = Vout * (100 oC/V)
- So if Vout is 0.5V, then Temperature = 50oC
However on the IdIoTware shield, the LM35 temperature sensor is wired such that with a higher temperature we get a higher Analog Voltage on Pin A0.ThingSpeak
ThingSpeak is an open source data platform and provides API’s for the Internet of Things. Follow the steps below to create your own account, and see the temperature, and light values measured by your IdIoTware shield, appear on the web.
You will need to upload ESP link firmware to ESP8266-01 module to configure WiFi SSID and password. Visit this link for more information.
Plug in the ESP-01 module supplied and upload the code into the Arduino. Now you are ready to start sending data to Thingspeak, from the IdIoTware shield. The code publishes the values of Light and Temperature every 5 minutes to the Thingspeak portal.
After 5 minutes, you can open the browser, go to Thingspeak URL, select your channel and check for the values of light and temperature your IdIoTware shield has published on the web.
You have your own weather station up and running, that can monitor the light and temperature, of your room, or home, over the Internet from anywhere in the world!
With the idIoTware shield the sky’s the limit!