1

member

Easy Raspberry basics: Project 29g Raspberry PI 3 model B board, ESP8266 ESP-12E module, DHT - Temperatur

of Acoptex.com in Raspberry Pi 3

Raspberry basics: Project 29g

Project name: Raspberry PI 3 model B board, ESP8266 ESP-12E module, DHT sensor - Temperature and Humidity with ESPhome, Home Assistant

Tags: Raspberry, Raspberry PI 3 model B board, vers 1.1, v 1.1, Home assistant, ESPhome addon, how to use ESPhome in Home Assistant, ESP8266 ESP-12E module, ESP, ESP8266, WI FI module, ESP-12E, LoLin NODEMCU V3, NODEMCU, ESPhome Nodemcu, ESPhome ESP8266 ESP-12E, ESPhome ESP8266, DHT, DHT21, DHT22, DHT 11, DHT sensor, humidity, temperature

Attachments: copy1_new_node.yaml

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Raspberry PI 3 model B 1 pc

2. Micro SD card and SD card adapter 1 pc

3. Micro USB power supply (2.1 A, max 2.5 A) 1 pc

4. USB keyboard 1 pc

5. USB mouse 1 pc

6. TV or PC monitor 1 pc

7. HDMI cable 1 pc

8. ESP8266 ESP-12E module with micro USB cable 1pc

9. Jumper cables F-M

10. Resistor 1 pc (4.7 KOhm or 10 KOhm)

11. Breadboard 1 pc

12. DHT11 21 22 Humidity and temperature module 1 pc

General

We will learn how to use ESP8266 ESP-12E module and DHT sensor module with ESPhome and Home Assistant on Rasprberry Pi. 

Understanding the ESPhome

ESPHome is the perfect solution for creating custom firmwares for your ESP8266/ESP32 boards. 

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.

ESPHome is a tool which reads in YAML configuration files (just like Home Assistant) and creates custom firmwares. The tool also has many helpers that simplify flashing devices and aims to make managing your ESP boards as simple as possible. Once you have added devices or sensors in ESPHome's configuration, they will even automatically show up in Home Assistant's UI.

Technically, all ESP8266/ESP32 devices are supported by ESPHome:

Sensor Components

Sensor Core, ADC, ADS1115, AM2320, APDS9960, BH1750, Binary Sensor Map, BLE RSSI, BME280, BME680, BMP085, BMP280, CCS811, CSE7766, CT Clamp, Dallas, DHT, DHT12, Duty Cycle, ESP32 Hall Sensor, HDC1080, HLW8012, HMC5883L, Home Assistant, HX711, INA219, INA3221, Integration, HTU21D, MAX31855, MAX6675, MH-Z19, MPU6050, MQTT Subscribe, MS5611, NTC Thermistor, PMSX003, Pulse Counter, Pulse Width, Resistance, Rotary Encoder, SDS011 Sensor, SHT3X-D, TCS34725, Template Sensor, Total Daily Energy, TSL2561, Ultrasonic Sensor, Uptime Sensor, WiFi Signal Strength, Xiaomi MiFlora, Xiaomi MiJia, Custom Sensor.

Binary Sensor Components

Binary Sensor Core, GPIO, Home Assistant, Status, ESP32 BLE Presence, ESP32 Touch Pad, MPR121 Capacitive Touch Sensor, Nextion Touch, Template Binary Sensor, PN532, RDM6300, TTP229, Custom Binary Sensor.

Output Components

Output Core, ESP8266 Software PWM, GPIO Output, ESP32 LEDC, PCA9685, MY9231/MY9291, Custom Output.

Light Components

Light Core, Binary Light, Monochromatic Light, Cold+Warm White Light, RGB Light, RGBW Light, RGBWW Light, FastLED Light, NeoPixelBus Light, Light Partition, Custom Light.

Switch Components

Switch Core, GPIO Switch, Restart Switch, Shutdown Switch, Generic Output Switch, Template Switch, UART Switch, Custom Switch.

Fan Components

Fan Core, Binary Fan, Speed Fan.

Display Components

Display Core, LCD Display, MAX7219, Nextion, SSD1306, Waveshare E-Paper.

Cover Components

Cover Core, Template Cover, Endstop Cover, Time-Based Cover, Custom Cover.

Text Sensor Components

Text Sensor Core, Home Assistant, MQTT Subscribe Text, Version, WiFi Info, Template Text Sensor, Custom Text Sensor.

Climate Components

Climate Core, Bang Bang Controller, Custom Climate, Coolix IR Remote, Tcl112 IR Remote.

Misc Components

Remote Receiver, Remote Transmitter, Status LED, Time, Sun, GPS, ESP32 BLE Tracker, ESP32 BLE Beacon, ESP32 Ethernet, ESP32 Camera, Stepper, Servo, PCF8574 I/O Expander, MCP23017 I/O Expander, Debug Component.

Additional Custom Components

Generic Custom Component, Custom I2C Component, Custom SPI Component, Custom UART Component.

You can find out more here.

Understanding the Home Assistant

You can read more about it here.

Understanding the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

You can read more about it here.

Understanding DHT humidity and temperature sensor

You can read more about it here.

Datasheet can be found here.

Understanding the Raspberry PI 3 model B

The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.

Specification:

  • Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
  • 1GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40-pin extended GPIO
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5A

Signals and connections of DHT11 module

There are 3 : VCC (+5V), Data, GND (-)

Signals and connections of the Raspberry PI 3 model B


Signals and connections of the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

TX - transmit pin. GPIO pin

RX  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND ( or G) - ground pin.

RST - reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.

EN - Chip enable. Keep it on high (3.3V) for normal operation.

Vin - External power supply 5VDC.

D0-D8 - GPIO (General Purpose Input Output) pins 

D5-D8 - SPI interface

D1-D2– I²C/TWI Interface

SC (or CMD) - (Chip Select) - the pin that the master can use to enable and disable specific devices. GPIO pin

SO (or SDO) - Master In Slave Out (MISO) - SPI communication. The Slave line for sending data to the master. GPIO pin

SK (or CLK) - SCK (Serial Clock) - SPI communication.The clock pulses which synchronize data transmission generated by the master. GPIO pin

S1 (or SD1) - Master Out/Slave In (MOSI). SPI communication. The Master line for sending data to the peripherals. GPIO pin

S2 (or SD2) - GPIO pin

S3 (or SD3) - GPIO pin

VU (or VUSB) - external power 5VDC.

A0 - ADC output.

RSV - reserved

Wiring

The DHT module should be connected to GPIO 5 (D1 pin marked on the module).

Step by Step instruction

We recommend using a high-performance SD card for increased stability as well as plugging your device into an external display to see the default application booting up.

We assume that you have Windows 7 64 bit OS installed on your PC and empty micro SD card 32 GB with SD card adapter.

Configuration file attched for your referencecopy1_new_node.yaml

1. Do wiring.

  1. Do wiring for Lolin Nodemcu 1.0 (ESP8266 ESP-12E module) and breadboard.
  2. Plug in your Lolin Nodemcu 1.0 (ESP8266 ESP-12E module) to the Raspberry Pi 3 board USB port.

2. Installing Hass.io

It was explained in Raspberry basics: Project 29a Raspberry PI 3 model B board - Home assistant for beginners

3. Adding ESPhome addon

  1. In Home Assistant go to Hass.io ->ADD-ON STORE.
  2. In the Repositories part (on top), type the https://github.com/esphome/hassio in the Add new repository by URL field.
  3. Click on ADD.
  4. After that, wait a bit until the add-on is installed.
  5. Go to the add-on page. Click on INSTALL.
  6. Start the add-on by clicking on START.
  7. Click on Open Web UI.
  8. You will be greeted by a nice introduction wizard which will step you through creating your first configuration.
  9. Click on plus in orange circle.
  10. The ESPHome setup wizard opens. It will guide you through setting up your first ESP8266 or ESP32-powered device using ESPHome. This wizard will create a basic YAML configuration file for your "node" (the microcontroller). Later, you will be able to customize this file and add some of ESPHome's many integrations.
  11. First, we need to give this node a name. Choose this name wisely, it should be unique among all your ESPs. Names must be lowercase and must not contain spaces (allowed characters: a-z, 0-9 and _). Let's name it - new_node. Click on CONTINUE button.
  12. Select a type of microcontroller board you're using so that the ESPhome can compile firmware for it. If unsure you can also select a similar board or choose the "Generic" option.
  13. We have selected NodeMCU. Click on CONTINUE button.
  14. In next step you need to type the local WiFi network SSID and password (leave empty for no password) to be able to connect node to WiFi Access Point.
  15. ESPHome automatically sets up an Over-The-Air update server on the node so that you only need to flash a firmware via USB once. This password is also used to connect to the ESP from Home Assistant. Optionally, you can set a password for this upload process too. Click on CONTINUE button.
  16. You've successfully created your first ESPHome configuration file. 
  17. When you click on SUBMIT, the wizard will save a configuration file under /config/esphome/new_node.yaml
  18. If you have Configurator installed in Home Assistant skip installation notes. Go to Hass.io -> ADD-ON STORE  and select Configurator.
  19. Click on Install.
  20. Click on Start.
  21. Click on Open Web GUI.
  22. The configurator GUI opens. Go to Browse FileSystem.
  23. Go to config/esphome/ folder and find the new_node.yaml file.
  24. Open this file and modify with code. You need toconfigure manual_IP with your static_IP and gateway. After putting a manual IP in your configuration, the ESP will no longer need to negotiate a dynamic IP address with the router, thus improving the time until connection. This can help with Over-The-Air updates if for example the home network doesn't allow for .local addresses. When a manual IP is in your configuration, the OTA process will automatically choose that as the target for the upload. 
  25. Manually specify the DHT model, can be one of AUTO_DETECT, DHT11, DHT22, AM2302, RHT03, SI7021 and helps with some connection issues. Defaults to AUTO_DETECT. Auto detection doesn’t work for the SI7021 chip. If you’re seeing lots of invalid temperature/humidity warnings in the logs, try manually setting the DHT model with the model: configuration variable. Other problems could be wrong pull-up resistor values on the DATA pin or too long cables. You can read more about DHT sensors setup in ESPhome here.
  26. Save your new_node.yaml file. Click on the diskette.
  27. Go to ESPhome, make sure that serial port selected.
  28. Click on UPLOAD to flash firmware. This compiles the firmware for your node and uploads it using any connected USB device or, if no USB devices are connected, over-the-air using the OTA Update ComponentPlease note that Hass.io Add-On is currently not capable of discovering new USB ports after the add-on has started due to some docker restrictions. Please go to the add-on details page and restart the add-on if a new USB device is not automatically found. If the USB device is still not found, try changing the USB cable and restarting the add-on.
  29.  Click on STOP as soon you will get the message: Client 'Home Assistant 0.95.4 (xxx.xxx.x.xxx)' connected successfully!
  30. Your node 
    Over-The-Air Updates: 192.168.1.240:8266
    Over-The-Air updates link is 192.168.1.240:8266 and API Server link 192.168.1.240:6053

  31. Go to Configuration->Integrations.
  32. Click on plus in orange circle.

  33. You need to setup a new Integration. Select ESPhome.
  34. Type the host and port (in our case it is 192.168.1.240 and 6053). Click on SUBMIT.
  35. You will need to type or paste the password witch you have assigned before when made the node (you can see it in new_node.yaml file as API password).
  36. Click on SUBMIT and FINISH.
  37. Click on ADD AREA if you want to assign this module to any area in the house (Living room, bedroom...).
  38. You can check the new_node integration configuration.
  39. Go to Overview and click on dots.
  40. Select Configure UI.
  41. Click on plus.
  42. Click on Entities.
  43. Type the title, select entities (in our case we had sensor.temperatureand sensor.humidity and click on SAVE.
  44. Click on GAUGE or SENSOR. You can setup additional views too.
  45. We will show you as example how you can do it. See below the configuration of GAUGE.
  46. See below the configuration of SENSOR.
  47. Do not forget to click on SAVE to save the setup done.
  48. Click on x to go back to normal mode or EDIT to change the card.
  49. Congrats! You can see the temperature and humidity from your DHT sensor now.

Summary

We have learnt how to use ESP8266 ESP-12E module and DHT sensor module with ESPhome and Home Assistant on Rasprberry Pi. 

Libraries in use

  • None

Resources

  • See on the begining of this project


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

Published at 12-07-2019
Viewed: 2533 times