Enhanced ESP-01 WiFi relay/SSR/opto module & 555 emulator.

Public Chat
Similar projects worth following
Yet another ESP-01 relay board but better: Does not glitch on boot! Breadboard friendly. In-situ programming. On-board buttons. Choice of outputs (GPIO, mechanical relay, PCB SSR, Fotek SSR, MOSFET, opto-isolated DC push-pull). Easy DIY customisable. No second micro controller in the way. Control by WiFi, GPIO, serial & button - all at the same time. Or by 1-wire device.

Can easily be used in place of a 555 with much butter control of the pulse shape & timing. Can even be used as an in-circuit emulator for a board with a 555 socket.

I wanted to power a solenoid valve for a short pulse.  I used a 555 board & an SSR board.  It worked OK but not very convenient.  Once I'd hacked the 555 board with reasonable R & C values, the timing pot was pretty coarse & any bump would change it.  I needed to be able to set different pulse lengths for different uses and select between them instantly & reliably.  But most of all, I need the pulse to be on for a maximum - even if I've left my thumb on the button for longer than the pulse should be.  The 555 is fantastic for a couple of pulse scenarios but there are many useful pulse patterns that can't be done even with a 556. 

The ESP-01 (S or not) has at least 2 usable GPIO pins for the trigger & output and they are cheap and common like the 555.  It was easy to program a GUI full of simple & elaborate pulse pattern choices to use from any browser by WiFi.  There are a few different ESP-01 relay modules available cheaply but they seem to all have problems of some sort.  I've seen 3 slightly different designs which all glitch the relay during power-on or reset.  In some uses this could literally be fatal.  Another design uses a second micro-controller to avoid the glitch but is awkward to use and many fakes are sold unprogrammed.  To use these boards I also bought a breadboard break-out and a programmer (to which I had to add PRG & RST buttons).  But worst was that I had to move the ESP-01 from the relay module to the programmer every time I wanted to make a change. 

So I made a list of wants & needs and designed a better ESP-01 relay board with all the trimmings, optional wherever possible to enable the same PCB to be used in many different configurations.  I tested the proof-of-concept by modifying one of the other boards: cutting tracks & soldering new components onto the exposed pins of others.  As with the modification of the original 555 board, this was a time consuming & fiddly pain so I resolved to make my version as hackable / DIY-friendly as possible.  Hence the combination of SMT & THT with header pins, mounting holes and a less cramped size, all for user convenience. 

Preventing the boot glitch was the main issue to resolve.  A simple R-C low-pass filter driven by a buffer transistor inserted between the GPIO pin & the output switching FET was all that was needed.  I don't understand why other designs didn't already do this.  After testing & tweaking I found an R-C combination which works reliably and still allows a switching time of under 20mS - never an issue for a mechanical relay and even fast enough for rough PWM with an SSR.  The next biggest issue was GPIO pin choice.  Rather than go through all the considerations I'll just summarise the main points of my choices below. 

GPIO0 for the !TRIGGER input.  To allow in-situ programming, it needs a button to GND on GPIO0 anyway so as long as you understand the implications, it's perfectly OK to re-use that for run-time use too.  The "TRIGGER" signal is active low ("!" prefix) to match the program enable usage.  In the worst-case scenario where the board is booted while GPIO0 is unintentionally held low, no harm will come: The relay will not be energised & the program will not be erased.  Just power it off, remove whatever was holding GPIO low & power it on again - all will be fine.  In fact, it can even be used for an IR-receiver or 1-Wire bus sensors such as DS18B20 without interfering with the normal boot process.

GPIO2 for the !OUTPUT switching.  To allow full use of serial in both directions on GPIO1 & GPIO3, the only free pin left is GPIO2.  The "OUTPUT" signal is active low ("!" prefix) so that it is inactive on initial power-on for safety.  For 555 emulation this needs to be inverted by a push-pull "totem-pole" opto-isolator which is a good thing to have anyway. 

... Read more »


GUI running a 60mS pulse to a mains load (alpha version)

Portable Network Graphics (PNG) - 185.88 kB - 05/08/2021 at 12:22



SIL PCB SSR & foot switch

image/jpeg - 2.03 MB - 05/08/2021 at 12:10



GUI during a running delay (alpha version)

Portable Network Graphics (PNG) - 239.96 kB - 04/15/2021 at 18:15



Serial logging (alpha version)

Portable Network Graphics (PNG) - 516.88 kB - 04/15/2021 at 18:15



First software (alpha version)

ino - 20.62 kB - 04/10/2021 at 15:40


View all 7 files

  • 2021-06-12 - Pulsed AirCannon at 22:42 0 comments

    Just successfully tested with my AirCannon & a "rapid paintball distribution" adaptor which shoots 10 paintballs in all directions, using a 100mS pulse of about 40psi.

    The important bit is that the valve closes fast enough to keep enough air in the 24 litre tank to do 2 more shots.  Maybe 4 shots in total when I fully charged to 90psi next time.

    As an interesting side-effect, when it goes off, it's *much* quieter than an uncontrolled release. 

    Also tried a bit of spot-welding recently, using a repurposed microwave transformer.  Unfortunately the FOTEK SSR I had was only going ON with quite a high resistance - presumably a flakey fake.  So while not thinking properly, I tried it on the WiFive55 board with the inline SSR which is only rated at 3A.  Handy note: that SSR fails-ON, so beware.  Fortunately I bought 2 inline SSRs so I replaced it for the above AirCannon test.  Still waiting on another FOTEK, hopefully genuine!

  • 2021-05-08 Test with onboard inline SSR at 11:02 0 comments

    When I designed the alpha board, I thought that most SIL-PCB relays and SSRs had a very similar footprint. But when I went to buy an SSR I found that by far the most common cheap SSR has the same layout but in a larger footprint. So for the alpha board test, I've put it on wires and tucked it underneath the PCB. 

    Having killed a couple of the small BS170 MOSFETs by running without a gate resistor (which the original design had) I bought some 2N7000 MOSFETs which are cheaper and lower rated but should be good enough.  Annoyingly their TO-92 pinout is not the same but at least it's just rotated 180 degrees, so still fits fine.

    I also reinstated the MOSFET's gate resistor with a 470 ohm to match the LED resistor, thus reducing variety & assembly costs.

    A handy aspect of the flexible configuration by solder-jumper & easy-access pin headers means that with a single jumper wire from GPIO0 to GPIO2, I can test the transistor, MOSFET & output device using just the on-board trigger button.  No need to have an ESP-01 installed!

    I then put this board into the original project box, replacing the separate 555 monostable & SSR boards.  All works fine.

    The latest PCB design includes these and other changes and now that this last test is complete I'll be sending off for the new PCBs soon.  I'll probably get them assembled with the essential/cheap components as SMD, leaving regulator, header pins, sockets & screw terminals to the user.  And of course leaving the final output device free for the users choice.

  • 2021-04-10 Start of Hackaday page & summary of the story so far. at 15:09 0 comments

    Identify the need, list of goals & hacked together a proof-of-concept as per the details section.

    Wrote (first generation) of software using WebSockets for good a selection of pulse patterns. All OK.

    Read lots about submitting to PCB prototyping companies.  Settled on KiCAD, with the simplest viable THT design to improve chances of success.  First 3 boards were perfect first time.  Assembled in 3 variations: mechanical relay, opto-isolator & off-board SSR (will add onboard inline PCB SSR when I find it).  Only have a few little SMT regulators to hand to soldered on legs & a heat-sink.  All pics are of these first boards.

    Test in every configuration with both "ESP-01" & "ESP-1 S".  Tweak a couple of component values.  All OK but identified a few opportunities to improve layout - particularly for mains traces.  Start the feature-creep!  Add MOSFET option.  Add edge castellations for direct Fotek SSD mount.  Test with 1-Wire DS18B20 - no additional components needed.  Update PCB design for next version including looking at how to mix THT & SMT for assembled or kit options.  Look at BoM management & component sourcing,

    Start planning new software architecture to support multiple concurrent control streams.

    Outline software for special cases using teamed boards.


    Finish combined THT/SMT PCB design & get new boards made & assembled.  Q: How many?

    Finish second generation software - no hurry as gen1 does what I need & still better than any other.

View all 3 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates