본문 바로가기

홈어시스턴트 IoT

미세먼지와 이산화탄소에 진심? Waveshare e-ink에 항상 표시

실내 미세먼지의 관리 여부와 외부 마스크 착용 여부에 따라 '코'나 '목'의 (콧물, 가래나 불편함)상태가 바뀌는 것을 체감한 후부터는 항상 실내 이산화탄소와 미세먼지 수치를 관리하고 있습니다. 특히 실내 초미세와 미세먼지 수치는 5㎍/㎥ 미만으로 365일 24시간 관리하고 있습니다. 

 

거실에 놓아둔 라즈베리파이 7인치 모니터로 Home Assistant가 표시되는 부모님 댁과 달리, 저는 컴퓨터나 스마트폰으로만 확인이 가능했는데, 잉여로 남아 돌던 e-ink 2.7인치에 표시해 보았습니다. 

 

간단하지만 좋네요. 

 

실외/실내 초미세먼지, 이산화탄소

 

[사용 장치] 

  • 2.7인치 e-ink 디스플레이 : 원래 RPi용 HAT에 붙어 있던 것을 떼어 내어 이용(제품 설명)
  • Waveshare e-Paper ESP8266 Driver Board(제품 설명)

[ESPHome 코드] 

Home Assistant에 HACS를 통해 설치한 네이버 날씨 정보에서 외부 초미세먼지를 가져오고, ESP8266보드 기반 DIY로 만든 미세먼지센서(SDS021)와 이산화탄소센서(MH-Z19B)는 ESPHome을 통해 Home Assitant로 연결되어 있습니다. 

 

ESP8266 Driver Board에 올린 ESPHome .YAML 파일 내용은 다음과 같습니다. 

esphome:
  name: epaper8266

esp8266:
  board: nodemcu

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

wifi:
  ssid: !secret ssid 
  password: !secret password 
  domain: !secret domain 
  
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.1.177
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.1.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0

captive_portal:

time:
  - platform: homeassistant
    id: ntp

# Example configuration entry
font:
  - file: "fonts/verdana.ttf"
    id: font1
    size: 36
    glyphs: |-
      !"%()+=,-_./:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz

spi:
  clk_pin: D5
  mosi_pin: D7

sensor: 
  - platform: homeassistant 
    entity_id: sensor.2_5um
    id: indoor_pm25
    internal: true 
  - platform: homeassistant 
    entity_id: sensor.naver_weather_ultrafinedust_1
    id: outdoor_pm25
    internal: true 
  - platform: homeassistant 
    entity_id: sensor.mh_z19_co2_value
    id: co2
    internal: true 

    
display:
  - platform: waveshare_epaper
    cs_pin: D8
    dc_pin: D2
    busy_pin: D1
    reset_pin: D4
    model: 2.70in
    rotation: 270
    update_interval: 60s 
    lambda: |-
      // position 
      #define xRes 264
      #define yRes 176 
      #define pad 10
      
      it.strftime(0 + pad, 0 + pad, id(font1), "%m-%d %H:%M", id(ntp).now());
      it.printf(0 + pad, 0 + pad + 36, id(font1), TextAlign::TOP_LEFT, "0PM25: %.0f", id(outdoor_pm25).state);
      it.printf(0 + pad, 0 + pad + 36 * 2, id(font1), TextAlign::TOP_LEFT, "IPM25: %.0f", id(indoor_pm25).state);
      it.printf(0 + pad, 0 + pad + 36 * 3, id(font1), TextAlign::TOP_LEFT, "CO2: %.0f", id(co2).state);