#88 A DIY battery + WiFi relay solution
With the ever growing pains of load-shedding looming over South Africans people have been desperately looking for viable alternative energy and battery powered devices. In my case I needed my remote pepper spray devices to be operational in my laboratory even during extended load-shedding times 4h off with 2h charge times.
I could have purchased added a battery and charging circuit to my existing factory made Sonoff board however that could make the PCB larger and I wanted to build a custom solution instead.
My requirements were WiFi capability, at least 4 relays, li-ion battery powered, battery charger with all the standard protection features and for the device to be powered by 5v from a standard phone charger.
The device must be plugged into the 5v phone charger 24/7, when the electricity goes off the device must continue to operate uninterrupted, when the power comes back on the device must change to the charge state uninterrupted.
The device does not have to send a notification when using battery but it must protect from overcurrent and over-discharge.
While looking for components I came across the ESP8266 PSB 04 module which is basically just the MCU WiFi controller used to switch 4 channels by itself
This was perfect for my application because I am already very familiar with Sonoff devices and in this case I do not mind using the firmware on the esp8266 and the Sonoff application + API software for my automation tasks.
Building around the module was a breeze all I needed was the appropriate relay circuits and a decent charging module.
I ended up creating two prototypes because hey there’s always improvements to be made…
The components I used on my final version 1.1 are as follows:
- 4x Songle 10A relays here
- 4x BC547 transistors here
- 4x screw terminals here
- 4x 1N4148 diodes here
- 4x red led 3mm here
- 1x yellow led 5mm here
- 1x LiPo charger MH-CD42 (IP5306 chip on mine) here
- 1x USB-A male cable here
- 1x ESP8266 PSB-B04-CN Module 4-Channel Switch here
- 1x AMS1117 3.3 800mA regulator here
- 2x 10uf 25v caps here
- 2x 100nf 25v caps here
- 1x 18650 battery holder here
- 1x old laptop battery 18650 (LGABD11865)
- 9x 1k resistors here
- 2x small cable ties
- Various male and female headers
I tried to make the design as modular as practically possible
There are 3 main parts in the design consisting of a main PCB which contains the battery and relays = complementary components then the WiFi module with buttons and 3.3v regulator is located on a small green PCB and finally the LiPo MH-CD42 module can be secured on the main board via headers.
While constructing I had to use a 1.6mm drill bit for the battery holes and a 1.5mm drill bit for the relay holes. I soldered the SMD AMS1117 reg onto 3 a pin male header for easy through hole placement. The relays and the screw terminals required more attention during drilling and placement of the holes due to their pin layout. I also coated all exposed wires with nail varnish as a make shift solder mask.
I had to add an extra 1000uF capacitor between GND and 5v out of the LiPo module because it would briefly lose power when transferring from USB to battery power