# Node-Red controlling 8 outlets for AC Power

**URL:** <https://discourse.nodered.org/t/node-red-controlling-8-outlets-for-ac-power/11987>\
**Category:** Share Your Projects\
**Created:** [8 June 2019 20:55 UTC](https://discourse.nodered.org/t/node-red-controlling-8-outlets-for-ac-power/11987 "2019-06-08T20:55:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kocherjj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kocherjj/32/20578_2.png) [@kocherjj](https://discourse.nodered.org/u/kocherjj)\
**Post date:** [8 June 2019 20:55 UTC](https://discourse.nodered.org/t/node-red-controlling-8-outlets-for-ac-power/11987/1 "2019-06-08T20:55:32Z")

</div>

I'm having too much fun with Node-Red!

I had an old rack mounted power strip and I got to thinking that Node-Red and a Pi Zero W would be the perfect solution to giving myself an inexpensive IP controlled Power Strip.

I got a 5V power supply and an 8 relay strip and while I was at it I cut a connector into the side that I can tap for up to 4 more 5V devices, such as other Pi's.

I wrote this flow and now I can browse to the UI on my phone and control 8 AC powered devices individually.

 ![PowerPiBasic](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/07a8a50b73ad2d010cdef467c169c40eecba8b62.png)

 ![PowerStripsmall](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9c71ca300d392e633fa246a71fc5a6504f5dc7c1.jpeg)

`[{"id":"12e7f6d3.29b8c1","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 2 Trig","tooltip":"","group":"e39e26ea.b46c2","order":4,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":160,"wires":[["c8b5d068.e7617"]]},{"id":"55de046d.70f5fc","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 1 Trig","tooltip":"","group":"e39e26ea.b46c2","order":2,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":80,"wires":[["eab001a8.c08d2"]]},{"id":"eab001a8.c08d2","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"16","set":true,"level":"1","freq":"","out":"out","x":940,"y":80,"wires":[]},{"id":"c8b5d068.e7617","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"15","set":true,"level":"1","freq":"","out":"out","x":940,"y":160,"wires":[]},{"id":"e6955cb1.862dc","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 3 Trig","tooltip":"","group":"e39e26ea.b46c2","order":6,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":240,"wires":[["e77c3c16.a7204"]]},{"id":"35908013.b85ef","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 4 Trig","tooltip":"","group":"e39e26ea.b46c2","order":8,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":320,"wires":[["bbddcfde.0089b"]]},{"id":"e77c3c16.a7204","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"13","set":true,"level":"1","freq":"","out":"out","x":940,"y":240,"wires":[]},{"id":"bbddcfde.0089b","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"12","set":true,"level":"1","freq":"","out":"out","x":940,"y":320,"wires":[]},{"id":"455208e1.694f78","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 1","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":80,"wires":[["5244108e.105cb8"]]},{"id":"5244108e.105cb8","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":1,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":80,"wires":[]},{"id":"7d9c6e7e.0467e","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":3,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":160,"wires":[]},{"id":"e37a4949.fb226","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 2","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":160,"wires":[["7d9c6e7e.0467e"]]},{"id":"23faf9bb.d9c526","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 3","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":240,"wires":[["e429bb13.b585a"]]},{"id":"e429bb13.b585a","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":5,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":240,"wires":[]},{"id":"ddd3c576.b50f8","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 4","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":320,"wires":[["71f14eed.c68d98"]]},{"id":"71f14eed.c68d98","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":7,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":320,"wires":[]},{"id":"b93c5e95.14a28","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 6 Trig","tooltip":"","group":"e39e26ea.b46c2","order":12,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":480,"wires":[["e14662da.600f"]]},{"id":"e1eded42.1c1e78","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 5 Trig","tooltip":"","group":"e39e26ea.b46c2","order":10,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":400,"wires":[["9ebebef4.657988"]]},{"id":"9ebebef4.657988","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"11","set":true,"level":"1","freq":"","out":"out","x":940,"y":400,"wires":[]},{"id":"e14662da.600f","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"10","set":true,"level":"1","freq":"","out":"out","x":940,"y":480,"wires":[]},{"id":"ac735353.eae95","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 7 Trig","tooltip":"","group":"e39e26ea.b46c2","order":14,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":560,"wires":[["79dcec4d.0ca914"]]},{"id":"6d7697fc.a089b","type":"ui_switch","z":"afba7257.93f7d8","name":"","label":"Outlet 8 Trig","tooltip":"","group":"e39e26ea.b46c2","order":16,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":770,"y":640,"wires":[["6e8bcc3.5a6be34"]]},{"id":"79dcec4d.0ca914","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"8","set":true,"level":"1","freq":"","out":"out","x":940,"y":560,"wires":[]},{"id":"6e8bcc3.5a6be34","type":"rpi-gpio out","z":"afba7257.93f7d8","name":"","pin":"7","set":true,"level":"1","freq":"","out":"out","x":940,"y":640,"wires":[]},{"id":"c2307c8e.7e62a8","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 5","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":400,"wires":[["38d83845.39e63"]]},{"id":"38d83845.39e63","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":9,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":400,"wires":[]},{"id":"c022e9d9.04a48","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":11,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":480,"wires":[]},{"id":"e4d5208b.c18e9","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 6","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":480,"wires":[["c022e9d9.04a48"]]},{"id":"2fa8cc17.3b825c","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 7","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":560,"wires":[["92318a8.0aaf778"]]},{"id":"92318a8.0aaf778","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":13,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":560,"wires":[]},{"id":"ed1cf884.b01a2","type":"ui_text_input","z":"afba7257.93f7d8","name":"","label":"Outlet 8","tooltip":"","group":"544b825d.aa89b4","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":640,"wires":[["b8b62a88.a6a95"]]},{"id":"b8b62a88.a6a95","type":"ui_text","z":"afba7257.93f7d8","group":"e39e26ea.b46c2","order":15,"width":"4","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":640,"wires":[]},{"id":"e8570b5e.262f1","type":"change","z":"afba7257.93f7d8","name":"Outlet 1 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":40,"wires":[["5244108e.105cb8"]]},{"id":"59efec82.8aff2c","type":"change","z":"afba7257.93f7d8","name":"Outlet 2 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":120,"wires":[["7d9c6e7e.0467e"]]},{"id":"81f68b02.dea61","type":"change","z":"afba7257.93f7d8","name":"Outlet 3 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":200,"wires":[["e429bb13.b585a"]]},{"id":"83b0d9cb.bed5f8","type":"change","z":"afba7257.93f7d8","name":"Outlet 4 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":280,"wires":[["71f14eed.c68d98"]]},{"id":"c7a234e6.5df6a8","type":"change","z":"afba7257.93f7d8","name":"Outlet 5 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":360,"wires":[["38d83845.39e63"]]},{"id":"cd89e010.ec15a","type":"change","z":"afba7257.93f7d8","name":"Outlet 6 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 6","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":440,"wires":[["c022e9d9.04a48"]]},{"id":"7d870af6.97e664","type":"change","z":"afba7257.93f7d8","name":"Outlet 7 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 7","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":520,"wires":[["92318a8.0aaf778"]]},{"id":"8c954048.587f58","type":"change","z":"afba7257.93f7d8","name":"Outlet 8 Default Label","rules":[{"t":"set","p":"payload","pt":"msg","to":"Outlet 8","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":600,"wires":[["b8b62a88.a6a95"]]},{"id":"3fa77f10.739fe8","type":"inject","z":"afba7257.93f7d8","name":"Initialize State","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"1","x":120,"y":40,"wires":[["8c954048.587f58","7d870af6.97e664","cd89e010.ec15a","c7a234e6.5df6a8","83b0d9cb.bed5f8","81f68b02.dea61","59efec82.8aff2c","e8570b5e.262f1"]]},{"id":"e39e26ea.b46c2","type":"ui_group","z":"","name":"Power Ctrl","tab":"78d3dce8.eb878c","disp":true,"width":"6","collapse":false},{"id":"544b825d.aa89b4","type":"ui_group","z":"","name":"Outlet Labels","tab":"3f10fd07.050ec2","disp":true,"width":"6","collapse":false},{"id":"78d3dce8.eb878c","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"3f10fd07.050ec2","type":"ui_tab","z":"","name":"Tech Page","icon":"dashboard","disabled":false,"hidden":false}]`

---

<div class="post-metadata">

**Author:** ![Robbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robbo/32/4491_2.png) [@Robbo](https://discourse.nodered.org/u/Robbo)\
**Post date:** [10 June 2019 12:08 UTC](https://discourse.nodered.org/t/node-red-controlling-8-outlets-for-ac-power/11987/2 "2019-06-10T12:08:03Z")

</div>

Your project reminds me of some Superhouse builds which you may be interested in to give you ideas.. He uses Arduino MQTT for end clients but Node-Red as the main brains...

---

<div class="post-metadata">

**Author:** ![kocherjj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kocherjj/32/20578_2.png) [@kocherjj](https://discourse.nodered.org/u/kocherjj)\
**Post date:** [20 June 2019 01:43 UTC](https://discourse.nodered.org/t/node-red-controlling-8-outlets-for-ac-power/11987/3 "2019-06-20T01:43:21Z")

</div>

Hey Robbo,

I finally had the chance to sit down and watch this video through. Neat stuff!

I am curious though what the benefits of the Arduino are though, vs the Pi. I can pick up a Pi Zero W at MicroCenter for $5 and I can't come up with any reason to go with an Arduino instead considering they seem to cost more for less functionality. I even grabbed a 4 pack of MCP3008s on Amazon and I started playing around with them so I can work with analog inputs too, which seemed like the one gaping hole in the Pi's capabilities. That's 4 Pi's with 8 ADC channels plus all the Pi GPIOs for under $35. Clearly the Arduinos are very popular though. What am I missing?

Thanks again for sharing! I have a list a mile long of things around my house I want to control. My next project is a scale with a load cell for my gravity fed water filter so I know when to add water without having to shake it, and I'm thinking about running a 1/4" water line and an electric ball valve so it will add the water on it's own too!

---

<div class="post-metadata">

**Author:** ![Robbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robbo/32/4491_2.png) [@Robbo](https://discourse.nodered.org/u/Robbo)\
**Post date:** [20 June 2019 05:56 UTC](https://discourse.nodered.org/t/node-red-controlling-8-outlets-for-ac-power/11987/4 "2019-06-20T05:56:51Z")

</div>

The Arduino is a micro controller so just runs the one program of your choosing and has better control of the hardware, where the Pi is a fully blown OS and does other things making it less reliable and not as fine control.

The Arduino Mega has 50+ GPIO pins and hardware PWM as well. A ESP board like the ESP8266 or it’s successor is also a micro controller with built in WiFi and Bluetooth and seems to be the go to controller these days. (It’s what the sonoffs use, so these devices can be re-flashed using Tasmota for local MQTT control). ESPhome is another easy way to flash these devices.

> **[The Difference Between A Microcontroller And A Raspberry Pi - Kompulsa](https://www.kompulsa.com/2017/07/27/difference-microcontroller-raspberry-pi/)**
>
> Single-board microcomputers such as the Raspberry Pi and Beaglebone Black have made waves in recent years, and microcontrollers have firmly retained their place in electronic designs. Why? After all, the Raspberry Pi has significantly more processing...
