ESP8266IOT Projects

Ubidots Nodemcu Light Intensity monitoring using Gauges and Charts

Ubidots IoT Platform, Description:


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

  1. How to send the sensor data from the Nodemcu esp8266 wifi module to the Ubidots IoT Platform.
  2. How to display the value stored in a variable on gauges and charts.
  3. Circuit diagram explanation
  4. Interfacing and finally number
  5. Testing

Amazon Links:

Arduino Uno

Arduino Nano

Nodemcu ESP8266 WiFi Module:

LM7805 Voltage Regulator:

470uf capacitor:

330-ohm resistor:

DC Female Power Jack:

Female Headers:

Male Headers:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

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.

#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(){
    pinMode(LDR, INPUT); 
    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);

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:



Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button