diff --git a/m5stackfire.yaml b/m5stackfire.yaml new file mode 100644 index 0000000..7eac182 --- /dev/null +++ b/m5stackfire.yaml @@ -0,0 +1,179 @@ + +esphome: + name: m5stackfire + platform: ESP32 + board: m5stack-fire + +substitutions: + friendly_name: "M5StackFire" + +api: + encryption: + key: !secret api_encryption_key + services: + - service: mhz19_calibrate_zero + then: + - mhz19.calibrate_zero: my_mhz19 +wifi: + ssid: WLAN + password: !secret wifi_password + +ota: + password: !secret ota_password + +logger: + hardware_uart: UART2 + baud_rate: 0 + +# Power Management +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components + components: [ip5306] + +ip5306: + battery_level: + name: ${friendly_name} Battery Percent + id: battery_percent + charger_connected: + name: ${friendly_name} Charger Connected + id: connected + charge_full: + name: ${friendly_name} Charge Full + id: full + +# Buttons +binary_sensor: + - platform: gpio + id: M5_BtnA + pin: + number: 39 + inverted: true + - platform: gpio + id: M5_BtnB + pin: + number: 38 + inverted: true + on_click: + then: + - switch.toggle: backlight + - platform: gpio + id: M5_BtnC + pin: + number: 37 + inverted: true + +# GPIO pin of the display backlight +switch: + - platform: gpio + pin: 32 + name: "Backlight" + id: backlight + restore_mode: ALWAYS_ON + +light: + #- platform: monochromatic # backlight + # output: gpio_32_backlight_pwm + # name: ${friendly_name} Backlight + # id: backlight + # restore_mode: ALWAYS_ON + - platform: esp32_rmt_led_strip + rgb_order: GRB + pin: GPIO15 + num_leds: 10 + rmt_channel: 1 + chipset: SK6812 + name: "${friendly_name} Side Light" + restore_mode: ALWAYS_OFF + id: side_light + default_transition_length: 0s + +i2c: + sda: 21 + scl: 22 + scan: True + +# Display +spi: + clk_pin: 18 + mosi_pin: 23 + miso_pin: 19 + +font: + - file: "gfonts://Roboto" + id: roboto + size: 24 + +display: + - platform: ili9xxx + model: M5STACK + cs_pin: 14 + dc_pin: 27 + reset_pin: 33 + id: my_display + lambda: |- + it.printf(80, 0, id(roboto), Color(255, 255, 255), TextAlign::TOP_CENTER, "CO2 Value %.1f", id(co2value).state ); + it.printf(80, 30, id(roboto), Color(255, 255, 255), TextAlign::TOP_CENTER, "CO2 Temp %.1f", id(co2temp).state ); + + +#display: +# - platform: ili9xxx +# model: M5STACK +# cs_pin: 14 +# dc_pin: 27 +# reset_pin: 33 +# id: my_display +# lambda: |- +# Color RED(1,0,0); +# Color BLUE(0,0,1); +# Color WHITE(1,1,1); +# +# it.rectangle(0, 0, it.get_width(), it.get_height(), BLUE); +# it.rectangle(0, 22, it.get_width(), it.get_height(), BLUE); // header bar +# it.print(it.get_width() / 2, 11, id(font_roboto_medium22), RED, TextAlign::CENTER, "Particulate matter"); +# +# it.print(11, 33, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "PM1"); +# it.print(11, 55, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "PM2.5"); +# it.print(11, 77, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "PM10"); +# +# ////it.printf(it.get_width() - 11, 33, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f µg/m³", 0.0); +# ////it.printf(it.get_width() - 11, 55, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f µg/m³", 0.0); +# ////it.printf(it.get_width() - 11, 77, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f µg/m³", 0.0); +# +# //it.rectangle(0, 110, it.get_width(), 22, BLUE); // header bar +# //it.print(it.get_width() / 2, 121, id(font_roboto_medium22), RED, TextAlign::CENTER, "Environment"); +# +# //it.print(11, 143, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "T"); +# //it.print(11, 165, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "H"); +# //it.print(11, 187, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "VPD"); +# //it.print(11, 209, id(font_roboto_medium22), WHITE, TextAlign::LEFT, "Tdp"); +# +# ////it.printf(it.get_width() - 77, 143, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f", 0.0); +# ////it.printf(it.get_width() - 77, 165, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f", 0.0); +# ////it.printf(it.get_width() - 77, 187, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f", 0.0); +# ////it.printf(it.get_width() - 77, 209, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%.0f", 0.0); +# +# //it.printf(it.get_width() - 11, 143, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "°C"); +# //it.printf(it.get_width() - 11, 165, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "%%"); +# //it.printf(it.get_width() - 11, 187, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "kPa"); +# //it.printf(it.get_width() - 11, 209, id(font_roboto_medium22), WHITE, TextAlign::RIGHT, "°C"); +# +uart: + id: uart_co2 + tx_pin: GPIO17 + rx_pin: GPIO16 + baud_rate: 9600 + +sensor: + - platform: mhz19 + co2: + name: "MH-Z19 CO2" + id: co2value + temperature: + name: "MH-Z19 Temperatur" + id: co2temp + update_interval: 5s + automatic_baseline_calibration: false + uart_id: uart_co2 + id: my_mhz19 \ No newline at end of file