Energy Monitor in 15 Minutes

Introduction: Energy Monitor in 15 Minutes

About: Passion for electronics, and love to solve bigger problems with the the most performing solution. 'Let the machines do the work' Founder of Skjold Display.

This is a wifi sensor to tape on the flasher in your electricity meter.
It detects flashes with LDR, and displays power on OLED display.
Sends data to Thingsboard Dashboard,live example here.
Sign up for a free demo account:

Parts needed:
ESP8266 TTGO 0.91" OLED (or regular ESP8266 and run without display)
LDR (light dependent resistor)
10K resistor

About 9$ total.

The ESP8266 TTGO 0.91" OLED is sold on ebay, search: 'esp8266 oled 0.91'.

Step 1: Solder

There are only 4 solder points:
LDR goes from A0 to D0(gpio16).
10K resistor goes from A0 to GND.

Step 2: Code

Program is made with Arduino.
Download code at my Github site:

You need some libraries, U8g2lib, PubSubClient, You find these in Library manager.

Set your values in top of code. They are well explained.

Select programmer 'LOLIN(WEMOS) D1 R2 & mini'.
If you dont see it in boards menu, install ESP8266 in Arduino Boards Manager.

Go to this thread if your TTGO OLED is not working. A few i2c OLED pinouts is showed there.


Step 3: Thingsboard

Sign up for a free live demo at

Add device, with name Energy monitor.

In Device 'Details', click 'Copy access token'
Paste this string to THINGSBOARD_TOKEN in code, and upload.

If all went well, you should now see data in Device 'Latest telemetry'.
Select 'wh' telemetry data (Calculated Watts per hour), and click 'Show on widget'.
Select 'Chart' in drop down, and find 'Timeseries - Flot' in the carousel gallery.
Click 'Add to Dashboard'.
Select a existing, or create a new dashboard.
Select 'Open Dashboard', and click OK.
In Dashboard you want to change Timewindow to 2 hour, and Data aggregation to None.

For the Analog gauge, do the same steps from Telemetry, and select Analog gauge in the Widget.
When you are back to Dashboard, the Gauge parameters edited.
In 'DATA', the number of decimals is set to 0.
In 'ADVANCED', Minimum and Maximum value is set to 0 and 8000,
and 'Major ticks count' is set to 10, to clean 1000 marks.


Be the First to Share


    • Science Fair Challenge

      Science Fair Challenge
    • Home and Garden Contest

      Home and Garden Contest
    • Chocolate Challenge

      Chocolate Challenge



    9 months ago

    Hello Pereskjo, Is live demo still up ? browsed and got message " and got message: "Access Forbidden
    You haven't access rights to this location!
    Try to sign in with different user if you still wish to gain access to this location. "


    2 years ago

    I have updated some text and images.
    Please repport back how it goes.
    The widgets have many parameters, and I recomend play with them to learn what is happening.


    Question 2 years ago

    Hi, could you please clarify the dashboard settings in ThingBoard? I suspect that they may have made changes since the instructable was published thus the data I am getting is not showing correctly like your first image. I had to measure my device and determined my pulse count to be 1000/KwH. Many thanks