Making a smart heatpump - Part 1

This is the first part of the progress for the heat-pump device. It will describe the concept a bit more in detail, and publish the rev1 board files in a later article

My standard disclaimer for all project described here applies. Please read it before you continue.

Concept

Lets circle back to the main concept at first. This time with a bit more details of how the existing system works, how the hardware is supposed to work and how the software is supposed to work.

How my system work today

My heat pump uses a pretty common concept for control, at least where I live. The house uses water based heating. Radiators are placed in every room in the house, and these radiators dissipate heat passively into the space. Control of this entire system is handled by essentially two independent control system, each working by them-self without any communication between them.

Large scale control

The heat pump is using a pretty simple control method. The pump measures the temperature outside the house using a sensor. This signal is then pretty heavily filtered to provide a stable control input. A house has pretty significant thermal mass, so it should not react to a short term temperature changes. The control input is then used to find a set temperature in a lookup table. This table is usually implemented and visualised as a "house curve". The curve is set by a technician at commissioning of the system, and is based on house properties such as level of insulation, radiator area, passive heat flux and manual trimming. Once set and trimmed, it is supposed to basically never be touched unless something is significantly changed. For further reading, see here for example.

The heat pump is constantly working to keep this outlet temperature. This water is then circulated through the radiator system by a pump. This pump is maintaining a set pressure at the pump output. There are also systems that use a internal temperature sensor as well, but exactly how this one is utilized is a bit unclear to me. Mine is often widely off, so I suspect it is used to fine adjust the set-point and not completely control it.

Small scale control

The smaller scale control is done by the radiators them-self. The radiators have a thermostat, usually a wax thermostat that can be adjusted by twisting a knob. It is also now possible to buy smarter versions of these, where the temperature in the room can be set and controlled electronically. The thermostat adjusts the amount of water being pushed through the radiator, which in turn adjust how hot it become and how much energy is released to the room. This thermostat is supposed to be used to adjust a specific rooms temperature, and might be expected to be utilized more. The pump does not really care what the radiators are doing, it is just keeping the hot water source at a specific temperature.

Taking control

Now that it is known how the system work, we can break or adjust it. My plan is to only adjust it. This is where the control board comes in. The board will have 2 channels, consisting of 2 digital potentiometers each. 1 potentiometer for larger adjustments and one for small adjustments. These two channels will be connected to the system through 2 relays each. One on the high side and one of the low side. The device has two operating modes

  • Pass-through
  • Spoofing

Passthrough mode

Pass-through mode is the default operating mode. Pass-through refers to the fact that the signals from external sensors are not modified in any way. They are simply connected through the board to the pump as if the device was a cable. This is used when no inputs are needed or when a fault has been detected. The possible faults I foresee are

  • Lost connection to home assistant
  • Home assistant lost pricing data
  • Home assistant lost actual temperatures
  • Home assistant data is invalid
  • Potentiometer fault
  • Loss of power to the device
  • Software lockup

Of these, software lockup is probably the most problematic to solve.

Spoofing

Spoofing mode is the mode for when the device will actually control the heat-pump. The relays are set to the active position where the temperature sensors are disconnected and replaced by the digital potentiometers. The potentiometer will be set to fool the pump that the outside temperature is higher or lower than the actual to indirectly control the compressor. Setting the temperature to -10C for example when it is actually only -2 outside will cause the set-point to become higher than expected. This will cause the pump to increase its set-point and charge the accumulator tank, increase the radiator temperatures and heat up the house slightly. For even more effect, room thermostats could temporarily have the set-point increased to charge the air and building materials with heat. 

And the other way around, if the temperature is set to higher, it will start dropping the temperature in the tank and radiators. The drop will take a while and should allow the compressor to either not run at all or run less until the price spike has passed.

Blocking

There is a third option as well. We will see if I exercise it. There is a digital input on the pump which can control a few things. It can be used to do a "night temperature drop" or block compressor or heater packs. This input will only need a relay to connect or disconnect a digital 5V signal. It is a quite crude way to control the pump, and I need to choose what the input does beforehand on the normal operating screen.

Hardware

The hardware used for this project is a semi-simple board. Complexity has been tried to be kept to a minimum by purchasing more advanced modules. I expect the device to save me some money, so speed is more important than a slim BoM.

Processor

I chose to base this board on a NodeMCU v3. It is a ESP8266 based board, with most of the available IO broken out. The ESP8266 is a solid choice here due to the simply excellent ESPhome project with a lot of functionality out of the box and super simple Home Assistant integration. It is not the slimmest design, but it is cheaply available locally and I happened to have two at home already. The chip itself is hilariously overkill for what I ask it to do, but well. It is cheap and simple to use.

Spoof block

The block for spoofing is based on two components. The first are two MCP4151 from microchip, one 50k and 5k variant. The second component are the G6S-2G DC5 from Omron. They are quite expensive, but Omron has superior quality compared to the knockoffs you find on aliexpress. I do not want to have my house messed with because I saved €2 on a relay.

Power supply

The power supply caused me a great deal of headache. In principle it is simple, I need about 400mA of 3.3V and nothing else. The main supply to the board is by an external power brick and it is transformed to 3.3V on the board. I did consider tapping power of the heat-pumps board but I decided that mucking about with expensive electronics I rely is was a bad idea. There was quite a bit of ~9V available on the control card, which was supplied by a transformer and a small rectifier, but I decided against it. 

The issue is around failure modes. I need to consider the fact that the pump and wall plug above it are of different circuits, and only one of them have protective earth. My concern was that if the breaker tripped on one of these, it could potentially be a large potential difference between the wall plugs GND net and the pumps GND net. This would rely on the wall wart to provide isolation and I am not 100% sure I can rely on of these I can find. I was not able to fully convince myself this scenario was impossible (especially considering wall plugs here are not polarized), so ultimately I decided to purchase a PCB mounted DCDC converter rated to 1000V isolation. Specifically this one. It is probably overkill but well, the pumps control board is expensive if I can even find one. The only concern left then is back feed of the pumps control board from the spoof board which is easily preventable by simply not providing anything but ground or current limited nets.

Software

The embedded software is rather simple as most of the heavy lifting is done by ESPhome and Homeassistant. A simple interface need to be created between Homeassitant and the device. The interface will provide a way for the two systems to exchange data. From the device to HA

  • General status (Pass-through, spoofing, error)
  • Heartbeat
  • Measured temperature channel 1
  • Measured temperature channel 2
  • LED status
  • Relay command states

From homeassistant to the device

  • Heartbeat
  • Commanded state
  • Commanded spoof temperature channel 1
  • Commanded spoof temperature channel 2
  • Commanded LED state

The sensors are are created using the excellent ESPhome integration. To actually control the potentiometers I opted to do an Arduino library and integrate it into ESPhome. The reasons to do this are simple

  • Debugging embedded C++ in ESPhome is terrible
  • A library can be reused by other projects

This article was updated on May 3, 2024