Introduction: Smart Radiator Valve With Home Assistant

Picture of 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

Picture of Components

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

ebay

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)

Amazon

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

gearbest

1 x Anet A8 3D Printer (£119)

home

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

Picture of 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

Picture of 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

Picture of Housing the Stepper Motor

Attached is the stl file to print the sRV housing. 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.

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

Picture of 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

Picture of 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:-

https://learn.sparkfun.com/tutorials/esp8266-thing...

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 'Cover' 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

Picture of 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 'Cover' 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.

cover:
- 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

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!!

Picture of 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 plan to 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.

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!!

Comments

radeonorama (author)2017-11-18

Amazing! This is Exactly(!!) what i'm after. I already have my Worcester Boiler rf signals sniffed and now controlled by HASS but really want to control each TRV. Is there any chance you might be able to post direct links to the products needed to produce the full thing?

AJStubbsy (author)radeonorama2017-11-19

Hi radeonorama,

Sorry but I purposely didn't put direct links because the prices of the components were changing regularly and I used a couple of different sources. I think it's better to shop around, so you don't end up paying more than the indicative costs I added to the components description. The component descriptions and the shop I used to buy them should get you close enough though.

One addition I would suggest is to put a spring on the actuator pin. You can use the retaining pin that holds the plastic collar in place and just trim the pin back slightly, so it doesn't foul on anything when it's moving in and out. This will help counteract the spring that's in the radiator valve. I'll add some pictures once I get that addition standardised because at the moment I've been recycling springs out of random items, so I haven't really settled on the optimised solution. They're still working great though, I just think it'll help with the life of the stepper motors.

Best of luck, I'm really looking forward to hearing from someone who's been able to make these and if there's other improvements to be made.

radeonorama (author)AJStubbsy2017-11-19

Nice! Thanks for that, I almost have my basket of items ready for purchase. I've setup for 3 just for testing then will venture into all of them once I have the first 3 made nicely. Can I ask if there is any chance you might be able to help modify the mount point for the trv at all? Or perhaps make the file available? I'm working with a totally different trv to yours and I can't even work out how it comes apart! haha See the picture for what I have. I'm wondering if I can print (and if it will be strong enough!) the base part to connect onto the metal screw ring as it looks like I should be able to get the screw ring off easily enough. Any thoughts would be greatly appreciated! I'll definitely keep you updated on my progress. Just a bit of a wait on some of the china parts!

AJStubbsy (author)radeonorama2017-11-19

What country are you in? These are the TRV heads I used:-

https://www.screwfix.com/p/white-chrome-angled-trv...

They're not too expensive and the bonus would be that you'd have back-up TRVs.

If you'd rather use your existing TRVs then I'm happy to share the part file. I think you'd have to tackle the modifications because you'll need to make sure the linear stepper motor actuator remains the correct distance from the radiator valve pin.

It's not really obvious how that cap comes apart. If you are going to use those I think you're going to have to go for good old fashioned brute force :)

Let me know if you still want the part file and I'll have a go at attaching it to the instructable.

radeonorama (author)AJStubbsy2017-11-19

In the UK in the "Sunny English Riviera" haha.

Thanks for sharing the Screwfix ones, those may have to be the way I go. If you don't mind sharing the files I'd quite like to mess with it, if you could include the top that'd be good. I may change the shape or look at changing to a wemos d1 mini, well, assuming I have the pinouts on it actually.

Actually, on that note, I may have missed it but i couldn't see a reference to how you attach the esp8266 to the printed housing? You insert the nuts then use what? something like a 6mm M3 Cap Hex Head screw?

AJStubbsy (author)radeonorama2017-11-19

I've added the part files to step 4. You'll probably need Inventor 2018 to open the files, as I don't think they're backwards compatible and they got migrated to this when I last opened them.

6mm M3 screws will be ideal for attaching the board.

Best of luck!

radeonorama (author)AJStubbsy2017-11-19

Amazing! Thanks so much! I'll have a go at importing into fusion 360 (my general design software) i believe i should be able to use their "data panel" which will convert for me. I've not used inventor before. I'll let you know how i get on! :-)

radeonorama (author)radeonorama2017-12-02

Just a quick update for you, if you're interested. Sadly I'm still waiting on a lot of the components. Ordering from china was the only way i could seemingly get the price down to the ones you quoted. I've ordered enough for 3 trv's for now, just to prove the concept. I'm still unsure about the physical connection at the minute but the files you posted were easily imported into fusion so that's great. The "data panel" in fusion 360 just converted them perfectly. I'm debating cloning the metal connection ring and 3d printing it but fear the heat of the rad may make it warp. :-/ Once I start getting the things through and make some headway on the project, I'll let you know how i get on. :-) cheers!

AJStubbsy (author)radeonorama2017-12-03

Thanks for the update, I was wondering how you were getting on. I think you'd be fine printing the connection. I'd do what you mentioned before and take the screw ring off the old valve and fit it on to your 3D printed bit. You could thicken up the hexagon bit and maybe even drop something metallic into the print to stop potential warping?

AJStubbsy (author)AJStubbsy2017-12-03

I can't remember if you said you already have temp sensors or not but that's something worth considering as well, as they will really help tailor the operation of the valves for each room.

radeonorama (author)AJStubbsy2017-12-04

Yeah, I have Wemos D1 Mini's in nice 3d printed cases with little LCD screens running Easy ESP along with DHT22's They're already nicely hooked into HASS making decisions on the heating so i'm hoping your smart TRV's will be an almost seemless integration!

radeonorama (author)AJStubbsy2017-12-04

That metal idea is a great call! I may well do that. I'm wondering though if it might just be sensible to go buy a load of the trv's you used and save the hassle! I do like a challenge though!

AJStubbsy (author)2017-10-01

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.

iihay (author)2017-09-23

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

AJStubbsy (author)iihay2017-09-24

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

DIY Hacks and How Tos (author)2017-09-17

Great first Instructable. Very well written.

Woah, thank you very much! Most appreciated.

About This Instructable

2,244views

27favorites

License:

More by AJStubbsy:Smart Radiator Valve With Home Assistant
Add instructable to: