I'm using Sonoff basic switches, flashed with the awesome Tasmota firmware to control some heaters. I'm using an esp8266 to read the temperature, connect to my MQTT server via wifi then toggle the sonoff switch power. The thing is, for this to work, I'm reliant on the wifi and MQTT server to be running which seems overkill as the ESP8266 and Sonoff switch are right next to each other.
Does anyone know if (and how) I can physically connect the ESP8266 to the Sonoff to toggle it via, I assume, the digital output, essentially using it as a 240V relay and bypassing the reliance on the other external systems?
The end result I'm looking for is a single box that houses my ESP8266 and two sonoff switches, both toggled directly without the need of a wifi connection.
Very very risky trying to connect to a live Sonoff device over a cable. The risk of power potential differences is not worth the effort in my opinion though other may disagree.
You could ditch MQTT by talking to the Sonoff devices using web requests but this still needs Wi-Fi.
Another option is to use a Sonoff TH switch (or convert your current basic to the TH equivalent) with the relevant sensor and do the temperature reading and switching directly.
Thanks for that, I figured from the lack of tutorials that it was a no go but thought I’d ask.
I’m not sure converting the switch to a TH would work in my scenario unless there’s something I’m missing? I’m doing a bit more than toggling a heater based on temperature (although that’s all the sonoff is doing). The ESP8266 is running a web server that allows me to enter details about a beer I’m brewing. It then controls the heat pad to control the fermenter temperature and passes all the data, entered & gathered, via a json post to the brewfather software to attach to the batch I’m brewing.
To my knowledge there’s no way of running any code directly on the sonoff (Tasmota) is there? If I move the sensing responsibility to the switch, I still need the rest of the code to run somewhere and post the json file.
Controlling it via web requests might be a good way forward since I need the wifi to set the parameters of the brew anyway. I was only hoping for a direct connection as a failsafe if the wifi vanished.
If your happy with wiring mains and have spare GPIO pins on the ESP8266 then you could just use a 3.3v compatible relay module (like this) directly connected to your ESP8266.
The ESP that runs the web server and takes the temperature measurements could maybe control a relay module that can just replace the Sonoff switch. That way you don't require Wi-Fi to maintain temperature control but you have to be happy with wiring the mains power into the relay.