A Calustra - Eloy Coto Pereiro Home About Books

Playing with ESPHome, how to read compost bin temperature

on

Have you heard of ESPHome? It is one of the projects which understand how important is user experience in any project, especially in an open-source project. ESP ecosystem is growing, and there are a bunch of projects out there that simplify complex tasks

Personally, I'm not a big fan of proprietary firmware of ESP32, and I like the alternative projects out there. On the other hand, the RISC-V devices are just great and have impressive RTOS support.

In the past, I always used Tasmota firmware. However, the other day, I needed to make a more complex project which reads the compost bin temperature and reports it over MQTT. The project is based on a ESP32 with an NTC thermistor.

While I could gone with Rust embedded, I decided to give ESPhome a try! All that took was ~2 hours, the following yaml and running esphome run command:

esp32:
  board: nodemcu-32s2
  variant: esp32s2
  framework:
    type: arduino

# Logger must be at least debug (default)
logger:
  level: DEBUG

web_server:
  port: 80

wifi:
  ssid: "SSID"
  password: "PASSWORD"

  ap:
    ssid: "compostbin"
    password: "compostbin"

captive_portal:

mqtt:
  broker: my-mqtt-broker
  username: compostbin
  password: compostbin

sensor:

  - platform: ntc
    sensor: resistance_sensor
    name: NTC Temperature B Constant
    calibration:
     b_constant: 3950
     reference_temperature: 25°C
     reference_resistance: 10kOhm

  - platform: resistance
    id: resistance_sensor
    sensor: source_sensor
    configuration: DOWNSTREAM
    resistor: 10kOhm
    reference_voltage: 3.3V
    name: Resistance Sensor

  - platform: adc
    id: source_sensor
    name: ADC Voltage
    filters:
      - offset:  +0.14
      - multiply: 3.3
    pin: 1
    update_interval: 5s

 deep_sleep:
   run_duration: 15s
   sleep_duration: 180min

With ESPHome, setting up this project was quick. The YAML configuration encapsulates everything needed, from defining sensors to configuring Wi-Fi and MQTT. Plus, the deep sleep feature ensures efficient power usage for battery-operated setups. For complex scenarios, I really love the lambda calls and the C++ code in it.

P.S. While I don't have an immediate need to monitor the compost bin temperature, I discovered that if the temperature exceeds 70 degrees, it helps eliminate salmonella, making the compost bin safer.

Tags

Related articles: