Skip to content

Alextros00/Home-Automation-NodeRED-ESP-Telegram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

Home-Automation-NodeRED-ESP-Telegram

LinkedIn Stargazers Features GitHub last commit My Projects Website


ESP32 Wired to control a light via relay

Home Automation

A cheap way to automate anything and everything!
Explore the docs »
View Demo · Report Bug · Request Feature
Buy Me A Coffee

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. License
  6. Contact
  7. Acknowledgements

About The Project

This project is about automating all aspects of my home that I can. Why turn on my lights every morning at 7am and turn them off every night at 10:45pm when it can be done for me! I want to spend as little time as possible dealing with repetitive tasks and focusing on the things that matter most to me. This project consists of many smaller projects. Here is where they are all put together and additional features are added.

Built With

There were many parts to this project. Some sub-projects that I did in order to build up to this complexity can be found on my github.

Main Components

†: I us 8GB but don't really think it is required.

Architecture

Architecture

Getting Started

These steps will take you through the overall home automation system. The system consists of other repos for specifics linked throughout this README doc.

Prerequisites

The software used is free and mostly open source.
It would help to have the hardware below.

  • Laptop
  • Smartphone
  • At least one ESP32
  • Raspberry Pi 4
    †: Raspberry Pi 4 should be running Raspbian Operating System
    ‡: Needs to be connected to and using a 2.4GHz network. This is because the ESP32 currently(Dec 2020) cannot connect to 5GHz networks.

ESP32

You can get really cheap knock off ESP32s on AliExpress
Some ESP devices that I use are: ESP-WROOM-32, ESP-32S, ESP32-CAM, ESP-EYE

ESP-IDF

  1. Use the installer for Windows, Linux or Mac OS.
    ‡:Check the official site for more info.
  2. Fork my repo and Clone my ESP32 MQTT Light Control repository using this command. Replace the xxxxx with the repo.
    git clone -b --recursive https://github.com/Alextros00/xxxxxxxxxxx
Commands to Remember

Build and flash the project onto your device.
idf.py build & flash
Monitor the logs of your device
idf.py monitor
To exit the monitor us Ctrl + ] or Ctrl and ] at the same time

ESP32 Repos

  1. Light(Relay) Control over MQTT.
  2. MC38 Door Sensor to track opening and closing of doors or windows

Mosquitto MQTT Broker

MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium [mqtt.org]. The Mosquitto broker will be installed on your Raspberry Pi as the broker and your ESP devices will be clients. Learn more here.

Navigate to the terminal and follow these steps for the installation.

  1. Update your Raspberry Pi
    sudo apt-get update
  2. Install Mosquitto
    sudo apt-get install mosquitto
  3. Install Mosquitto Client
    sudo apt-get install mosquitto-clients
    ‡: Note for later: Port of your Mosquitto Broker, most likely 1883; Server Mosquitto Broker is running on, most likely the ip address of your Raspberry Pi

NodeRED

NodeRED is a low-code programming tool for wiring together hardware devices, APIs and online services for event driven applications. The browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

Install NodeRED on your Raspberry Pi

Flows

Many of the flows used can be found in my collection at nodered.org. Here the general functionality of each flow will be described and more details(and the flow itself:) are provided on my NodeRED page.

Functionality

Light Control: lights can be controlled through a Telegram command, a button by the lamp, a button on my NodeRED Dashboard, and a webhook on my phone's home screen

  • Light Control: Lights can be controled through time of day, a Telegram Command using a inline keyboard, the NodeRED Dashboard, a webhook on my phone homescreen, or even a good old button by the lamp
  • Raspberry Pi Status: The Raspberry Pi 4 has been rumored to overheat. I monitor the temperature and recieve notification and text if it goes to high
  • Local Free Listings: The dashboard displays local free listings from FreeCycle and Craigslist
  • Motivational Dashboard: When idol the dashboard displays a motivational image, quote and Bible verse that rotate regularly. I also recieve a daily motivational message.
Flow Gallery

Telegram

Telegram adds the ability to control the system from your phone but is not required for use. You could stricktly use the NodeRED dashboard to control your system. In this implementation, Telegram does not directly control any devices but rather goes through NodeRED using the node-red-contrib-telegrambot library.

Commands

  • /water - records that I drank a bottle of water
  • /poop - records that I took a poop
  • /piss - records that I took a pee
  • /lights - displays inline keyboard to choose which light to change and what to do with it
  • /doorlighton - turns on door light... I know its redundant just use /lights
  • /doorlightoff - turns off door light... I know its redundant just use /lights
  • /bedsidelalmpon - turns on bedside light... I know its redundant just use /lights
  • /bedsidelalmpoff- turns off bedside light... I know its redundant just use /lights
  • /sleepin - delays the auto turn on of my lights by 30 minutes
  • /motivation - changes the motivational display on the dashboard and sends motivational image over Telegram
  • /whoishome - replys with who is on my home wifi
  • /alive - replys with what devices are responding on the system
  • /temp - replys with the temp of each device that is connected
  • /help - responds with the Telegram ChatId

Notifications

  • Raspberry Pi is over 65 degree C - Tells me when the Raspberry Pi has reached temperatures over 65C.
  • Motivational Image - at 11am daily I recieve a motivational quote to keep me going until lunch!
  • Motivational Quote - at 2pm daily I recieve a motivational image to keep me going until dinner!

Usage

The system can be utilized in two ways, through the Telegram-Bot or through the NodeRED Dashboard.

Usage through Telegram

Telegram sends me notifications and I can send it commands.

Usage through the NodeRED Dashboard

The NodeRED Dashboard can be used to control the system through buttons, text boxes and switches, but also displays alot of information.

Roadmap

See the open issues for a list of proposed features (and known issues).
This project will continue to grow in my free time to automate everything... except for working out... that I just have to do.

License

Distributed under the MIT License. See LICENSE for more information but basically you can take my code but I would appreciate a coffee!

Contact

Alex Trostle - GitHub - Email - LinkedIn - Instagram - My Website

Buy Me A Coffee

Acknowledgements