Tag: esphome

  • A beelogger on ESP32 basis, part 4: Test setup: The rain sensor

    I bought a rain gauge from china, just google “rain gauge sensor aliexpress” for the product, it was round about 15€.

    For my test-setup, I simply cut off the connector and connected the wires directly to GND and GPIO4 and used the internal pull-up resistor:

    Adding it to esphome is straight forward and easy. I’m using the pulse counter component, it can use the pulse counter peripheral of the ESP32 and can work in standby-modes:

    substitutions:
      update_interval: 5s
    
    sensors:
     - platform: pulse_counter
        name: "Rainfall Pulse Counter"
        id: rainfall_pulse_counter
        use_pcnt: true
        count_mode: 
          falling_edge: INCREMENT
          rising_edge: DISABLE
        pin:
          number: GPIO4
          inverted: true
          mode:
            input: true
            pullup: true
        unit_of_measurement: "mm"
        icon: "mdi:water"
        update_interval: ${update_interval}
        filters:
          - multiply: 0.367
          - debounce: 10ms
        total:
          name: "Rainfall Total Pulses"

    The value “0.367” is explained here:
    https://community.home-assistant.io/t/how-to-measure-integration-of-rain-pulse-counter-into-daily-value/136709

    Then I created two utility meters that convert it to a daily and hourly basis within homeassistant like this:


  • A beelogger on ESP32 basis, part 3: Test setup: The scale

    I built two bee-hive scales according to the great instructions of the Beelogger project.

    Remarks:

    • I used the “2 holes per side”-variant of the Load Cell Sensor (CZL601 instead of the CZL601-AC), it works fine too.

    In my test-setup I connected it like this:

    There are 2 possible solutions for this problem, I don’t know yet which way to go:

    • exchanging some resistors on the hx711-breakout-board
    • use another breakout board that doesn’t cause that much problems, I ordered a NAU7802-breakout-board for testing.


    For calibrating, I used weight-lifting weights.

    The code for esphome to use it:

    substitutions:
      update_interval: 5s
    
    sensor:
      - platform: hx711
        name: "HX711 Weight"
        dout_pin: GPIO4
        clk_pin: GPIO5
        gain: 128
        update_interval: ${update_interval}
        filters:
          - calibrate_linear:
              datapoints:
              # measuring at 25 °C
              -  77915  -> 0
              -  167520 -> 4.08    # empty super + tension belt
              -  205782 -> 5.88    # super with empty frames + tension belt
              -  308103 -> 9.08    # super with empty frames + tension belt + 5kg
              -  413973 -> 14.08   # super with empty frames + tension belt + 10kg
              -  517992 -> 19.08   # super with empty frames + tension belt + 15kg
              -  630596 -> 24.08   # super with empty frames + tension belt + 20kg
              -  734680 -> 29.08   # super with empty frames + tension belt + 25kg
              -  836741 -> 34.08   # super with empty frames + tension belt + 30kg
              -  939262 -> 39.08   # super with empty frames + tension belt + 35kg
              - 1047388 -> 44.08   # super with empty frames + tension belt + 40kg
              - 1149025 -> 49.08   # super with empty frames + tension belt + 45kg
              - 1251903 -> 54.08   # super with empty frames + tension belt + 50kg
              - 1353236 -> 59.08   # super with empty frames + tension belt + 55kg
              - 1450079 -> 64.08   # super with empty frames + tension belt + 60kg
              - 1554032 -> 69.08   # super with empty frames + tension belt + 65kg
              - 1655332 -> 74.08   # super with empty frames + tension belt + 70kg
          - clamp:
              min_value: 0
              ignore_out_of_range: true

    Compensating the temperature drift of the scale is still an open TODO.

  • A beelogger on ESP32 basis, part 2: Test setup: The basic sensors

    I’m still unsure which sensors to use in production, so I started experimenting:

    I connected a bmp085, a waterproof bh1750, a Si7021 and a bme280 via I2C. Two DS18B20s that will be built in in the lid of the hive and into its center are connected via 1-wire.



    In my test-setup, I connected it like this:


    The code I used for the sensors:

    substitutions:
      update_interval: 5s
      
    i2c:
      sda: GPIO35
      scl: GPIO36
      scan: true
    
    one_wire:
      - platform: gpio
        pin: GPIO04
    
    sensor:
      - platform: htu21d
        model: SI7021
        temperature:
          name: "SI7021 Temperature"
        humidity:
          name: "SI7021 Humidity"
        heater:
          name: "SI7021 Heater"
        address: 0x40
        update_interval: ${update_interval}
      - platform: bmp085
        temperature:
          name: "BMP085 Temperature"
        pressure:
          name: "BMP085 Pressure"
        address: 0x77
        update_interval: ${update_interval}
      - platform: bme280_i2c
        temperature:
          name: "BME280 Temperature"
        pressure:
          name: "BME280 Pressure"
        humidity:
          name: "BME280 Humidity"
        address: 0x76
        update_interval: ${update_interval}
      - platform: dallas_temp
        name: "DS18B20 Temperature 1"
        address: 0xcb000000513fb228
        update_interval: ${update_interval}
      - platform: dallas_temp
        name: "DS18B20 Temperature 2"
        address: 0x6f000000bcc72128
        update_interval: ${update_interval}
      - platform: bh1750
        name: "BH1750 Illuminance"
        address: 0x23
        update_interval: ${update_interval}
  • A beelogger on ESP32 basis, part 1: The idea

    The Beelogger project is really great.

    But: Since my house is automated with homeassistant, esphome, a lot of ESP32s and my bee-hives are in WIFI-range, I decided to rebuild the beelogger-functionality on esphome basis.

    Additional arguments for realizing it with an ESP32 instead of an Arduino or STM32 might be:

    • more CPU power
    • more RAM & flash (up to 8 MB RAM & 16 MB flash)
    • integrated WIFI
    • probably less power consumption when using deep sleep modes
    • A DSP for audio analysis
    • more ADCs with higher resolution (depending on the ESP32 variant used)
    • a built-in RTC
    • the comfort of esphome:
      • OTA updates
      • a built-in automated connection to homeassistant
      • a webinterface on the device
      • no complex sketches to maintain, just a .yaml-config

    Desicion: I’m going to use an ESP32-S3-N16R8

    It provides:

    • a dual-core 32-bit microprocessor with 240 MHz
    • 8MB of additional PSRAM and 16MB flash,
    • 2.4 GHz Wi-Fi (IEEE 802.11b/g/n) and Bluetooth® 5 (LE)
    • An hardware RTC
    • Two general-purpose SPI ports
    • Three UARTs
    • Two I2Cs
    • Two I2Ss
    • Pulse counter
    • Two 12-bit SAR ADCs, up to 20 channels
    • Four 54-bit general-purpose timers
    • 52-bit system timer
    • Three watchdog timers
    • DSP-hardware
    • Four power modes designed for typical scenarios: Active, Modem-sleep, Light-sleep, Deep-sleep
    • A lot of GPIOs 🙂

    It’s the currently most powerfull ESP32, its hardware should be more than enough for the task 😀

    Realizing it will be a major project, but probably also a lot of fun 🙂

    The TODOs I see so far, I’ll realize them in single test projects:

    • get all the desired sensors working properly
    • write an external component for esphome for the audio-analysis
    • write a component for esphome for the bee counter hardware
    • write a component for esphome to connect to the beelogger-server
    • care about the power management
    • logging to SD-card/flash
    • properly wiring it all up at the end, making it electronically fail safe, soldering it onto a prototype-board
    • install everything in proper cases with proper connectors and install it in a bee hive
    • realize additional ideas, they will for sure come up when working on this project 😉