Re-programming 3 channel WiFi relay board - ESP8266 - ESP-03

A few years ago I purchased one of @Martin_Harizanov 3 channel WiFi relay boards from the OpenEnergyMonitor shop, but not used it much, purely because most times that the WiFi is interupted, I lose the MQTT connection which in turn does not automatically reconnect when the WiFi is restored.

I’ve recently had a lot of success programming Wemos D1 Mini boards using the PubSubClient library which seems rock solid, and re-connects every time, so I was considering re-programming the relay board using that library, but first wanted to get opinions and advice if this is viable and any possible problems I’d likely encounter, especially from members who are more familiar with ESP8266EX programming.

There may be other customers out there who experienced the same issue, and may want to do the same. :neutral_face:

  1. Martin has included the schematic in his blog, which should help identify O/P pins which are relay connected, and the board has a switch to put the chip into upload mode.

  2. I have a OEM shop ‘USB to serial UART programmer’, which I’m assuming will be compatible with the board - I just need to solder on some pins, and would like to use the Arduino IDE to write the code as I’m familiar with it.

  3. I’m reasonably confident writing the sketch, and converting MQTT messages to logic to control the pins, as I’ve already done a Wemos project which does just that.

  4. I’m not concerned about losing the Access Point, sensor inputs, Thermostat, etc. I just want to reliably & consistently control the relays via MQTT messages from node-red (although I will probably add some other functions back in).

Any advice or comments would be appreciated.



1 Like

I have one of the single channel versions from the OEM shop and I would be quite happy to try to test any builds you think may be suitable - assuming that I recall correctly that my version is simply the same thing with a slightly different PCB and only one relay.

Just completed a sketch to update the firmware, which although only providing basic functionality at this stage, seems to work very reliably and uploads fine.
I’m using a fork of the pubsubclient library which has a number of advantages over the original pubsubclient, especially that QoS 0, 1 or 2 can now be used.

I’ve been testing the new sketch over the past 3 days with an automated script which sends a QoS 2 MQTT message to the relay board every 5 seconds, the relay board then responds by sending a QoS 2 message back in response. So far 52,299 have been sent, and 52,299 messages received back from the relay board.
I’ve also dropped the internet numerous times and the relay board has reconnected to the wifi and MQTT server reliably.


1 Like


Have you looked at the Tasmota software. Originally intended to reprogram the Sonoff devices but it’s also been used on other boards.

This is all mqtt controlled and you can assign the pins etc and it has an access point in case you change your router.

To your original point about pubsubclient, I’ve been using the library for a few years without a problem but I only send messages through to my emoncms system on a Pi.

I have a separate 4 channel relay board that I control through a couple of web pages that the 03 serves.

My 03 system manages a Heat Bank by turning the boiler on when the HB hasn’t got enough heat. The setpoints are different for when the radiators are on or not. So I didn’t fancy having the control algorithm on the Pi just in case Comms broke down for whatever reason.

Back to the Tasmota software (you’ll find it on GitHub), it didn’t have any option to have local control before, only through mqtt but I think that’s been fixed now. In any case you can always make your own custom version.

Also there might be an issue getting it onto the 03 size wise but I think if you edit out all of the stuff you don’t need in the header files it should fit.


I’ll +1 for Tasmota. Not used it on anything but SonOff devices so far but want to play with a WeMos in the near future.

I looked at the Tasmota image before deciding to write my own, but IMO it was better to add-in the functionality that I needed, instead of deleting out functionality that I didn’t need to make this fit in the 03 footprint.
I’ve just updated the sketch to include DS18B20 compatibility, a bit more in the readme, plus a few other tweaks.

Observations, comments or improvements welcome :wink: