New Firmware for OLD 3 Channel Wifi Relay

Hi Everyone,

I have taken Martin Harizanov’s 2015 firmware for the older 3 Channel Wifi Relays and dragged it kicking and screaming into 2023. This fork of the code is actively maintained (2023), builds cleanly in Platform IO and has been rebased against NON-RTOS-SDK 2.2.1 (the latest one PIO supports).

Note, this firmware will NOT work with the currently sold - single channel relay in the shop, but I suspect could easily be adapted.

Flashing can’t be done OTA due to the 512K flash in the older units.

This release adds the following enhancements:

  • Full support for MQTT thermostat source
  • Enhanced MQTT reporting (state, DS18B20 JSON)
  • Avoid thermostat cycling
  • New Config items for MQTT thermostat timeout & thermostat cycling
  • Display of a bad or stale temperature readings highlighted in thermostat UI, and subsequent thermostat disablement
  • Change thermostat to work in tenths of a degree, not hundredths (direct compatibility with emonTh + emonGLCD via MQTT sources)
  • Publish all ds18b20 sensors to MQTT by device-id
  • Choose which relays associate to each thermostat
  • Alignment of UI time with server time

This may be breathe more life into the older 3Ch relays, particularly the ability to use MQTT as a thermostat source.

I will update how to do the flashing and provide firmware binaries in the near future.

2 Likes

Good news! The problem is that I don’t remember how to install the platformIO NON-RTOS-SDK 8266 framework. :face_with_diagonal_mouth:
Any plan to make a tutorial?

Thanks.
These boards are awesome so I wanted to prolong their usage (and needed the MQTT thermostat input for my own projects).

Can you try cloning the repo and opening in PIO ?
I think PIO should realise using the platformio.ini file and install all the magic for you.
Can you let me know if it doesn’t ?

As an aside I’ve been looking at how to bring the code further into 2023, but sadly the v3.x of either RTOS or non-RTOS need a minimum of 1mb of flash. The 3ch relay has 512Kb.

Wow…even better. There is a fork of the 3ch relay, adapted to one relay, that I’m using on a different esp8266 board (I think it has 1MB flash, otherwise, the memory chip could be changed). How come you chose to maintain the older version? Was it for the extra 2 relays?

I’m using the 1 channel version with a remote sensor, and a few changes I did to the interface.

I’m not able at the moment to test your code but I’ll definitely do it as soon as possible (weeks).

At the end of this post [WiFi 1CH Relay - get temperature from 433Mhz remote node - #5 by fpaliuc] you can see the way the UI looks with my changes.

I used the existing code as I didn’t know other efforts existed. I simply went to Martin’s page and found his GitHub. If I’d have known there were other efforts that might have saved me some work. If we can, we should look to merge efforts after we prove this works outside of my own environment. In particular improving the Serial part in line with what you have done.

I’m pretty sure we could make the code adaptable to both modules with some #defines and compiler directives. I don’t have a 1ch relay to try with, but do plan to upgrade one of my 3ch devices to larger flash (to see if I can get OTA upgrades to work), meaning the 1ch relay would also work.

Last night, I got the build to work cleanly outside of PIO via the Makefile : (you can simply download the xtensa compiler and non-os-SDK 2.2.1, put them in a directory, edit the Makefile with their locations and run make.)
I’m still working on getting the complied firmware and upload script done so that people don’t have to compile it themselves.

I’ve added flashing instructions and firmware binaries to the GitHub repo.

I’m not a programmer, I’ve just tried my best :grin:
As for the 1ch relay part, you could just use a normal NodeMCU ESP8266 board or something similar, maybe with an LED connected instead of the relay.
For my thermostat I’m using this board: https://www.olimex.com/Products/IoT/ESP8266/ESP8266-EVB/open-source-hardware

This is the 1c relay code I used as base: https://github.com/openenergymonitor/ESP8266_Relay_Board/tree/master/1ch_relay

Hi Everyone,

The code has been substantially updated, and builds with latest SDK (3.0.6) ESP8266_NONOS_SDK, has FOTA update functionality and a plethora of new features.
I believe this will also work on 1ch boards, and the number of relays is configurable.

  • Full support for MQTT thermostat source
  • Enhanced MQTT reporting (state, DS18B20 JSON)
  • Avoid thermostat cycling
  • New Config items for MQTT thermostat timeout & thermostat cycling
  • Display of a bad or stale temperature readings highlighted in thermostat UI
  • Fix bug where thermostat relay off time is updated if it is already off
  • Change thermostat to work in tenths of a degree, not hundredths (direct compatibility with emonTh + emonGLCD)
  • Publish all ds18b20 sensors to MQTT by device-id
  • Choose which relays associate to each thermostat
  • FOTA Upgrade via webpage upload (thank you ESP-LINK project for the code)
  • Thermostat timeout for all sources implemented
  • Move all thermostat config to its own page in the Web GUI
  • ESPFS webpage upload now available through the Web GUI
  • Tidy up about.tpl page and only show firmware upgrade options when flash_map > 2 (over 512Kb)
  • Disable URLs for flashing firmware if flash_map < 2 (512Kb board)
  • Supports DST for Europe and North America (thanks Martin Harizanov for the code template)
  • Correct relay active for thermostat indicated in MQTT and JSON feeds (instead of relay1 default).
  • CurrentSetPoint published in state JSONs
  • Number of relays is now configurable via UI - if relay is not configured, it cannot be actuated via any means. This means code should work on 1-Relay boards and have correct UI and logic
  • Relays configured as thermostat controlled cannot be actuated via any other means (webpages, IO calls, MQTT)
  • Main menu updated
  • UI overview page completed to show relay, thermostat state and all sensor readings available on main menu
  • Thermostat colour map gradients configurable from web UI
  • Display all DS18B20 & DHT22 sensor values on new UI overview page
  • Tidy up serial interface - add help and validation of inputs
  • Add serial userJSON input - JSON can be submitted via serial, is published to MQTT and thermostat.cgi?state to allow easy customisation of webpages to support random serial devices
  • Add manual override mode to thermostat, if setpoint is adjusted while in scheduled mode, go into override mode; setpoint will reset to the next schedule temperature when it comes around
  • Add syslog logging feature for thermostat events
  • Thermostat Zone name configurable and thermostat.html page title reflects zone name (useful for multiple thermostats)
  • Able to download full week thermostat schedule in JSON format, upload one day at a time

Instructions for flashing, building and use are on the GitHub page above.

I think its important these boards have continue to have the open source firmware developed with feature parity (or in this case, more features) than the sadly closed alternative… we are called open energy monitor after all.

1 Like

Thanks for sharing @alandpearson this looks great, actually epic! nice work!

Thanks Trystan, I’ll reserve the epic title for your original thermostat code you wrote many years ago and the solid core by MartinH. I simply hacked bits onto the side :slight_smile:
Martin also merged into his GitHub release today. I think it needs some more testing, esp. on 1ch boards.
I also owe you an update to emonlib, it’s on my list… should be soon.

2 Likes