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.