Smart Radiator Valve With Home Assistant




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 need to 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 does seem to be working well for me.

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 Switch' component to Home Assistant and name it to match what you've got in your sketch. Here's what I have in my configuration file.

- platform: mqtt

name: sRV_L

state_topic: "sRV_L/state"

command_topic: "sRV_L/move"

payload_on: "ON"

payload_off: "OFF"

state_on: "OPEN"

state_off: "CLOSED"

optimistic: true

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.

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 switches. I've grouped the switches and then created an automation that turns the heating on, if any of the switches are on, and turns the heating off, if all the switches are off. 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 target temperature of '5' 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!!

2 People Made This Project!


  • Big and Small Contest

    Big and Small Contest
  • Toys Contest

    Toys Contest
  • First Time Author

    First Time Author

17 Discussions


Reply 7 weeks ago

Hi DovidT, If there's a spring/pin mechanism on your TRV then I can't see why this wouldn't work for your application, you'd need to redesign the 3D printed part, so it fits to your radiator valve.

The main problem at the moment is we can't get our hands on the linear stepper motors, for a sensible price, any more. If you find some, or an alternative, I'm sure the other members on here would be interested in a link.


Reply 7 weeks ago

Why cant you 3d print the "wormgear" part and use a cheap basic stepper motor?
For myself maybe I should design something offhand like this instead?
This maybe be better as well as I can easier revert back to basic if the smartness stops working.


Reply 7 weeks ago

That will be a project I look forward to reading! Best of luck DovidT, happy tinkering.


Question 10 months ago on Step 4

Hi. Great Project. I've been looking to do something like this for a while. I'd like to modify the housing slightly but i only have Catia v5. I believe from some forum posts i've seen that inventor might be able to save as .catpart files. Do you think you could post the parts as .catparts? failing i can import step (.stp).

3 more answers

Answer 7 months ago

Hi CraigM169, sorry for not responding, I'm not sure how I missed your request. I'm guessing you don't need these now?


Answer 7 months ago

Thats ok. I decided to re invent it a little to use batteries and have a dial and display to change the temp on the unit as well as via home assistant. I have all the parts, as usual i just need to find the time to put it all together. Thanks for the inspiration though!


Answer 7 months ago

Wow that sounds superb! Did you manage to buy the linear actuators at a reasonable price? @SturmGhost commented that he couldn't find them so cheap. I've had a look and they are about 3 times the price they were when I first posted the instructable, I thought you might have an alternative supply route. It was answering him that made me see your comment. P.S. I reverted my HASS config to use MQTT covers to control the valves, instead of the MQTT switches and then use an Input Boolean as the target for the Generic Thermostat, which in turn triggers an automation for when the cover should be controlled. This was because I had a problem where the MQTT switch didn't reflect the state of the valve because the valve would publish its state but the Generic Thermostat would override the state, depending on whether it was in 'Idle' or 'Heat'. I'm confusing myself reading this back, so if you do get to that point I can share my HASSIO config. Good luck with your build!


7 months ago

Nice project. Next step should be an integrated battery (and use of power saving tricks) and an integrated temperature sensor (I know, placement isn't ideal but it's easier to start If no room temperature sensor is already in place).

Btw: I can't find the linear actuator for that price. Can you provide a source?

1 reply

Reply 7 months ago

Hi SturmGhost, I've checked and you're right. I can't find these linear steppers anywhere near that price anymore. I've listed the two ebay shops I used below. They don't show them in stock anymore but I suppose you could ask them?




10 months ago

If you've looked/made a start on this Instructable in the past, I've changed the code again. This is to ensure the valve doesn't try to open/close if it is already in the desired state. I've also changed the Hass Component from a cover to MQTT Switch. This allows you to control the valves using a Generic Thermostat Component.

If you haven't already installed it, I'd definitely recommend using the Google Assistant component as well. It's very satisfying to check room temperatures and control the valves and other components, using your voice.


1 year ago

There was a problem with multiple devices having the same Client ID and so I've updated the Arduino IDE code, so that this can be personalised for each device.


1 year ago

Brilliant work and just what I need. Especially love it leaving the valve open when the heating is off, very well thought out.

1 reply

Reply 1 year ago

Thanks very much. I'd love to here how you get on making one of these as well. Best of luck.