Home Automation Using Node-Red and Heroku

Published on 19 Nov 2020
Written by Pranav Chakkarwar
4 min to read

This is an outdated and infeasible solution for home automation. Take a look at my better approach

Home, Office, Industrial Automation, and control using Node-Red, Heroku, MQTT, Raspberry Pi, other edge IoT devices (like esp8266, Arduino, etc.)

Advantages of Using This Solution

  1. It is an open-source solution (So you are the one in control of the critical internal data, not a multi-national conglomerate).

  2. The dashboard is available over the internet but password protected. For more security, we can use a free OpenVPN server (in the cloud or on our Raspberry Pi)

  3. It’s free, so why NOT!!! (Except you need to pay for the hardware lol)

  4. Your Node JS app will never sleep.


  1. Access the Control center from anywhere in the world.

  2. Control will be transferred locally to the Raspberry Pi (ex - in case of internet failure)

  3. Easily change automation rules or rewire controls with instant deployment.

  4. Automation rules can get as complex as you like.

  5. It is effortless to integrate third-party APIs like the OpenWeatherMap.




  1. Edge IoT devices (I am using esp-01 for demonstration)

  2. Raspberry Pi for local control and override rules (Note: The Raspberry Pi control center can also be accessed remotely on demand)

  3. Relay boards or Custom PCB boards

  4. And other devices like CCTV’s (optional)

Other Requirements

  1. App platform to deploy the project (I am using Heroku)

  2. MQTT provider. I am using Hive Public MQTT Brokers. Not recommended for final deployments

Initial Setup and Deployment

  • Fork the Node-Red Repo (This easiest way that I found while writing this post)

  • Recommended settings change for the Node app

  • In the forked repo edit settings.js as requried (located at yourgithubusername/node-red/packages/node_modules/node-red/)

  • Uncomment httpAdminRoot: ‘/admin’,

  • Uncomment and change ui: { path: “ui” }, —> ui: { path: “/” },

  • These edits ensure that the flow editor is available at eg.herokuapp.com/admin

  • Control (Dashboard) is available at appname.herokuapp.com

  • Don’t forget to secure your Node-Red deployment Official Guide

  • We can make our initial deployment to Heroku once the settings.js is updated.

Final Setup

  1. Deploy the app to Heroku using the git deployment method (choose the forked repo)

  2. Once the app build is completed, you can access the node-red editor at the /admin path.

  3. Gather information and learn to use Node-Red.

  4. Next we will install the dashboard and core nodes.

  5. Setup the MQTT connections in Node-Red and click deploy in Node-Red.

  6. Your Control Center/Dashboard will be accessible at yourappname.herokuapp.com

  7. Flash the hardware (in this case esp8266) with MQTTclient program.

  8. Test the connection.

  9. NOTE that the app is deployed internally in Heroku and will not persist across app failures or reboots. (Read helpful notes for a solution to this problem)

Helpful Notes

  • Node-Red can be deployed to IBM Cloud with a few clicks but the app sleeps when using the free plan whereas In Heroku if we add a credit card we can run our app 24x7x365 without spending a single buck If you are not careful with your settings in Heroku your card will be charged

  • Helpful Info about the Heroku free plan

  • Very Imp when using Heroku After every Deploy (In Node-Red NOT IN HEROKU) Make sure that you export the current flow Official Guide. I will update this once I find a better and automatic method.

  • Always secure Node-Red Editor, Dashboard, and other static and node paths Official Guide

  • Setup Guide for Node-Red on Raspberry Pi

  • To make your app persistent across reboots or sleep times, export your node-red flow from the editor and update the flows.json file and the package.json file in the FORKED repo. In Heroku deploy the app again. I am still working on a better and automatic solution to this problem.

  • To prevent the Heroku app from sleeping, send an HTTP request to your app URL using a timestamp node with a 5-15 min interval and an HTTP node.

For any suggestions or queries feel free to send me a message. Now go DIY!

That's it!

I hope you enjoyed this article, as there are no ads, no trackers, no paywall, no shilling, no affiliate links, and no intentional bias, but I'm not perfect. Feel free to send your feedback.