Easy Raspberry basics: Project 29h Raspberry PI 3 model B board, ESP8266 ESP-12E module, BME280 sensor -

of Acoptex.com in Raspberry Pi 3

Raspberry basics: Project 29h

Project name: Raspberry PI 3 model B board, ESP8266 ESP-12E module, BME280 sensor - Temperature, Pressure 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, BME280, BME280 sensor, humidity, temperature, pressure, GY-BME280, Digital Sensor, SPI I2C Humidity Temperature and Barometric Pressure Sensor Module, GY-BME280-3.3

Attachments: copy2_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. Breadboard 1 pc

12. BME280 sensor module 1 pc


We will learn how to use ESP8266 ESP-12E module and BME280 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 the BME280 module

The BME280 is the next-generation of sensors from Bosch, and is the upgrade to the BMP085/BMP180/BMP183 - with a low altitude noise of 0.25m and the same fast conversion time. 

The BME280 sensor module reads temperature, humidity, and pressure. You can also estimate altitude as the pressure changes with altitude. There are several versions of this sensor module, but we will use the one shown below.

The sensor can communicate using either SPI (supports 3-, 4-wire SPI) or I2C communication protocols (there are modules of this sensor that just communicate with I2C, these just come with four pins).


  • Supply Voltage: 1.8 - 5V DC
  • Interface: I2C (up to 3.4MHz), SPI (up to 10 MHz)
  • Operational Range: Temperature: -40 to +85° C
  • Humidity: 0-100%
  • Pressure: 300-1100 hPa
  • Resolution:Temperature: 0.01°C Humidity: 0.008% Pressure: 0.18Pa
  • Accuracy:Temperature: +-1°C Humidity: +-3% Pressure: +-1Pa
  • I2C address SDO LOW : 0x76 SDO HIGH: 0x77 

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.


  • 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 the Raspberry PI 3 model B

Signals and connections of the BME280 sensor module

To use SPI communication protocol, you must have the following pins:

VIN -  power supply 3.3V DC

GND - ground

CLK (or SCK or SCL) (Serial Clock) - The clock pulses which synchronize data transmission generated by the master

MISO (or DO or SO or SDO) (Master In Slave Out) - The Slave line for sending data to the master

MOSI (or DI or SI or CMD or SDI or SDA) (Master Out Slave In) - The Master line for sending data to the peripherals

CS (or SS or D3 or CSB) (Chip Select or Slave Select) - the pin on each device that the master can use to enable and disable specific devices

If your BME280 sensor module has 4 pins it can use I2C communication protocol only: 

VIN -  power supply  3.3V DC

GND - ground

SDA - Serial Data Line

SCL  - Serial Clock Line 

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


BME280 sensor  Nodemcu 1.0

GND                 G (GND)

VIN                  3V3

SCL                  D1 (GPIO 5)

SDA                 D2 (GPIO 4)

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 referencecopy2_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. The BME280 sensor platform allows you to use your BME280 temperature, pressure and humidity sensors with ESPHome.Manually specify the i2c address of the sensor - 0x77 or 0x76; set up an Infinite Impulse Response filter (iir_filter) to increase accuracy - can be OFF, 2x, 4x, 16x; manually specify the update_interval to check the sensor. You can read more about  BME280 sensors setup in ESPhome here.
  26. In order for BME280 sensor module to work correctly, you need to define the I2C bus in your configuration. Please note the ESP will enable its internal 10kOhm pullup resistors for these pins, so you usually don’t need to put on external ones.
  27. Save your new_node.yaml file. Click on the diskette.
  28. Go to ESPhome, make sure that serial port selected.
  29. 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.
  30.  Click on STOP as soon you will get the message: Got temperature...
  31. Your node 
    Over-The-Air Updates:
    Over-The-Air updates link is and API Server link

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

  34. You need to setup a new Integration. Select ESPhome.
  35. Type the host and port (in our case it is and 6053). Click on SUBMIT.
  36. 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).
  37. Click on SUBMIT and FINISH.
  38. Click on ADD AREA if you want to assign this module to any area in the house (Living room, bedroom...).
  39. You can check the new_node integration configuration.
  40. Go to Overview and click on dots.
  41. Select Configure UI.
  42. Click on plus.
  43. Click on Entities.
  44. Type the title, select entities (in our case we had sensor.bme280_temperature, sensor.bme280_humidity and sensor.bme280_pressure) and click on SAVE.
  45. Click on x to go back to normal mode or EDIT to change the card.
  46. Congrats! You can see the temperature, pressure and humidity from your BME280 sensor module now.


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

Libraries in use

  • None


  • See on the begining of this project

Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

Published at 13-07-2019
Viewed: 6008 times