# Ultrasonically controlled Christmas tree

**URL:** <https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342>\
**Category:** Share Your Projects\
**Created:** [24 November 2019 07:08 UTC](https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342 "2019-11-24T07:08:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [24 November 2019 07:08 UTC](https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342/1 "2019-11-24T07:08:34Z")

</div>

A couple of my IoT students are planning on designing and building a flow to control a strip of RGB lights on a Christmas tree (using a distance-value from an ultrasonic distance measuring device HC-SR05).

Here's a very rough sketch of the ideas discussed during their first session.

[Project plan and progress diary](http://resources-area.co.uk/node-red-flows/xmas_tree_project_diary.pdf)

 ![ed_arwen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/79086c48cde6ff9b22b857b058a233cd7921da6d.jpeg)

They discussed the idea of changing the colour of the RGB strip as you walk nearer to the tree or changing the brightness of a single colour. Maybe if they have enough time I'll encouage them to do both!!

This might be the first Christmas tree that has two IP addresses (ho.ho.ho. merry & ho.ho.ho. christmas ).

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [24 November 2019 11:54 UTC](https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342/2 "2019-11-24T11:54:20Z")

</div>

> This might be the first Christmas tree that has two IP addresses (ho, ho, ho).

shouldn't that be ho.ho.ho.merry and ho.ho.ho.christmas 🎄

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [12 December 2019 18:01 UTC](https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342/3 "2019-12-12T18:01:55Z")

</div>

Here's an update on this project.  
The students, working on this project, have just made a video of their working Christmas tree.

[Video of the ultrasonically controlled Christmas tree in ACTION](http://resources-area.co.uk/node-red-flows/christmas_projects/ultrasonic_xmas_tree.mp4)

Merry Christmas to everyone who stops-by and reads this post.

---

<div class="post-metadata">

**Author:** ![JonS](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@JonS](https://discourse.nodered.org/u/JonS)\
**Post date:** [29 December 2019 23:47 UTC](https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342/4 "2019-12-29T23:47:52Z")

</div>

Very nice. I like the video. Well done.

Being new to Node-RED, I'm having a bit of trouble figuring out how you would do this using NR... I know how it could be done using the ultrasonic sensor, the neopixel LEDs plus an Arduino or ESP8266, but no idea how it would be done using Node-RED.

Could you please post the flow or a picture of the flow?

Inquiring minds want to know... 🙂

Thanks.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [30 December 2019 08:26 UTC](https://discourse.nodered.org/t/ultrasonically-controlled-christmas-tree/18342/5 "2019-12-30T08:26:07Z")

</div>

Hi Jon,  
I'm away from home at the moment, so can't post the flow.  
I'll do that when I get home in the New Year.

Basically the students hooked-up a HC-SR05 ultrasonic distance sensor to a Wemos D1 Mini, flashed with ESP Easy. Distance readings were sent via MQTT to Node-RED. To reduce the amount of traffic a reading was only published if it was different to the previous one.

Node-RED took the reading and compared it with various distance-values. The results were sent to the MagicHome node to control the colour of the strip of RGB LEDs.

The students were planning on rigging up a second set of lights that used a single colour but changed the intensity as you got nearer to the tree, but ran out of time.

Hope that helps.
