ESPHome+Geyserwise Smart Thermostat

RoganDawes

Expert Member
Joined
Apr 18, 2007
Messages
1,453
Reaction score
154
Location
Randburg
I wanted to smarten up my geyser, because while I have solar panels and a battery, eventually the battery is full, and the sun is still shining, leaving energy going to waste. I figured that since I also have an electric geyser, I could use excess energy to heat water, which would otherwise need to come from the grid. I had an electrician move my geyser to the AUX port of my Sunsynk 8kW inverter, but was not happy with the fine-grained controllability of this, and also needed to know what the actual temperature of the water in the geyser was, to know when to turn it on and off.

Wanting to keep a physical failsafe, but still monitor the temperature was a problem. Having pondered all sorts of ways of putting a sensor inside the thermostat, but knowing that I also didn't really want to deal with any leaks if anything went wrong, I decided to go with a commercial product. I found the Geyserwise thermostat for sale by itself at an online store (normally only available as part of a much more comprehensive, and expensive, setup). This contains an NTC thermistor, which is an analog device, meant to form part of a voltage divider. Easy enough to work with, one would think!

The geyser has a 3kW element, which at 220V means a 20A relay should do the trick. First I got a CBI Astute Smart Controller, which is rated for 30A, and reprogrammed it using the LibreTuya-ESPHome project, since it is using a RTL8710BN microcontroller. However, my electrician told me that it could not be installed near to the geyser, as it was not an isolator. I then got the CBI Astute Smart Isolator, and did the same reprogramming. I then realised that the CBI Devices were not mains isolated at their GPIO's, and that connecting the external temperature sensor would potentially be routing 220V into the inside of my geyser! Time for a new approach, using something designed to use external sensors!

The best match I could find for this was the Sonoff THR320, which has a 20A relay, and a RJ9 plug for an external sensor. And if you look at the internals, there is an actual transformer stepping down mains voltage, and isolating the ESP32 in the process. Perfect! The downside, which I only figured out later, was that the exposed GPIO on the RJ9 port was connected to GPIO25, which is in the ADC2 group. Which is not usable if WiFi is in use. I considered a few options:

1. reroute GPIO25 to a GPIO in the ADC1 group. Problem: None of them were exposed on pins or pin headers, and the ESP32 is a VERY fine pitch package in amongst a number of other components, I don't trust my soldering enough to put a wire on the right pin!
2. Turn off the WiFi periodically, take the reading, and turn it back on again. Problem: I wasn't sure that this would work, and I didn't want to take chances with it failing in the wrong state.
3. Since the THR320 was designed for use with 1-wire sensors, somehow make the analog NTC thermistor appear to be a 1-wire sensor.
EDIT: 4. Another option that I only thought of later is to replace the thermistor entirely with a DS18B20 1-wire sensor at the end of the brass tube of the thermostat. This might require trimming the brass tube to allow enough space for the slightly larger component, and also needs 3 wires (in theory you can use 2, would probably also require some testing to be sure).

Googling for 1-wire slave implementations, I found a few, but the most promising was https://github.com/orgua/OneWireHub. This claimed to support a variety of microcontrollers, including the ATTiny85. I found a supplier with some ATTiny412's in stock, but quickly realised that the ATTiny85 and 412 are very different beasts! Fortunately, digging through my parts bin, I found that I already had some ATTiny85's! I flashed the sample code to the ATTiny, using "Arduino as ISP", and implemented a simple 1-wire sketch for the same Arduino.
This resulted in a fairly roundabout test cycle:
1. Flash ArduinoISP onto the Arduino.
2. use the Arduino to flash the firmware onto the ATTiny85
3. Flash the Arduino 1-wire sketch onto the Arduino
4. goto 1

In retrospect, I should have just used two different Arduino's for the ISP and 1-wire sketch, it would have made my life a LOT easier!

Especially considering how many iterations it took me to get things working!

Firstly, I had tried it on an ESP32, to "prove" that the idea could work. The Arduino was able to enumerate the various 1-wire sensors that the ESP32 was emulating. However, when I flashed it to the ATTiny85, I got no results.

I put a logic analyser on the 1-wire pin to see what was happening, but the short answer was "nothing". The master would pull the line down, but the slave (ATTiny) simply never responded. Unfortunately, the ATTiny85 is rather resource limited, so trying to figure out what the problem could be seemed insurmountable.

Eventually, I realised that the sample sketch had a blink function on one of the other pins, so I included that in my logic analyser probe. And after an embarrassingly long time, I realised that the 0.5HZ (1 second on, 1 second off) flashing I was expecting to see was taking 16 seconds! And after some further googling, I found this note in the ATTinyCore documentation: https://github.com/SpenceKonde/ATTi...-you-are-not-using-the-chip-with-a-bootloader

And with that done, the ATTiny85 started responding to the master, and I could move my attention to the ADC half of the problem. A few more lines of code, and reference to https://github.com/kroesche/thermistor_lookup and https://mybroadband.co.za/forum/threads/geyserwise-temperature-probe.1181356/ (for the required constants), I had a working 1-wire slave, reporting temperatures read from the ADC.

And so, on to the THR320! This turned into an interesting exercise as well, as it boot-looped after being flashed with ESPHome. The documented workaround of installing Tasmota first didn't work for me at all. What did work for some weird reason was installing it with no wifi creds, but only ap: and captive_portal:. Then, powering it from AC allowed the device to be reconfigured onto my home WiFi, and reprogrammed OTA as usual.
 

Attachments

Last edited:
4BD11909-4CAA-41E6-876A-BF86AF6DEA1B.jpg
8ACB5378-4D03-4699-97B7-1A6B00D73F62.jpg
642EAA17-619C-4386-93B6-B3E94B9670E8.jpg
502CD379-BC01-4F88-813D-0BD11EA8B106.jpg

The above are pictures of the ATTiny85 "interposer" board, that sits between the THR320 and the Geyserwise thermostat. There is a pull up resistor from the 1-wire pin to Vcc as required by the spec. (I wasn't sure whether this was included within the THR320 or not, so I added it anyway, and it works, so ...) There is also a 10k resistor between ground and the ADC pin, with the NTC thermistor connected between the ADC and Vcc, making a voltage divider.

The black wire in the 4-core is ground, the red wire (clipped off) is not connected, the greenish wire is 1-wire (GPIO25), and the yellow wire is Vcc. I was not able to find documentation on the RJ9 pinout online, so I thought I would add it here. In the second picture you can see the required orientation of the RJ9 connector for this wiring description.

And the last picture shows the connections required underneath the strip board. Basically, I used a 6x6 piece of veroboard, with the middle 4 rows split in half underneath the ATTiny85. The outer two rows formed power buses, being Vcc and ground. I made ground run adjacent to the ATTiny95's ground pin, and Vcc adjacent to the Vcc pin, so all I needed was a small jumper between the adjacent rows. The resistors ended up being wedged into the same holes as the ATTiny85's pins, so perhaps it would have been smarter to have used an 8x6-row bit of stripboard. This was just a convenient piece I had lying around, so I used it as is. It also fitted nicely into the heatshrink tubing that I had on hand.

One "positive" about taking the 1-wire to ADC translator approach as I did is that people with no interest in ESPHome should be able to simply use the Sonoff THR320 as-is, without reprogramming anything. Then they could use the ewelink app to manage it. Not saying I'd recommend it, as my configuration above has many local failsafes built-in, that I would be hesistant to put on the other side of a flaky internet connection. But it would be possible.
 
1680085804657.png
What it looks like in Home Asssitant. I can use the three dots menu to change preset between the default Home (55C), Boost (65C) and Eco (45C) modes, and am currently experimenting with the best ways to detect when to switch between them automatically.

One thing I am noticing is that the temperature drops surprisingly fast at times (2C/h), and surprisingly slowly at others (12C/15h). Still need to investigate that!
 
Had similar thoughts on best way to use excess solar to heat geyser without using battery power.

Installed 63a Red Pole Breaker in line with regular 20a breaker on geyser supply (on and off)
Installed updated PCD board into my Geyserwise (temp)
Installed Loadhsedding detector from Sonoff (grid or battery)

Setup automation to turn on geyser during the day and turn off if when load shedding is detected.

This means battery and geyser get “charged” up during the day at night the geyser is off and if load shedding hits during the day the geyser turns off.
 
FWIW, total cost was R330 for the THR320 (Communica), R259 for the Geyserwise Thermostat, the ATTiny85 should be around R50, and a few bucks for wiring, connectors, etc. Around R650 all in, if you exclude the time I spent on it! :-D
 
Had similar thoughts on best way to use excess solar to heat geyser without using battery power.

Installed 63a Red Pole Breaker in line with regular 20a breaker on geyser supply (on and off)
Installed updated PCD board into my Geyserwise (temp)
Installed Loadhsedding detector from Sonoff (grid or battery)

Setup automation to turn on geyser during the day and turn off if when load shedding is detected.

This means battery and geyser get “charged” up during the day at night the geyser is off and if load shedding hits during the day the geyser turns off.
So this can use a bit of battery power, but primarily because it has a 3kW element and I don’t have sufficient solar to sustain that as well as the various other loads of the house. So I have it set up to activate Boost mode between 10 and 4, but only if the battery is charged above 60%. The inverter is an 8kW, so it’s fine with the load, but it will likely drop by about 10% in the process of heating up to 65C, even with the solar energy.

I’m sure I’ll tweak this a bit more as I learn what works. Probably check that the battery is charging at more than 2kW, for example, before turning the geyser on.
 
FWIW, total cost was R330 for the THR320 (Communica), R259 for the Geyserwise Thermostat, the ATTiny85 should be around R50, and a few bucks for wiring, connectors, etc. Around R650 all in, if you exclude the time I spent on it! :-D
Where did you buy this "R259 for the Geyserwise Thermostat"

Do you have a picture of where you fitted the thermistor?
I assume that is why you bought they Geyserwise thermostat, but it isn't clear to me where the thermistor goes into that thermostat.
 
Where did you buy this "R259 for the Geyserwise Thermostat"

Do you have a picture of where you fitted the thermistor?
I assume that is why you bought they Geyserwise thermostat, but it isn't clear to me where the thermistor goes into that thermostat.
I bought it from Livestainable. The thermistor is already installed in the thermostat tube, along with a 90C physical cutout to prevent runaway heating.
I had been trying to come up with my own, but decided it was too important to take a chance on. At that price, it was easier just to buy it, tbh!
 
Did you fit a Geyserwise PTC element?
This uses 33% less power to heat water
I fitted a Geyserwise ECO controller and 2 x 575 watt PV panels
 
I did not. Just a regular Kwikot 2kW element. Really not sure how a resistive element can be more or less efficient than a different resistive element. It will just create heat, one way or the other.

The only way to be more efficient is to use a different mechanism, like a heat pump.
 
Updated to add another approach that I cannot believe I never thought of:
4. Remove the thermistor from the Geyserwise thermostat, and replace it with a DS18B20 sensor.
This would probably have been the absolute simplest solution, eliminating the ATTiny85 entirely. Possible complications might be having to find thin enough wire to run a 3rd signal wire, but it could possibly have been avoided because 1-wire should be possible without the Vcc wire! That said, it might have required linking the Vcc line to the signal line in order to provide enough current. Some testing would probably be required to make sure it would work ok, and the DS18B20 is slightly larger than the thermistor, so that might also be a problem.

Would love to hear from anyone that followed this path, and actually built one.
 
I did not. Just a regular Kwikot 2kW element. Really not sure how a resistive element can be more or less efficient than a different resistive element. It will just create heat, one way or the other.

The only way to be more efficient is to use a different mechanism, like a heat pump.
The PTC element mentioned takes the 12V panel current and converts it to heat directly. It is a 12V( or 24V) element. So if you use a normal 2KW element the 12V from the panels is converted to 220V and then converted to heat again and the loss in that whole process is about 33%.
In the Geyserwise PV system, you have this titanium 12V element and a 2KW normal element in the geyser and it's controlled to stop heating at 76 Degrees.
 
The PTC element mentioned takes the 12V panel current and converts it to heat directly. It is a 12V( or 24V) element. So if you use a normal 2KW element the 12V from the panels is converted to 220V and then converted to heat again and the loss in that whole process is about 33%.
In the Geyserwise PV system, you have this titanium 12V element and a 2KW normal element in the geyser and it's controlled to stop heating at 76 Degrees.
It's all very well to take 12V directly from the panels, although that requires wiring from the panels directly to the geyser, which adds complication. Also, often the panels are wired in series, so the DC voltage is much higher, resulting in thinner cables, and less loss.

Does that then mean that the panels are dedicated to the geyser, and cannot be used by the inverter at all? That seems inefficient/wasteful, as once the geyser reaches full temperature, any energy generated by those panels is simply discarded.

Also, I doubt that the efficiency of DC to AC conversion in the inverters is as poor as 67% (33% losses). That would be horrendous! Sunsynk apparently claims as high as 97%!

Regardless, I'm not claiming that this is the last word in efficiency, just a way to make use of existing capacity of panels already wired to my inverter, which would otherwise go to waste (or be pushed back to the grid without compensation). If you want to maximise efficiency, get a heat pump.
 
Top
Sign up to the MyBroadband newsletter
X