User Tools

Site Tools


rpi

This is an old revision of the document!


Home Assistant, ESPHome, BMP280 - temperature and pressure monitoring.
List:

ZDJECIE RPI3

ESP32

BMP280 sensor

ZDJECIE OBUDOWY

Prepare image HAOS:
https://github.com/home-assistant/operating-system/releases/download/13.0/haos_rpi2-13.0.img.xz
  • unpack image
unxz haos_rpi2-13.0.img.xz
  • insert sd card to your device and check how your machine recognize it - in mine case it is /dev/mmcbkl0
sudo fdisk -l  
  • flash your sdcard
sudo dd if=Downloads/haos_rpi2-13.0.img  of=/dev/mmcblk0 status=progress bs=1M
First run HA
  • insert sd card to RPI
  • connect Ethernet cable
  • insert WIFI dongle to usb port
  • connect power to RPI and wait while for HA to run
  • on your router check your rpi Ip address
  • in web browser insert rpi Ip address with port 8123, http://your_rpi_ip:8123
  • first create account
Setup wifi connection on first run:
  • go to Settings > System > select Network and then wifi tab
  • in ip4 select automatic
  • in WI-FI scan network to find your network and insert SSID and password. Save after that
  • reboot rpi to set up wifi
Instalacja dodatków:
  • idź do: ustawienia > Add-ons
  • naciśnij na klawisz dodaj i zainstaluj esphome i File editor
  • esphome pozwoli podłączyć esp32 płytkę do HA
  • file editor pozwoli edytować pliki konfiguracyjne HA
Struktura konfiguracyjna HA
  • configuration.yml
  • automation.yml
  • secrets.yml
Przygotowanie płytki ESP32 i podłączenie BMP280
  • BMP280 ma 6 pinów ale my użyjemy 4 VCC, GRN, SCL, SDA
  • podłącz piny:
    • BMP280 VCC → ESP32 3V
    • BMP280 GRN → ESP32 GRN
    • BMP280 SCL → ESP32 D22
    • BMP280 SDA → ESP32 D21

ZDJECIE PLYTKI Z PODLACZENIEM

Podłączenie esp32 do RPI
  • podłącz esp32 za pomocą USB do RPI
  • kliknij w ESPHome w zakładce
  • kliknij dodaj nowe urządzenie

tak powinno wyglądać ustawienie:

esphome:
  name: esp32-01
  friendly_name: esp32-01

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxx"

ota:
  - platform: esphome
    password: "xxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-01 Fallback Hotspot"
    password: "xxx"

captive_portal:

i2c:
  sda: 21
  scl: 22
  scan: True

sensor:
  - platform: bmp280_i2c
    temperature:
      name: "bedroom temperature"
      oversampling: 16x
    pressure:
      name: "bedroom pressure"
    address: 0x76
    update_interval: 60s

a tak wygląda przykładowa automatyzacja, jak temperatura wzrośnie powyżej 25 stopni, lub spadnie poniżej 5 lub 0 - wysłany zostanie email z ostrzeżeniem. Chciałbym tutaj zaznaczyć, że poniższa automatyzacja dotyczy czujnika umieszczonego poza domem. Stąd te niskie wartości temperatury :)

alias: "Temperature"
description: low temperature level
trigger:
  - platform: state
    entity_id:
      - sensor.temperature
    to: null
    for:
      hours: 0
      minutes: 30
      seconds: 0
condition:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.temperature
        above: 25
      - condition: numeric_state
        entity_id: sensor.temperature
        below: 5
      - condition: numeric_state
        entity_id: sensor.temperature
        below: 0
action:
  - data:
      message: "Temperature is: {{ states('sensor.temperature')}} C"
      title: "Warning: temperature is {{ states('sensor.temperature')}} C"
    action: notify.email_notification
mode: single

Dokładna dokumentacja jest tutaj: https://www.home-assistant.io/installation/raspberrypi

rpi.1727635530.txt.gz · Last modified: by karcio