Ubidots Nodemcu Light Intensity monitoring using Gauges and Charts
Table of Contents
Ubidots IoT Platform, Description:
Ubidots Nodemcu Light Intensity monitoring using Gauges and Charts- In this tutorial, you will learn how to monitor the Light intensity using Ubidots Gauges and Charts along with the time and date information. This is a Ubidots Nodemcu LDR based Light Intensity Monitoring system. This is a getting started tutorial and explains the extreme basics like for example
- How to send the sensor data from the Nodemcu esp8266 wifi module to the Ubidots IoT Platform.
- How to display the value stored in a variable on gauges and charts.
- Circuit diagram explanation
- Interfacing and finally number
- Testing
Amazon Links:
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
LDR with Nodemcu Circuit Diagram:
As you can see the Circuit Diagram is really simple. LDR is connected in series with a 10k resistor, which makes a voltage divider circuit. As you know LDR stands for “Light-dependent Resistor”. LDR is basically a variable resistor whose resistance changes with the amount of light falling on the LDR. So as the resistance changes due to the light, it results in the change of voltage. This change of voltage is monitored using the Analog Pin A0 of the Nodemcu esp8266 wifi module.
LDR interfacing with Nodemcu ESP8266:
As you can see the LDR is connected in series with a 10k resistor. The orange wire is the 3.3v wire. Blue wire is the Ground wire. While the white wire is connected with the A0 pin of the Nodemcu module. These connections are as per the circuit diagram as already explained.
Ubidots esp8266 library:
Before you start the programming first of all make sure that you download the Ubidots-esp8266 library. “Click Here”
After you download the library the next step is to open the latest version of the Arduino IDE and add this library.
LDR Nodemcu Programming:
For the Step by Step program explanation and how to find your Ubidots TOKEN watch video tutorial available at the end of this article.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#include "UbidotsMicroESP8266.h" #define TOKEN "BBFF-J7PJo14TCt2bEkOvLPj0M5RKoATGXy" // Put here your Ubidots TOKEN #define WIFISSID "ZONG MBB-E8231-6E63" #define PASSWORD "08659650" Ubidots client(TOKEN); unsigned long lastMillis = 0; int LDR = A0; int ldr_data = 0; void setup(){ Serial.begin(115200); pinMode(LDR, INPUT); delay(10); client.wifiConnection(WIFISSID, PASSWORD); } void loop(){ if (millis() - lastMillis > 1000) { // the ldr value is sent every 1 second. ldr_data = analogRead(LDR); lastMillis = millis(); client.add("LDR", ldr_data); client.sendAll(true); } } |
Before you upload the program first of all make sure that the right board is selected…
and also make sure that the right com port is selected. In your case the com port number can be different.
then click on the upload button and wait for a while….After the program is uploaded wait for the Nodemcu esp8266 wifi module to connect with the WIFI.
Open your Ubidots account.
click on the devices menu and select devices….
as you can see a new device with the name esp8266 has been added. Now if you click on this device you will see the value of the ldr in real-time.
you will see a change in the value as u change the amount of light falling on the LDR… as you can see the variable name LDR, this is the name which I defined in the programming. So this is the variable which we can use now with different gauges and charts. lets display this value on a gauge and chart. click on the data menu and select dashboards…
click on add new widget.
After you click on the add new widget a list of all the widgets available is displayed.
as you can see we have different widgets but for now lets use a Gauge.
click on the add variables.then click on the device which is esp8266…and then select the variable LDR…
you can change the name of the widget…you can change the range value…
now you can monitor the light intensity in real-time using a Gauge…
now let’s add the line chart the same way we added the Gauge….
This is how easily we can use the widgets in Ubidots.
Watch Video Tutorial: