Tag Archives: RELAY


#95 A simple Sonoff siren trigger

Remote siren Sonoff device

While looking for ways to trigger a siren through the internet I decided to make a small project using inexpensive modules. I decided to use the SonOff RE5V1C without an enclosure because it was the cheapest option available that would satisfy all my requirements. Likewise I used the LM2596S because it was a cheap and easy to use option unfortunately some of the mini options (like the LM2596 Mini Buck Regulator) are to cumbersome when adjusting the output voltage.

Simple schematic (replaced mini with LM2596S )

The number 1 major pain of this simple project was the red and black speaker wire I used…. This wire is actually more of a pinkish color and the insulation can be torn easily by my fingers however, the problem is dirty copper wire inside this cheap cable that would not solder even with a generous amount of flux.. I had to expose the copper and then try to clean them with vinegar and this partially worked.. However lots of time was wasted with this mundane cleaning. Even standard store bought ripcord solders fine compared to this wire….

Anyway in the end it worked out the way I wanted it to and it’s quite light and reliable, I have the whole system hooked up to a dedicated 12v battery that is trickle charged so when the power goes out the devices will still be operational for quite a while.

The RE5V1C uses from 80mA to 250mA according to the datasheet but I have a 40W siren connected to the relay so if triggered it will use from about 3A to 3.5A depending on the supplied voltage 11.5v – 13v


#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…

Drill holes for terminals and relays
ESP8266 board with buttons, led and 3.3v regulator
Headers to mount LiPo and ESP8266 boards

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

Version 1.0 with lots of hot glue and test points
Version 1.1 board layout


#81 Building a 12v relay on a cheap PCB board

Completed relay

While working on one of my projects I needed a 12v relay unfortunately I did not have one on hand and was not about to pay for 1 relay plus shipping.

Luckily I had all the components at hand:

1 green and 1 red led
2x 470 ohm resistors
1x 1k resistor
1x 1N4007 diode
1x bc547 transistor
1x 12v relay
Some solid alarm wire
Very cheap rectangular PCB

For a 5 volt version just replace with a 5v relay and 2x 100 ohm resistors for the LEDs.

Unfortunately the PCB I had was very cheap and I could not fit the screw terminals I had so I had to squeeze them in.
I also used thin alarm wire as i did not need to switch high amps but luckily everything worked out in the end.

It was a bit messy but next time I will use a better quality PCB that doesn’t burn tracks when making solder bridge tracks.

The BC547 also allows switching with 3.3 volt logic but remember to supply the 12v



ESP01 + v4 relay module.

While looking for a cheap wireles relay solution I found the ESP01 + relay module package.

This ESP-01 Relay Module based on AI-Thinker ESP-01/01S WIFI module. It is designed for smart home, internet of thing and others DIY project. With this smart relay, you will easy to DIY your smart switch to control any device by your phone anywhere using the popular ESP01.

The board is surprisingly small and has a thin PCB.

Relay module bottom.
Relay module top.
Close up.
Pin out
ESP01 pin out
ESP board types



A quick solder up to test the circuit (had issues with power sharing between GSM module and ATTINY85)

My first attempt to build a small circuit which controls a relay to an alarm speaker was a failure. Contrary to popular belief failure in electronics projects is quite common and I would argue that it is of paramount need if you want to learn anything.

Surprisingly my failure was in using the ATTINY85 instead a Pro Mini, Uno or Mega. Some problems I had were:

  • Not enough RAM to hold all my variables (I had to scrounge 😢)
  • Very limited FLASH memory.
  • GSM module interferes with the ATTINY’s 5v power source when connected using the same source with no filtering.

In a later project I created a reliably working solution with the Pro Mini as the brains.

My goal was to create a small circuit which uses the ATTINY85 as the brains. It uses the A6-GSM-Module to receive SMS’s, phone calls and sends TCP data. Finally it has a 5v relay which will switch on/off an alarm speaker. The theory is that when I’m on the farm in the fields and not near the house, I have the option of remotely starting an audio alarm at will. This should be a deterrent to potential criminals.

I made an easier to debug testing circuit with exposed copper traces (Same issues)

After making an easier to debug circuit I tried to get the ATTINY85 to work happily with the GSM module. This was going to be a bit complicated and I suspect I would have to isolate power between the ATTINY85 and the GSM module. This would require more components and the board is already looking cramped. A much easier solution is to use the Pro Mini instead of the ATTINY85.

The Pro Mini is most certainly a beauty.