Making a smart meter out of a dumb one for 4 $

and displaying it on an awesome dashboard

Posted on 2018-10-19

As a geek who has a few servers and other devices at home I can't stop thinking about my power output. I always wanted live stats on my power consumption but my power company won't install a smart meter so I had to improvise

Step 1: What do we have and how can we use it?

My power company installed this ISKRA M17 power meter.

ISKRA M17 1376 power meter

It has no interfacing mechanisms and it was sealed by the power company so I have no chance to attach any probes to the thing and get data directly.

But it has an LED that blinks 1000 times per kWh. So one blink equals 1 watthour of energy usage. Perfect!

Step 2: Building something that can log the blinking

So I need a method to log whenever a light flash occurs. Since I don't have a network cable by the power meter I want to log it via Wifi so a NodeMCU (esp 8266) would be the way to go.

To accomplish this I'm using only three components

The squad is ready

Components in detail

A 10 Kilo Ohm resistor - 0.01$

A cheap photosensitive resistor - 0.02$

The cheapest NodeMCU board I found on Ali Express - 3$

All in all under 4$ including shipping.

Wiring it up for a test

So simple it doesn't even need a diagram

Putting it together and taping it on the power meter

Wiring it together so it has the smalles footprint

The tape is not only to prevent it from falling off, but also shields the sensor from outside light

I ended up powering the thing from a 5v rail but if your meter has no power outlet near it you can also use a power bank. I calculated that with a 20100mAh power bank you can power the device for 10 days.

Step 3: Log each blink

I'm using a simple - just print whatever the analog value is - script. I moved my flashlight over it and we can clearly see each spike.

Example script that plots the value of the light sensor
void setup() {

void loop() {

Now log it to InfluxDB

I chose InfluxDB because it's a timeseries database which means all values you are logging have always the time as primary key and are therefore incredibly fast.

To avoid deadlock situations we're just going to use UDP with InfluxDB. The idea is that each time the NodeMCU sees a spike, we just push a value of "1" to the database. So every time 1 Wh of energy has been used by your house, a "1" will be added to the database.

Why "1"? Because then we can use the "count" or "sum" function of Grafana and we can calculate power usage for any given point in time and range of time. You'll see later what I mean.

I have created a script that not only logs each blink, but also handles wifi disconnects and reboots itelsef if necessary.

Get the code >>here<<

Step 4: Make a nice dashboard for it

I'll be using Grafana as a dashboard because it's so beautiful and I love a good looking graph :D

After adding your database as a data source in Grafana, create a new dashboard and select your data source and measurement

You'll see that you can't see anything useful because by default the mean value is plotted. And the mean value is of course always 1

Okay let's make it useful. Click that little "+" icon in the "select" row and select Aggregations -> count

This will make it a bit more useful

Now in the tab "Axes" select the "Unit" Energy -> Watt-hour (Wh)

Now you have a corretly labeled graph of your power consumption

Example graph for one day

Just don't look at it too often, you'll hate your computers


Tags: diy | smartmeter | arduino | nodemcu