In this Instructable you find out how I read my Main Electricity Power use of my house and publish it via an ESP8266, Wifi, MQTT in my Openhab Home Automation.
I have a 'smart meter' ISKRA Type MT372, however it has no easy possiblility to export the data. Therefore I used the LED pulses to read the current Power, the LED pulses 1000 times for 1 kW/h.
Step 1: Principle Scheme
The pulses are detected by an ESP8266. However, you need a good and clear '0' and '1'. The pulses are quite weak so I needed some suitable electronic components.
A photoresistor is not fast enough to detect the short and weak pulses of red light. Based on this Youtube video I choose a phototransistor. By adding a 2M Ohm resistor I could reach about 2V.
However, to ensure a clear '0' and '1' I choose to add a LM293 comparator. By connecting a 0.6 V to Vin and the phototransistor the Vref, I got a positive signal in the dark, and a negative signal at the pulse. The appropiate voltages were found by using potentiometers for the Vin and the Vref voltage. With the comparator, I used a 300K resistor.
By using a pull-up resistor on the output, I could get an output difference of almost 3.3V.
The output is shown at the oscillope screen.
The ESP8266 detects the low voltage when there is a pulse. It sends the output data to my MQTT broker. The data is received by:
- Node-red via which the data is uploaded to Thingspeak
Step 2: Components
Step 3: Programming
The program is published on my Github: https://github.com/Wim3d/Main_power_meter
See the scheme for the outline of the program and the method the power is calculated.
I program my ESP-01 via a modified USB-programmer. I soldered a button switch between RST and GND forn an easy reset and a slide switch between GPIO0 and GND to boot in in flash mode.
Step 4: Assembling
Al the parts are soldered to a prototype PCB.
See the pictures and the scheme for explanation.
Blue LED: the blue LED is attached to the output signal of the LM293 comparator an lights independent from the ESP8266.
If there is no pulse (dark), the voltage output from the phototransistor circuit is low, therefore Vref < Vin (steady voltage of 0,6V) and the output of the LM293 is high, no current flows to VCC and the blue LED is OFF.
If there is a pulse (light), the output from the phototransistor circuit is higher (ca. 1.5V) therefore Vref ? Vin (steady voltage of 0.6V) and the output of the LM293 is low, so current flows from VCC and the blue LED is ON.
Green LED: the green LED is attached to GPIO0 of the ESP8266 and pulses if the ESP8266 has detected a good pulse.
Step 5: Mounting to the Electricity Meter
I used some sticky putty for posters to mount the PCB in the box and the box to the meter, not to damage the meter. It is important to drill a hole at the exact position of the LED. Bend the phototransistor pointing down to the LED.
Step 6: Powering Up
I used some more sticky putty to prevent ambient light shining into the phototransistor as I opened the case in daylight. Drill a small hole in the lid to see the LEDs blink (not on the photos).
Read the values in Openhab to get these cool graphs!