Smart Radiator Valve With Home Assistant

11,895

48

34

*******************************************************************************************************************************

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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

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

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

Fix It Contest

Participated in the
Fix It Contest

Automation Contest 2017

Participated in the
Automation Contest 2017

First Time Author Contest

Participated in the
First Time Author Contest

2 People Made This Project!

Recommendations

  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

34 Discussions

None
AJStubbsy

9 months ago

For anyone reading this instructable, it's sad to say but this is no longer a cheap way to build a smart radiator valve. The linear stepper motors aren't available anymore at the price I originally stated.

If you happen to find them then I'm sure there are lots of people who would be interested in buying a couple, so please post your findings here. Alternatively, if you can find a similar item then it would be great to modify this sRV.

The motor description is: -
Type: NMB Linear Stepper
PN: PL35L-024

Best of luck tinkerers

2 replies
None
BiffchipsAJStubbsy

Reply 22 days ago

No need for a motor to open the valve. Try one of these. Cheap old school tech (wax motor) and totally silent operation, apart from the click from a relay to operate it. You could always put that out of the way if it’s an issue.

https://wattswater.co.uk/catalog/hydronic-radiant-heating-solutions/actuators-and-motors-for-heating-systems/electrothermic-actuator-26ls/

Many options available from many manufacturers. 2 wire for simplicity. 4 wire models can signal open and closed position.
None
AJStubbsyBiffchips

Reply 19 days ago

I like it!! Could be used with a Sonoff for integration into Home Assistant and scheduling.

None
federicoz13

Question 6 weeks ago on Step 1

Hi! Seems that the stepper motor is no longer available. I found just one on ebay but he's not shipping to Italy. Even on aliexpress I didn't find one, can you suggest a different one who could fit?

3 answers
None
AJStubbsyfedericoz13

Answer 6 weeks ago

Hi federicoz13,
Unfortunately, I haven't been able to find a suitable replacement. It seems the stepper motor is now used in some cars to tilt the headlights and so the cost of the component is now much higher. I've added a request to the beginning of these instructions, so hopefully, if someone does find a replacement, they can let us know. I hope you're able to find a solution.

None
AJStubbsyfedericoz13

Reply 6 weeks ago

If only I knew this would happen when I bought the original steppers, they're almost 6 times more expensive!! I could have made a fortune!

None
marlon.otto9

Question 6 months ago

How can I set a temperature like 15°C? How It look like in HA. What is you HA automation

1 answer
None
AJStubbsymarlon.otto9

Answer 6 months ago

You need a temperature sensor setup as a Generic Thermostat component. You set a target temperature of 15°C and if it's above that the GTc state will be idle. If the temp is below that the state will be heat (there's a hot and cold tolerance you can set). You can then use the state to trigger an automation.

My setup is very convoluted. I have input boolean switches for a lot of things because I'm not directly controlling the heating, I'm simulating a button being pressed.

I can't get the formatting right here but this is one of the automations I have, as an example.

alias: Thermostat Heating On
trigger:
- platform: state
entity_id: input_boolean.heating_switch
from: 'off'
to: 'on'
- platform: state
entity_id: climate.l_temp
from: idle
to: heat
condition:
- condition: state
entity_id: input_boolean.heating_switch
state: 'on'
- condition: state
entity_id: switch.central_heating
state: 'off'
- condition: or
conditions:
- condition: state
entity_id: climate.l_temp
state: heat
action:
- service: switch.turn_on
entity_id: switch.central_heating
- service: automation.trigger
entity_id: group.srv_automations

None
kuhnikuehnast

9 months ago

I am struggling to find the motor online... On aliexpress / ebay they are all sold out. Any ideas to get one? (best would be from germany as I live there :-) )
greetings kuhni

5 replies
None
AJStubbsykuhnikuehnast

Reply 9 months ago

Hi kuhni, unfortunately they just aren't available at a reasonable price anymore. The cheapest I've found was from Germany
http://www.einausschalten.com/nmb-drives-linear-actuator-2phase-4wire-stepper-motor-5v9v-6v-motor-electric-telescopic-rod-slide-motor-stepper-motor-screw-lift-motor-p-176.html?language=en#.W7aEpGhKiwc

If it helps, the motor type and part number is:-
Type: NMB Linear Stepper
PN: PL35L-024

If you do find some it would be great if you could post back here.
Bets of luck.

None
m-lceAJStubbsy

Reply 9 months ago

Hi,
I'd like to do this one but impossible to find this motor at less than 20$ with shipping...
Do you know any other linear stepper that we could use to replace the onr that is not avaible anymore?

Thanks in advance

None
AJStubbsym-lce

Reply 9 months ago

I think they would work just as well. Obviously there'd be a big alteration to the part file but the stepper motors will behave in a very similar way, it's just a case of finding out how many steps make up a full revolution of the stepper motor. You just tweak the sketch then to reflect the type of motor you use.

None
AJStubbsym-lce

Reply 9 months ago

You're right m-ice, unfortunately this instructable is no longer a cheap way to make your own smart radiator valve. I've looked all over the internet and these linear stepper motors are no longer available at the price I originally stated. I've posted a link to the cheapest motors I've found in the reply before this one, but they're still expensive. Such a shame.

None
AJStubbsyJakwiebus

Reply 9 months ago

Thanks very much. It's just a shame that these parts are difficult to find anymore - at least, not at the price I originally posted.

None
AJStubbsyTeitelbot

Reply 1 year 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.

None
TeitelbotAJStubbsy

Reply 1 year 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?
https://www.thingiverse.com/thing:2783959
This maybe be better as well as I can easier revert back to basic if the smartness stops working.