Introduction: Smart Radiator Valve With Home Assistant


Edit: 03-Sep-2019

Unfortunately, since writing this instructable, it seems the stepper motor is no longer available (at least not at the price that made this project worth attempting). If anyone finds a suitable replacement and can modify these instructions to suit your needs, then it would be great if you could let me know, so I can post a link to a new, affordable, DIY Smart Radiator Valve project.


Of all the people in my house, I am by far the hottest! This means the heating is often on when I personally don't think it needs to be. To compound this issue, my daughter's bedroom is above our garage and so she has 3 exposed walls to her particular cube. Although the house is well insulated, during winter that room is usually much colder than the rest of the house. If I want to warm her room before bed, I end up going around the various rooms and adjusting the TRVs so that her room can heat up without getting the other rooms too hot. Especially because downstairs is usually warm as we will have been cooking and if that gets warm it will knock the thermostat off. I sound so grumpy reading this back haha! Anyway, something had to be done!

This smart radiator valve (sRV) can replace the Thermostatic part of a TRV and then be integrated with a Home Automation application. I'd already been introducing temperature sensors to my house and integrating them with Home Assistant, which is a great, open-source application that can be hosted from a Raspberry Pi. This was just an extension of that and, if anyone is interested, there's already some great tutorials to follow from a guy called Ben at BRUH Automation.

The sRV is communicating over the MQTT protocol, which can integrate with a wide variety of home automation applications and the 'brains' of the device is an ESP8266 board. In total, this sRV comes in at a little under £10, which is incredibly cheap given similar devices are more like £50 - £60. The only downside of this device is that it is permanently powered on. It's very small power consumption and I'm sure, with a bit of tinkering, this could be adjusted to be battery powered but for now, lets get into the method used to make one of these.

Step 1: Components

For the sRV I used the following components. (I've included some rough costs)


1 x Stepper Motor Drive Controller Board Module L298N Dual H Bridge DC (£1.44)

1 x NodeMcu Lua CH340G ESP8266 WIFI Internet Development Board Module (£2.54)

1 x NMB Linear Actuator 2-phase 4-wire Stepper 5V-9V Put Pull Pusher Motor DIY (£3.60)

5 x 10 Female to female jumper wire connectors (£2)

Pack of 1k and 10k resistors (99p)

5 x prototyping boards (99p)

100 x NPN Transistor 2N3904 (99p)

Connector crimping tool and pins (£2.75)

20 x 3M nuts (99p)


20 x M3 Cap Hex Head screws 50mm long (£1.80)


1 x Anet A8 3D Printer (£119)


1 x TRV adapter (the bit that screws onto the radiator valve)

Arduino IDE to upload the code/sketch/program

Home Assistant running on a Raspberry Pi for automation.

The Beginner's Guide to Home Assistant - HassIO

Step 2: Connecting the Stepper Motor Cables and Power to the Stepper Driver Board

I desoldered the blue double connectors from the stepper motor drive board, just to save some room and make it easier to attach the linear stepper connections. The picture shows how to connect the Yellow, Green, Blue and White connections from the linear stepper motor. It would be worth reading through the whole project and see how components will be assembled because I shortened these cables so they fit into the 3D printed parts a bit easier. You need to be careful to leave enough length so the cable can be plugged into the motor before final assembly.

Power for the motor driver board is coming from the VU pin, on the esp, and going to the left port on the blue triple connector. The middle port on the blue triple connector is where you connect ground from the esp and stepper motor (black cable).

I bought quite a few of these stepper motor driver boards and the voltage regulator is different on some of them. I'm pretty clueless when it comes to electronics. Everything I've done has come from copying other projects and piecing ideas together, so I was lucky that a friend was able to diagnose a problem. One batch of stepper motor driver boards would not power up and it turns out the voltage regulator wasn't getting enough power to kick in, so he managed to 'jump-start' it by shorting out two of the pins. The voltage regulator is there because you can connect up to 35V to these driver boards and the regulator will adjust that to suit the motors used and it can give you a 5V output as well. Since we're using a regulated 5V input from the USB power supply, we don't need to worry about this and so I soldered a piece of wire between the 2 legs of the regulator, which you can hopefully see right at the centre of the second picture. Have a go at powering the board from a 5V supply and if the LED comes on straight away, you won't need to do this step.

Step 3: Stepper Control Connections

Don't be daunted by all these connections, this is the easy bit. Wait until you try to assemble everything in the 3D printed housing!!

The stepper motor driver board can be used to power/control 2 DC motors and so either side of the board can be disabled by removing a jumper pin. They're called ENA and ENB and can be found either side of the pins labelled IN1, IN2, IN3 and IN4. I found that the board and stepper motor was getting hot, even when it's not being driven and so I thought it would be a good idea to disable the stepper outputs when not being used. To do this I've used a transistor that will be controlled by one of the GPIO pins from the esp. When the pin is set to HIGH it will open the transistor and this will act as a jumper on the ENA and ENB pins. When the GPIO is set to LOW it will close the transistor and this will simulate the jumper connector being removed. All this will become clearer when we look at the sketch that is used to control this.

I don't know why these particular resistors are used but I've seen so many projects with this same setup that I thought I'd do the same. We've got a 1K ohm resistor going from a pin on the esp to the base of the transistor. In this case I've used D8 as the GPIO that is connected to the base of the transistor. There is a 10K ohm resistor connected from the base of the transistor back to a ground pin on the esp. This will make sure that any residual power drains back to ground so there won't be any residual power at the base of the transistor, which could cause it to be open when we actually want it closed. This is referred to as a 'pull-down resistor'.

I made up a little circuit with the 1K resistor on the right and 10K on the left. The transistor has the flat face facing up. There's two wires on the emitter and two wires on the collector of the transistor. I've used the crimp tool to attach pins to the wires and then fitted them to a connector, so they are easily attached to ENA and ENB of the stepper driver board. I'm not sure if it matters which way round the connections are attached, I haven't tested this but you can see in the picture I have the white wires at the front and green at the back.

The other connections are coming from D1, D2, D3 and D4 of the esp and going to IN1, IN2, IN3 and IN4 of the stepper driver board respectively.

Step 4: Housing the Stepper Motor

Attached is the stl file to print the sRV housing. There's also the part files from Inventor, in case you'd like to modify anything. You need to pause the print at 5.6mm and then remove any support from the 4 exposed holes, put a nut in each hole then continue the print. Once the print is finished you can remove all the support material and push 2 nuts into the slots that you can see in the 1st picture attached.

You will need to remove the plastic piece on the stepper motor actuator. There's a little pin you can tap out, then it just slides off. The stepper motor can then be pushed into the housing and a small twist will lock it in place.

*since originally writing this, I've found it's a good idea to fit a spring under the little pin. This helps ensure the radiator valve is firmly closed after power is isolated from the stepper motor. You might need to trim the pin a bit so it doesn't foul on the bottom of the TRV. The last picture in this stage shows a spring in place. Ideally it'd be a bit longer than this one*

Now you need to disassemble a TRV from your radiator. This is pretty tricky; in my case I had to prize back some clips using a screwdriver. Hopefully your valves have the same threaded portion as mine, or you may need to design a different attachment. I've included the Inventor part files but you may need Inventor 2018 to open them.

The bottom of the TRV can be screwed onto the 3D printed part, which will then be ready to put back onto the radiator valve, once everything else has been assembled.

Step 5: Final Assembly

Prepare for a fair bit of frustration!

If I was going to convince my wife that these valves were going to replace our existing TRVs, they had to look pretty neat. To achieve this, there's not a lot of room. As previously mentioned, you might want to reduce the length of some of the cables, or route them in a way that will maximise space for the top to screw on.

Push the connectors from the motor driver board through the hole and connect the stepper motor. Connect the cables from IN1 etc to D1 etc and bend the pins over so the connectors are out of the way.

With everything fairly loose, fit the esp with the USB port towards the bottom of the valve. You can then use the two nuts that were pushed into the slots and some small M3 screws to fasten the esp in place.

Put 4 of the M3 Cap head screws in place and then make sure the wires are out of the way of the driver board heat sink. Put the top in place by squeezing the screws inwards, while they are only just in the board (I think the pictures does a better job than my description). Push an allen key through the holes in the top and then tighten all the screws until the whole assembly is firmly secured.

Give yourself a well deserved pat on the back and crack open a bottle/can of your favourite tipple! Now it's time to program the esp.

Step 6: Loading a Sketch

You can use Arduino IDE to upload a sketch and you need the esp addon to be able to choose the correct board. Here's a link to an example tutorial of how to do this:-

I pieced together the attached sketch from some example sketches that come with Arduino IDE and from some examples I saw of people controlling stepper motors from home assistant. None of them did exactly what I wanted but this hybrid seems to be working well for me.

***edit: 28-Jan-2021 I've modified the sketch so that upgrades can be made OTA. This makes it easier to fine-tune the number of extension/retraction steps needed to successfully open/close your radiator valve pin. The extension/retraction steps are found in the 'void callback' part of the sketch. The attached sketch is still relevant though and you could continue to use that and the instructions below, or you can find the OTA version on Github here: - . If you use the OTA version, just follow the instructions in the README and skip the rest of the instructions in this section. ***

Open the ino file using Arduino IDE and then add your wifi connection details. Change the name of the sRV topic to match whatever you're going to call it in home assistant. I've gone for sRV_L for the living room. You can probably guess what I've named the one for the bedroom :)

// Change these to match the 'MQTT Switch' component in Home Assistant

char* sRV_room = "sRV_L/move";
char* sRV_room_state = "sRV_L/state";

You also need to set a unique ID, if you have more than one sRV, otherwise the broker will keep disconnecting the devices. I just add the relevant room letter to the end.

char* clientid = "ESP8266ClientL"

Change the settings, in the 'Tools' drop down of Arduino IDE, to match those in the attached picture. Connect your esp to your computer, click the 'Tools' drop down and select the COM port that is available. Hit upload and this should transfer the sketch to the esp. If everything has worked properly the stepper motor should retract and then push out a little way. If this doesn't happen, click the little magnifying glass in Arduino IDE and check that the esp is connecting to your home network. If it's not then check you've entered the details correctly in the sketch and try flashing again.

Step 7: Controlling the SRV

I posted a tutorial in the 'Components' section for Home Assistant, if you follow that you'll end up with a Raspberry Pi running home assistant. You'll also need the MQTT broker (Mosquitto) installed - I think that gets covered in the tutorial but if not he covers it in one of his other videos.

As a side note, I've got my Raspberry Pi connected to my central heating controller and I've used the same transistors that were used for ENA and ENB to short out the 'Advance' button, so I can turn my heating and hot water on/off from anywhere with an internet connection. I've also installed temperature sensors in the rooms where I've got the sRVs. There's loads of tutorials to do this, I've used an esp-01 board with ESPeasy installed and a DS18B20 sensor.

Back to the sRV! You need to add a 'MQTT Cover or Switch' component to Home Assistant and name it to match what you've got in your sketch. Here's an example of one of the MQTT Covers I have in my configuration file.

  - platform: mqtt
    name: sRV_L
    state_topic: "sRV_L/state"
    command_topic: "sRV_L/move"
    payload_open: "ON"
    payload_close: "OFF"
    state_open: "OPEN"
    state_closed: "CLOSED"
    optimistic: false
    qos: 0

Once this is setup you'll be able to action the stepper motor. Power the sRV by connecting the esp to a USB power supply. Function the actuator to check everything is working.

You can now fit the sRV to a radiator and check if it's doing its job. You may need to adjust the number of steps that the linear actuator moves. If you listen, you can hear when the metal part of the linear actuator makes contact with the metal pin in your radiator valve. When the actuator is extending you should hear just a couple of steps, at the end, where the stepper motor slips slightly. This is the point where the spring loaded pin in the radiator valve is fully pushed in and the radiator valve is then closed. If you don't hear the stepper motor slip slightly at the end of the stroke, then you may need to increase the number of steps in the sketch. If it sounds like it slips for quite a while then you could reduce the number of steps. You'll now what I'm getting at when you listen to the stepper motor move. You can hear the tone change when it's slipping. If you adjust the extension steps you may need to adjust the retraction steps as well, it depends how much the motor slips. You'll find both of these in the 'void callback' part of the sketch.

Since the sRV is using very little power it was slipping when extending, which is why I've got the stepper motor moving just a couple of steps at a time.

Step 8: Done!!

That's it. Now you can decide when you would like certain radiators to be on/off and automate this with Home Assistant.

I have all the valves open when the heating is off. This will make sure the valves will never seize, which can happen if they're always closed because the internal seal can get stuck. I have Generic Thermostat Components that check the temperature of my temp sensors in each room. They then open/close the radiator MQTT covers and I have an automation to turn the heating on/off depending if the correct temperature has been met. There's a separate Input Boolean Component that I've used as a Heating Switch. This allows me to have a condition where the heating is only turned on/off if the Heating Switch is on. The beauty of this is you can set time triggers for when this all kicks in. I also have time triggers that set the upstairs Thermostats to a lower target temperature during the day; this means I'm not unnecessarily heating the upstairs rooms during the day.

Future modifications would be to have this battery powered and use the 'Deep Sleep' function of the esp to conserve energy.

Congratulations, you may have spent a couple of quid to get to this point but you should now have a 3D printer and loads of spare components to make more sRVs!!

Automation Contest 2017

Participated in the
Automation Contest 2017

Fix It Contest

Participated in the
Fix It Contest

First Time Author Contest

Participated in the
First Time Author Contest