Learn Node-RED and InfluxDB on a Raspberry Pi to build a Home Automation System with the ESP32 and ESP8266.
GET THE EBOOK »
Throughout this eBook, you’ll learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database.
If you want to learn:
- an easy way to create a user interface dashboard (Node-RED dashboard) to communicate with one or multiple ESP32/ESP8266 boards;
- send data from the ESP boards and display it on that same dashboard;
- create and schedule events easily without having to write a single line of code;
- set up a notification system to send you alerts or other useful data (email, WhatsApp messages, Telegram messages);
- log and handle your data on a time series database (InfluxDB) without previous knowledge about databases;
- create awesome dashboards with customizable charts, gauges, and much more using InfluxDB intuitive dashboard;
- build a home automation system but you don’t want to spend a lot of time learning and writing code;
- and much more…
Then, Smart Home with Raspberry Pi, ESP32, and ESP8266 is everything you are looking for!
What is Node-RED?
Node-RED is a powerful open-source tool for building Internet of Things (IoT) applications with the goal ofsimplifying the programming component. You can build a complete home automation system without having to write a single line of code. Node-RED runs on the web browser and uses visual programming that allows youto connect code blocks, known as nodes, together to perform a task. With Node-RED you canspend more time making cool stuff, rather than spending countless hours writingcode.
What is InfluxDB?
InfluxDB is an open-source high-performance time-series database (TSDB) that can store large amounts of data per second. Each data point you submit to the database is associated with a particular timestamp. So, it is ideal for IoT data logging projects like storing data from your weather station sensors.
By the end of the eBook, you’ll have a home automation application running on your Raspberry Pi that allows you to monitor and control various ESP32 and/or ESP8266 devices in your house. Then, you can connect the ESP boards to actuators to actually control something and to sensors to monitor your house.
The following diagram shows a quick overview of the system you’ll learn how to build.
- The brain of the operation is the Raspberry Pi. The Raspberry Pi hosts Node‑RED software, the MQTT broker, and InfluxDB. If you don’t have a Raspberry Pi, you can run the software on the cloud (Digital Ocean);
- You’ll learn how to connect the ESP32 and ESP8266 boards to your Raspberry Pi. They’ll communicate via a protocol called MQTT that uses a publish/subscribe system.
- You can control the ESP32 and ESP8266 boards via MQTT from Node-RED.
- The ESP can send sensor readings to Node-RED via MQTT. The readings can be displayed on gauges and charts on Node-RED UI.
- Node-RED can send the sensor readings and any other data to InfluxDB (time series database).
- InfluxDB provides tools to build customizable awesome charts and graphs to display and monitor your data on a dashboard.
- Node-RED can communicate with third-party services to send you notifications. We’ll cover sending emails, WhatsApp messages, and Telegram messages.
- You can create rules on Node-RED and schedule events to make things happen automatically. For example, turn something on or off depending on sensor readings, day and time of the week, etc.
- All of this is accessible on your local network.
- In the end, we’ll show you how you can create a secure tunnel to access your home automation system from anywhere in the world.
What’s inside the eBook?
A colorful 450 pages long PDF with step-by-step instructions. Includes all the source code, schematics, and screenshots that are easy to follow. Smart Home comes with 11 Modules.
Each module breaks down a specific concept of the home automation system and allows for quick referencing in the future.
With easy step-by-step tutorials, you can learn how to build a home automation system in a couple of afternoons! Here’s a quick description of the included modules:
- Module 1: Getting Started with the Raspberry Pi—a quick introduction to the Raspberry Pi board and setting it up to use throughout this eBook.
- Module 2: Getting Started with Node-RED—install Node-RED on the Raspberry Pi, get familiar with it, and start creating simple flows.
- Module 3: Getting Started with MQTT—set up the Raspberry Pi as an MQTT server to communicate with other devices.
- Module 4: Introducing the ESP32 and ESP8266—a quick introduction to the ESP32 and ESP8266 boards and how to program them using Arduino IDE.
- Module 5: Connecting the ESP32/ESP8266 with Node-RED (MQTT)—learn how to establish communication between the ESP boards and Node-RED using MQTT (publish and subscribe) to control outputs and monitor sensors.
- Module 6: InfluxDB Time-Series Database—get started with InfluxDB, a time-series database. Learn how to save your data and create dashboards with beautiful and easily-customizable charts.
- Module 7: Sending Notifications with Node-RED—learn how to send emails, Telegram messages, and WhatsApp messages via Node-RED to receive a warning, sensor readings, or any other useful information.
- Module 8: Adding Rules and Triggering Events—learn how to automate your system by adding rules (like sensor threshold values) and scheduling events based on time and day of the week.
- Module 9: Access Your Local System from Anywhere—set up a cloudflare tunnel to access your local home automation system from anywhere.
- Module 10: Creating a Cloud Server—set up Node-RED, Mosquitto MQTT broker, and InfluxDB on Digital Ocean and set up a secure tunnel. This is also an alternative if you don’t have a Raspberry Pi board.
- Module 11: Setting Up a Surveillance Camera—learn how to add an ESP32-CAM surveillance camera to your Node-RED home automation system.
- Appendix— quick guide with Linux commands and how to execute Linux commands via Node-RED.
Here’s what you’ll have access to when you get the eBook:
- eBook in PDF format (11 Modules, ~450 pages)
- Source Code + Project Files (Arduino sketches, JSON files for Node-RED flows)
- Unlimited Free Updates (includes future eBook updates)
- Access to a private Forum to ask questions
- Exclusive access to our Facebook group community
What you’ll learn:
By following this eBook, you’ll learn about the following subjects:
- Raspberry Pi:
- Get familiar with the Raspberry Pi board;
- Learn how to set up the Raspberry Pi board with the required software and how to establish an SSH connection;
- Learn basic Linux commands;
- Control the Raspberry Pi GPIOs using Node-RED.
- What is MQTT, how does it work, and how to use it in your home automation system;
- Install an MQTT broker on your Raspberry Pi to handle MQTT messages;
- Use MQTT to communicate between Node-RED and other devices (ESP32 and ESP8266).
- Learn how to create flows in Node-RED to execute tasks;
- Build publish and subscribe system flows;
- Set up a notification system;
- Schedule events and set up rules;
- Interface with InfluxDB: send data and make queries.
- Node-RED Dashboard:
- Create tabs and groups to display different widgets: buttons, text, charts, and gauges;
- Build flows with switches to control the ESP32/ESP8266 GPIOs;
- Use charts and gauges to visualize sensor readings.
- ESP32 and ESP8266:
- Subscribe to MQTT topics (listen to Node-RED messages) and do different tasks depending on the received messages;
- Publish sensor readings to MQTT topics (send to Node-RED);
- Subscribe to multiple topics simultaneously;
- Use interrupts to publish MQTT messages when motion is detected.
- Install InfluxDB on a Raspberry Pi and use Influx Telegraf to monitor the Raspberry Pi system;
- Create buckets to save data and build dashboards with different visualizations;
- Send data from Node-RED to InfluxDB;
- Make queries on Node-RED to get data from InfluxDB.
Continue reading for the complete Table of Contents…
MODULE 0: Introduction
This Module introduces the eBook. It covers what you’ll learn and build, instructions on how to follow this eBook, and recommended prerequisites. We’ll also give you a quick introduction to the main subjects we’ll cover throughout the eBook: MQTT, Node-RED software, InfluxDB time-series database, Raspberry Pi, ESP32, and ESP8266 boards.
MODULE 1: Getting Started with the Raspberry Pi
This Module is a quick introduction to the Raspberry Pi. You’ll set up your Raspberry Pi for the first time: install the operating system and establish an SSH connection with your Pi using your computer.
- 1.1 Introducing the Raspberry Pi
- 1.2 Installing the Operating System
- 1.3 Connecting via SSH to the RPi
MODULE 2: Getting Started with Node-RED
In this Module, you’ll get started with Node-RED software on the Raspberry Pi. You’ll install Node-RED, learn some basic concepts, and create simple flows to control the Raspberry Pi GPIOs. You’ll also learn about Node-RED dashboard, a set of nodes to easily create a user interface.
- 2.1 Node-RED Introduction
- 2.2 Installing Node-RED
- 2.3 Node-RED Overview
- 2.4 Node-RED Dashboard
- 2.5 Controlling an LED with Node RED
MODULE 3: Getting Started with MQTT
This section is an introduction to the MQTT protocol.MQTT stands for Message Queuing Telemetry Transport, a simple messaging protocol suitable for communication between IoT devices. Learn MQTT basic concepts, install an MQTT broker and create a simple publish/subscribe flow.
- 3.1 Introducing MQTT
- 3.2 Installing Mosquitto Broker
- 3.3 MQTT with Node-RED
MODULE 4: Introducing the ESP32 and ESP8266 Boards
This Module is a quick introduction to the ESP32 and ESP8266 boards. We’ll take a quick look at its features, specifications, and pinout. We’ll also show you how to program your boards using Arduino IDE.
- 4.1 Introducing the ESP8266
- 4.2 Introducing the ESP32
- 4.3 Installing Arduino IDE
- 4.4 Testing the Installation
MODULE 5: Connecting the ESP32/ESP826 with Node-RED (MQTT)
In this Module, you’ll learn how to program your ESP32 and ESP8266 boards to connect to your broker to publish messages and subscribe to topics. This way, we’ll be able to establish a communication between the ESP boards and Node-RED using MQTT. You’ll learn how to control the ESP outputs using Node-RED dashboard and to display sensor readings published by your boards.
- 5.1 Connect the ESP32/ESP8266 with Node-RED (Introduction)
- 5.2 Publish and Subscribe(Basic Example)
- 5.3 Publish Sensor Readings
- 5.4 Subscribe to Multiple Topics and Control Multiple Outputs
MODULE 6: InfluxDB Time-Series Database
InfluxDB is a time-series database. Each record on the database is associated with a timestamp, which makes it ideal for data logging, IoT, and home automation projects. InfluxDB also provides dashboard tools to visualize data in different formats like charts, gauges, histograms, etc. You can easily connect Node-RED to InfluxDB and save your readings on the database and use their dashboard to analyze the data in many different formats.
- 6.1 Getting Started with InfluxDB
- 6.2 Install InfluxDB (Raspberry Pi)
- 6.3 Monitoring your Raspberry Pi using InfluxDB Telegraf
- 6.4 MQTT + Node-RED + InfluxDB
- 6.5 Monitoring GPIO States on InfluxDB
- 6.6 Get Data from InfluxDB
- 6.7 Delete InfluxDB Data
MODULE 7: Sending Notifications with Node-RED
In this Module, you’ll learn how to send notifications with Node-RED. We’ll show you how to send emails, Telegram messages, and WhatsApp messages. We’ll also create a simple project to send the notification of your choice whenever motion is detected.
- 7.1 Email Alerts with Node-RED
- 7.2 Telegram Messages with Node-RED
- 7.3 WhatsApp Messages with Node-RED
- 7.4 Motion Detector with Notifications
MODULE 8: Adding Rules and Triggering Events
In this Module, you’ll learn how to automatically set all GPIOs to a defined state using master switches and modes. You’ll also learn how to trigger events when something happens (a notification, a threshold value, etc.) Finally, you’ll learn how to set timers and schedule events.
- 8.1 Creating Master Switches or Modes
- 8.2 Trigger Events Based on Threshold Values
- 8.3 Triggering Time-based Events
- 8.4 Time-based Events with Big Timer
MODULE 9: Accessing Your Local System from Anywhere
This Module explains how to set up a Cloudflare tunnel to access your Node-RED home automation system and InfluxD monitoring dashboards from anywhere.
- 9.1 Accessing Your System from Anywhere
MODULE 10: Creating a Cloud Server
If you don’t have a Raspberry Pi to follow along, you can create your system on the cloud. We provide instructions for installing Node‑RED, InfluxDB, and Mosquitto broker on Digital Ocean (hosting).
- 10.1 Introducing Digital Ocean
- 10.2 Installing Node-RED on the Cloud
- 10.3 Installing Mosquitto MQTT Broker on the Cloud
- 10.4 Installing InfluxDB on the Cloud
MODULE 11: Setting up a Surveillance Camera
In this section, you’ll learn how to add an ESP32-CAM surveillance camera to your Node-RED home automation system. The ESP32-CAM is a development board with an ESP32-S chip, an OV2640 camera, microSD card slot and several GPIOs to connect peripherals.
- 11.1 Introducing the ESP32-CAM
- 11.2 ESP32-CAM Video Streaming
- 11.3 Surveillance Camera on Node-RED
This section provides additional information that might be useful like executing commands on the Raspberry Pi using Node-RED and a quick guide with Linux commands.
- Sending Linux Commands Through Node-RED UI
- Learning Basic Linux Commands
Prerequisites (recommended but not mandatory)
There’s no previous knowledge required to complete the eBook, but some previous basic knowledge about the ESP32 or ESP8266 boards is beneficial like controlling outputs and reading sensors.
If there’s something extra that you need to learn during the eBook, we’ll point you to the right resource.
We use a step-by-step teaching approach, so all the modules and corresponding units are straightforward to follow even with no previous experience.
What do you need to follow the eBook?
The following list shows all the parts required to complete the projects and examples in this eBook:
- Raspberry Pi 4 B (recommended) or Raspberry Pi 3 B+
- MicroSD card for the Raspberry Pi OS (at least 16GB class 10)
- Raspberry Pi power supply (5V DC 2A power supply, USB-C)
- ESP32 board and/or ESP8266 board
- Jumper wires
- LEDs (at least four)
- 220 Ω resistor or similar values (at least four)
- BME280 sensor temperature, humidity, and pressure sensor (alternatively, you can use any other sensor you’re familiar with)
- Mini PIR motion sensor (AM312)or PIR motion sensor (HC-SR501)
If you can’t get a Raspberry Pi, you can still follow along and build your home automation system on the cloud, which requires a monthly payment for the hosting service.
Invitation to Join our Private Forum!
This eBook comes with an opportunity to join our private Forum of like-minded people where you can ask questions about the eBook or other related subjects. You’ll get direct help from Rui and Sara or from other active members of the community.
Download the eBook
- Updated July, 2023
- PDF eBook with ~450 pages
- Source code and all files: Arduino sketches, JSON files for Node-RED flows
- Step-by-step instructions
- Code explanation
- Unlimited Updates
- Exclusive access to a Private Forum
- English language
- Created by Rui Santos and Sara Santos
Note:after your purchase,you receive an email with a username and password that you use to access the members’ area and download the PDF eBook.
Have questions?Email me at https://randomnerdtutorials.com/supportanytime for any reason.
You won’t regret it. My 60-day money-back guarantee backs up every word in this message. Proceed with confidence.See you inside,
-Rui Santos and Sara Santos
Backed by a 60 day 100% money-back guarantee
If you don’t like the course, I don’t want your money. Seriously, that’s why I offer a 60 days money back guarantee. Email me here and I will promptly refund all your money. No questions, no hassles – it’s that simple.
Frequently Asked Questions
To program the ESP32 and ESP8266 boards, we’ll use Arduino IDE.
Node-RED and InfluxDB are free to use locally on your Raspberry Pi. You don’t need to pay anything to use that software. In Module 9, if you want to access your Home Automation System outside your local network, you’ll need a domain name. You can use a free domain name or you can get a paid domain name in order to create a secure tunnel with Cloudflare. If you don’t have a Raspberry Pi, you can use Digital Ocean (instructions provided), but you’ll need to pay for a monthly plan.
Yes. We use Raspberry Pi to run Node-RED, Mosquitto MQTT broker, and InfluxDB locally. If you don’t have a Raspberry Pi, you can install all those on a cloud Linux server, for example. We provide installation instructions if you want to use Digital Ocean (you need to pay for a monthly subscription).
Yes. It is not mandatory to have all the recommended prerequisites to follow along as the eBook is step-by-step style. Anyone without previous knowledge can complete the projects.
It might be more challenging understanding the ESP32/ESP8266 code. But, you can always use our website or our ESP32/ESP8266 eBooks as a reference.
That’s true! However, if you don’t want to spend countless hours searching for the right information and if you want to accelerate the learning curve, our eBook is a better option.
We spent the latest few months curating and putting together all the relevant information and resources so that you can have a pleasant learning experience with only the information that matters.
Our instructions are straight to the point, all projects are tested, and we can help you if you get stuck or have any issues!
To access the local home automation system from anywhere, we’ll use Cloudflare tunnels. To do that, you need a domain name. You can get a paid or free domain name.
This eBook is for those who want to learn how to build a home automation system using Node-RED as the center of the operation. Node-RED allows you to create awesome automation flows without having to write code. It uses visual programming. So, it is super accessible, specially for those not much keen on writing code.
If you get stuck at some point, you can use our forum to post your issue. We answer all the questions. You can also send us an email with your issue, and we’ll try to help as much as possible so that you get all examples working.
Yes, we often update all our eBooks, so everyone who purchases gets free lifetime updates. You’ll also have access to future content that we might add to the eBook.
Well, if you don’t like it, I don’t want your money. Seriously, that’s why I offer a 60 days money back guarantee.Email me hereand I will promptly refund all your money. No questions, no hassles – it’s that simple!
If you still have questions after reading this page pleaseemail me here. I’ll do my best to answer your questions.
Meet the Authors
Hey there, I’m Rui Santos, founder of the Random Nerd Tutorials blog. I have a master’s degree in Electrical and Computer Engineering from FEUP. I’m the author of the books: “BeagleBone For Dummies “and “20 Easy Raspberry Pi Projects:Toys, Tools, Gadgets, and More!“. I was the Technical reviewer of the “Raspberry Pi For Kids For Dummies” book. I have worked at the RNT blog since 2013, and we’ve self-published several eBooks on the IoT and Home Automation fields.
Hi! I’m Sara Santos, and I work with Rui at Random Nerd Tutorials. I have a master’s degree in Bioengineering from FEUP, and I’m the co-author of the “20 Easy Raspberry Pi Projects” book. I create, write and edit the tutorials and articles for the RNT and Maker Advisor blogs and help you with your concerns wherever I can—I answer the questions on the forum and the comments on our blog posts. I’ve also written several eBooks with Rui related to ESP32, ESP8266, Firebase, and much more. I love books, writing, cats, and a hot cup of tea.
See what others are saying
Thank you Rui. Anyone wondering whether you bring value can rely on my word. I’ve purchased hundreds of books over a 45 year career as engineer and entrepreneur. NONE of these books have approached your excellent method of teaching a subject. You have a rare gift as a teacher. Glad to have made the purchases.
Just wanted to let you know that Random Nerd Tutorials is an axcellent site. It’s the best I’ve seen out there for showing software and hardware examples for the ESP32. You and Sara have done an excellent job! (…) I would have never learned it this fast without your help.Chris Steffes
I want to congratulate you on the manuals you have created, they are the best of the best that I have seen in many years. (… ) Your explanations are very clear and very detailed, as if you were a teacher…Tino Fernández
I placed the order of these ebooks/courses and have downloaded the eBooks. The ebooks are very informative and very well presented, as is your website(…).
I appreciate your eBooks, and especially your support that comes with them! Thank youJoe Margevicius
I want to thank you for the high quality of your projects. Too many others just list a series of tasks but not what to do when they do not go as planned. The detail that you have put into the writeups is amazing. I am working with my 10 year old grandson to help this interest in electronics and software. It would be much harder without your guides.Doug Hogg
Thank you. I’ve bought two of your course books and they really accelerate the learning curve with the result I wanted.Paul Kroshko
This is just a thank you! I’ve used bits of your code in almost all my projects. Because of your tutorilas I managed to get a job yesterday.Jan Gremmler
AS SEEN ON…