DIY Stand-by Killer Via Home Automation and BL0937 Explanation
Introduction: DIY Stand-by Killer Via Home Automation and BL0937 Explanation
In this Instructable I show you how I hacked a smart switch with power meter function and transformed it to a stand-by killer. Great for charging a phone and killing the power when the phone battery is full.
In my previous setup, I used a timer in my home automation to switch of the load after the pre-set time, but when I was charging a phone or comparable, I wanted to fully charge the battery and then shut off the power to the charger.
If you do not have a home automation or Node Red setup, you can also alter the code of the switch program to do the standby killing in the switch. However, if you want to tweak the settings, this requires a change in firmware. While in a home automation setup you can change the parameters easily.
Disclaimer: The stand-by killer switches of the connected load, but does not switch of itself and remains connected to the WiFi network.
Supplies
* Smart switch with power meter function, based on ESP8266 or ESP8285
* Arduino IDE and FTDI or other UART serial programmer
* Home automation setup, for example Openhab or Node-Red
Step 1: The Principle
In this scheme you can see the principle of the standby killer. The smart switch measures the power and publishes the value to my home automation.
When the power is above the defined threshold, nothing happens.
When the power is below the defined threshold, my home automation wait for a defined debounce time for the power to transcend the threshold. This debounce time also sees that, when charging a device, your device gets a full battery since the power drops and the end of the charging cycle.
If the power remains below the threshold, the switches is switched of by the home automation via an 'OFF' command.
Step 2: The Hardware
I made the standby killer from two different smart plugs with power metering function. Important that the switch is based on an ESP8266 or ESP8285 chip, so you can easily flash the microcontroller with your custom firmware.
The plugs I used where bought on Aliexpress:
* BSD34 based switch from Girier: link
* NEO-coolcam (NAS-WR01W) based switch: link
The BSD34 can be pried open, see my other instructable. For more information on the pinout of this switch, see this website. It is ESP8285 based, see the pictures for the way I connected it to my FTDI adapter. 382
The RX en TX pins are used by the switch and are connected to the main PCB of the switch. If you connect your wires to the solder pads of the ESP8285 PCB, make sure that the connections with the main PCB are inhibited. You can also desolder the whole ESP8285 PCB.
The NEO-coolcam can be opened by removing the allen screw (see picture). See this website for an explanation how to flash the ESP8266 based switch. I did not completely desolder the parts, but I did make a picture of my connections.
Step 3: Power Measuring
The switches I used measure the voltage, current and power via the BL0937. This IC is somewhat similar to the HLW8012 which is used in several Sonoff-devices.
The BL0937 is from a Chinese manufacturer (Belling) and most information is in Chinese, however I found a English datasheet.
Information I used:
* Website of Belling
* English datasheet and application
* Chinese guide
At first I investigated in depth how the IC works and compared it to the HLW8012.
What does the BL0937 do?
On the PCB, the BL0937 is connected to mains via a set of resistors which act as a voltage divider to measure the mains voltage via the VP-pin. The IP and IN pins of the BL0937 are connected to a shunt resistor, in my case of 1m Ohm, and measure the voltage over the resistor which are a measure for the current.
The chip sends pulses on the both CF and CF1 pins as an output. The pulse frequency on the CF pin is a measure for the power. The pulse frequency on the CF1 pin is a measure for the current if the SEL pin is low (ground). The pulse frequency on the CF1 pin is a measure for the voltage if the SEL pin is high (VCC).
According to the datasheet, the pulses are approximately 38 us, which was confirmed with my oscilloscope.
A difference with the HLW8012 chip is that the HLW8012 sends pulses with a duty cycle of 50% where the BL0937 sends pulses with a fixed length. 552