On other forums, I had requests for help to achieve what I have done with ESP8266, MQTT and Node-Red to switch my geyser on and off by rules, and an HTML5 web app for family members.
WARNING: WORKING WITH 230v WIRING IS DANGEROUS, ENSURE THE WORK IS CERTIFIED OR DONE BY A REGISTERED ELECTRICIAN.
Firstly, in a previous post I explained the components and how they work together. this one, a bit more technical. Although I am steering in a direction where Analytics would determine when to switch on and off the geyser, with inputs from outside temperature, day of week, month of year, this implementation describes the basics, from where you can build further. For this to work, I have the following installed on the RaspberryPi:
- NodeRed - an IBM emerging tech code set released for use to the open source community. Quite a few of their Nodes are used, like MySQL, MQTT, Function etc, details in the attached JSON file.
- Mosquitto - an open source MQTT (message queuing and telemetry transport) server.
- MySQL - an open source database server.
Secondly, find below in figure 1 the node-red flow, which I host on a RaspberryPi 2B+. A description:
- An incoming MQTT message from the ESP8266 about the switched state of the Geyser relay, displays on the html5 screen, and writes the state update into a MySQL database.
- On screen event ‘GeyserOnOff’ - a switch, for On, a delay of 25 min is implemented, thus a fan member can override the status of Geyser Off to shower outside of agreed time, but only fro 25min.
- Same screen can switch off the Geyser.
Figure 1: Node-Red process flow.
you will find the json file at the bottom of this post for this flow.
Thirdly, the configuration on ESPEasy code of the ESP8266 12F. I use the Switch Input sensor, with, on the Config page the OpenHab MQTT server comms protocol. See in figure 2 below the settings on the ESPEasy web app.
Figure 2: ESPEasy Switch setup on an ESP8266 12F
Fourthly, the ESPEasy code has an option to run rules straight on the micro controller, switched on under Advanced, below the rules which switches the geyser on and off.
————————————-on Clock#Time=all,04:00 do GPIO,16,1endonon Clock#Time=all,09:30 do GPIO,16,0endon
on Clock#Time=all,18:30 do GPIO,16,1endonon Clock#Time=all,23:30 do GPIO,16,0endon—————————————
Fifthly, I use the user interface “UI” a node on Nodered, here, with which to provide home members to view the status of the geyser switch, and get the schedule of when it will be on or off. This is deployed on the RaspberryPi’s node red server. The Interface, in figure 3, runs on a phone web browser, where home members can see if the geyser is on or off, and how long it has been in this state.
Figure 3: Geyser Interface.
Future One: I have already tested with rather let the RaspberryPi control the geyser schedule, which will give more cognisance to different times for weekends, vs summer and winter time. For this, I used the great Scarrgill BigTimer, on node red here. Works very well. See figure 4 for the flow.
figure 4: Using the Scargill Big Timer Node to control the geyser.
Future Two: Working on analytics to work out the best time per day, per day-week, and per season to switch on and off, based on past documented history in the MySQL database, and maybe with a link to home members calendars.
Future Three: Many other interfaces and phone apps are popping up to control things in the home. I am will look into:
- Linking with my Apple TV to access Siri: homebridge - here
- PiMatic - here
- Cayenne My devices - here
- Emperihome - here
And, lastly, the wiring of the circuit. I used a 100Amp solid state relay, wiring was a big issue, I used a 4N25 onto coupler to isolate the ESP8266 circuit form the 5v switching the 100A relay, but it came only after deep-dive into the 4N25’s circuit design theory. See previous post on this!
I hope you found this useful!