Basic Projects | How to Start on Raspberry Pi Home Automation | ESPHome

by mcmchris in Circuits > Raspberry Pi

2695 Views, 7 Favorites, 0 Comments

Basic Projects | How to Start on Raspberry Pi Home Automation | ESPHome

Raspberry Ep1.jpg

Hello everyone, here Chris, and I want to show you a simple guide to begin your journey in Raspberry Pi home automation projects with ESPhome, this is an Add on of Home Assistant (Raspberry OS) that let us turn ESP boards on nodes capable of handle sensors and actuators.

If you have worked with the ESP8266, ESP32, ESP-01 boards to make any IoT project, now you will be able to configure your Raspberry Pi as the server of your projects, that let you stop using paid services like Blynk, Adafruit.IO, or any other.

You can reflash the firmware of any node with OTA without the need of connect them by USB to the Raspberry.

Here I leave you a tutorial with all the information so you can make your own version.If you are a visual learner I know that a video worth more than 1000 words, so here is a Tutorial video. (I am a Spanish speaker, so please consider turning on English subtitles):

Skills Required

Basics_Of_Arduino_Programming.jpg
bestesp8266-thumbnail-1024x576.jpg

This project may seem difficult or very complex for beginners, but it is definitely not completely, since you will have all the guidance for the construction, it was difficult for me to design it to make life a little easier for you. Any conceptual doubt, you are free to ask it without problems.

You should have an understanding of:

-Experience with ESP Boards (Optional).

-Arduino Programming.

Components and Parts List

Captura de pantalla (398).png
Captura de pantalla (451).png
IMG_20201015_192655-01.jpeg
PCBProgrammer.png

PCB Design and Ordering

SilkProgrammer.png
delivery_icon.07264281.png
Captura de pantalla (471).png
PCBProgrammer.png

For the implementation of a good project we need a reliable assembly for the circuit that makes it up, and there is no better way to do it than with a good PCB.

Here you can download EasyEDA PCB design to order your custom PCB of the programming shield.

I suggest JLCPCB:

$2 for 1-4 Layer PCBs⚡, Get SMT Coupons🎫

UnZip the .rar file with a software like WinRar or any other.

Raspberry Pi Unboxing and Housing Setup

Captura de pantalla (399).png
Captura de pantalla (400).png
Captura de pantalla (401).png
Captura de pantalla (402).png
Captura de pantalla (403).png
GPIO-Pinout-Diagram-2.png
Captura de pantalla (404).png

The Raspberry Pi Board need some extras to work properly (for a long term use).

  • Unbox the board, verify everything is right.
  • Place the heatsinks on top of the ICs respectively.
  • Place the Raspberry Pi inside it protective case.
  • Connect the fan to the 5v-Gnd pins of the board.

Flashing the Raspberry MicroSD Card

Captura de pantalla (405).png
Captura de pantalla (406).png
Captura de pantalla (407).png
Captura de pantalla (408).png
Captura de pantalla (409).png
Captura de pantalla (410).png
Captura de pantalla (411).png
Captura de pantalla (523).png
Captura de pantalla (412).png
Captura de pantalla (413).png
Captura de pantalla (414).png
Captura de pantalla (415).png
Captura de pantalla (416).png

  1. Select the MicroSD adapter that fix your computer.
  2. Insert it to an SD slot or USB port.
  3. Verify your PC recognize the storage. (Format it)
  4. Install the flasher software. (balenaEtcher) and run it.
  5. Go to Home Assistant website (Getting Starter>Installation>Raspberry Pi) and select the right image for your board.
  6. Select the Flash from URL option and paste the copied URL.
  7. Verify you choose the right storage destiny (The MicroSD Card).
  8. Click on Flash and wait for it.

Setting Up the Raspberry Pi and Turning On

Captura de pantalla (417).png
Captura de pantalla (418).png
Captura de pantalla (419).png
Captura de pantalla (420).png
Captura de pantalla (421).png
Captura de pantalla (423).png
Captura de pantalla (424).png
Captura de pantalla (425).png
Captura de pantalla (428).png
  • Extract the microSD from your computer.
  • Insert it in the MicroSD slot in the Raspberry Pi.
  • Connect the Ethernet cable from your router or modem to your Rasp.
  • Connect the power cable.
  • Turn on the board.

Now you must go to your favorite Web browser and type : http://homeassistant.local:8123

  1. The page will not work, wait for about a minute and should appear something.
  2. This new page says that wait for 20 minutes (yes for real 20 minutes).
  3. Then should appear textboxes that you must fill with your personal info.
  4. Click on create account if you don't have a previus Home Assistant profile backup image.
  5. Select your location and time zone for better weather predictions.
  6. Finally finish the process.

ESPHome Configuration

Captura de pantalla (432).png
Captura de pantalla (433).png
Captura de pantalla (434).png
Captura de pantalla (437).png
Captura de pantalla (439).png
Captura de pantalla (440).png
Captura de pantalla (441).png
Captura de pantalla (442).png
Captura de pantalla (443).png
Captura de pantalla (444).png
Captura de pantalla (445).png
  1. Once on the Home Assistant home screen, go to Supervisor > Add-on store > ESPHome.
  2. Install the Add-on, and activate the Watchdog, and Show in sidebar.
  3. Click on Start.
  4. Click on the ESPhome shortcut in the left sidebar.
  5. Click on (+) symbol to add a node.

Your first node creation:

  1. Click on Begin.
  2. Name your node with lowercase letters.
  3. Select the ESP board you will use (Generic ESP8266) in my case.
  4. Next, insert your WiFi credentials.
  5. Click on Submit.
  6. Now your node is created with some initial codes. (Do not edit them if you don't know what are you doing).

Your First Node Creation (IoT Project Binding)

Captura de pantalla (446).png
Captura de pantalla (447).png
Captura de pantalla (448).png
Captura de pantalla (449).png
Captura de pantalla (450).png
Captura de pantalla (451).png
Captura de pantalla (452).png
Captura de pantalla (453).png
Captura de pantalla (454).png
Captura de pantalla (455).png
Captura de pantalla (456).png
Captura de pantalla (457).png
Captura de pantalla (465).png
  1. Go to ESPHome main webpage
  2. Find the GPIO Switch example
  3. Copy the example and paste it below the initial code of your Node. Changing the pin and name to GPIO0 and LED.
  4. Find the DHT11 sensor example.
  5. Copy the example and paste it below too, changing the pin to GPIO2.

Assamble the circuit in the breadboard as shown.

  1. Connect the LED with it 220 ohm resistor between GPIO0 and GND.
  2. Connect the DHT sensor (Vcc to 3.3v, GND to GND, and Signal to GPIO2).
  3. Connect the USB cable from the flasher board to the USB port of your Raspberry.
  4. The Raspberry will detect a new serial port.
  5. In the right upper corner select the USB serial port.
  6. Upload your code to the ESP8266.
  7. You should see a black cmd like screen showing the debug of the upload process.
  8. Then you should see on blue color the data return of LED state, temperature and humidity.

We are almost done.

Setting Your Dashboard to Visualize the Data and Control the LED

Captura de pantalla (495).png
Captura de pantalla (509).png
Captura de pantalla (512).png
Captura de pantalla (513).png
Captura de pantalla (514).png
Captura de pantalla (430).png
Captura de pantalla (515).png
Captura de pantalla (516).png
Captura de pantalla (517).png

  1. Go to Configuration > Integrations and you should see a new widget telling you that is a new discovered device.
  2. Click on configure > submit > select house zone and finish.
  3. Now verify that the new integration has our 3 devices (LED, Temp and humidity).
  4. Go to the main page (Overview).
  5. In the right upper corner on the 3 dots, select "Edit dashboard".
  6. Click on (+) Add Card.
  7. Select the card of your preference that shows the data of the sensor and the toggle switch for the LED.
  8. Name it as you want, in my case "Clima de mi cuarto".
  9. Now everything is ready.

Final Test! Enjoy Your Project

Captura de pantalla (518).png
Captura de pantalla (519).png
Captura de pantalla (520).png
Captura de pantalla (521).png

Now you should be able to control your hardware from anywhere in your LAN home network.

You can disconnect your ESP8266 from your Raspberry and power it with batteries or a wall power brick and it will be completely functional.

Great thing!! You can modify and reflash the ESP code Over the Air, without having to connect it directly by USB to the Raspberry Pi.