Monitoring energy consumption using ESP8266

IMG_20171101_135839

Any home automation enthusiast with any ambitions at all need to monitor energy consumption. It took me more than a year to get around to it. But once I got the units delivered and understood how the energy meter from the power company functioned things worked out pretty much right away.

IMG_20171029_205604

The hardest part of the project is to find the enclosure for the digital pulse counter (which detect the IR signal from the energy meter). The way that the digital pulse counter is intended to work is to blink with one diode and detect that signal with the other, you’ll understand that you do not need to have one of the diodes. The one which transmit the infrared signal is obsolete in this use-case. You can simply put a tape over the diode to prevent it to influence the measurement.

The power meter is in many cases placed on the outside of the building and you might have problem finding electricity to power your micro controller (ESP8266). Oooh, the irony!

IMG_20171125_193651

IMG_20171125_193726

I made the decision to have a long cable from the inside of my garage. That decision made me need to fix some problems with the loss of voltage due to the resistance of the long cable. To compensate this I feed the digital pulse counter with 5V and ended up getting the pulse signal to very be close to 3.3V. You’ll need to measure this level since you must make sure that the signal for each pulse is in the range of 2.4V-3.3V, if the level is lower than 2.4V the pulse will not be detected by the ESP8266. Just for info, levels you want to obey if you are using switches, pulse counters or similar devices:

High: 3.3V-2.4V
Buffer: 2.39V-0.81V
Low: 0.8V-0.0V

The digital pulse counter is physically attached to the energy meter using 3M Dual Lock which is placed in front of the pulse led of the energy meter.

With a 6-wire cable I had the opportunity to use some spare wires to monitor other things. A micro switch to see if the door is open or closed was a good feature and it was placed in the corner of the door. Works like a charm.

To control the ESP8266 I use the Swiss army knife of firmware, ESP Easy. The settings are as follows:

The energy meter is noted with the information that each pulse (blink of the led diode) equals 1 Wh, or 1000 pulses equals 1kWh. I want to show the momentary energy consumption, to do this I count pulses for 10 seconds and then multiply that number of pulses with 3600 seconds (that’s the number of seconds per hour) and then divide that number with 10 (to get the Watts which are in use at the moment).

If you want to measure the kWh you’ll just publish the pulses divided by 1000, and you’ll have that each pulse is equal to 0.001kWh.

Burst_Cover_GIF_Action_20171125194441

A really nice feature of the digital pulse counter is the small red led diode which flash for each detected pulse. Using the adjustment wheel you can fine tune the detection level which makes the device really robust and withstand unwanted signals from the outside. Turn the wheel until the red led light shines constantly and then turn it back slowly until it start to detect pulses, this is the level you want to have.

IMG_20171101_135747

IMG_20171101_135832

An extra feature of the unit is to have a single relay board to control a led stripe which I can have automatically lit up if the light inside the garage is below a given level when I get home. I will tell you more about this in a later blog post.

Hardware used:

NodeMCU (ESP8266)

Box (enclosure)

Single relay board

Glands

Rubber grommets

PCB anchor / fixation

Micro switch

Dual lock tape

Pulse counter device

Enclosure for the pulse counter

Enclosure for the 6-wire soldering

Led strip

Cable mount

3 pole stereo plug

3 pole stereo port

Dupont cover

Dupont female connector

Dupont crimp tool

The software:

ESP Easy (the firmware)

Mosquitto (to talk to the ESP using MQTT)

Portable Mosquitto (self made with no login needed)

Q&A is found on the ESP Easy forum:

Forum thread