M5sTACK ATOM LITE with PbHUB and sensors: how do I set this up for ESPHOME?



  • I have a M5sTACK ATOM LITE (https://docs.m5stack.com/#/en/core/atom_lite). Via the PbHUB (https://docs.m5stack.com/en/unit/pbhub AND https://github.com/m5stack/M5Stack/tree/master/examples/Unit/PbHUB) I connect the following sensors in this order into the ports of the PbHUB:
    On CH0: TVOC/eCO2 (https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/unit/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf)
    On CH1: ENV III (https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/unit/enviii/QMP6988 Datasheet.pdf + https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/unit/SHT3x_Datasheet_digital.pdf)
    On CH2: DLight Unit (https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/hat/BH1750FVI).
    On CH3: Microphone Unit (LM393) (https://docs.m5stack.com/en/unit/mic).

    In the Home Assistant I have ESPHOME and the following YAML:
    esphome:
    name: esphome-web-06c2e0
    friendly_name: ESPHome Web 06c2e0 ATOM

    esp32:
    board: esp32dev
    framework:
    type: arduino

    logger:

    api:
    encryption:
    key: !secret

    ota:

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

    ap:
    ssid: !secret
    password: !secret

    captive_portal:

    spi:
    clk_pin: 18
    mosi_pin: 23
    miso_pin: 26

    i2c:

    • sda: 26
      scl: 32
      scan: true
      frequency: 400 kHz
      id: grove

    sensor:

    • platform: sgp30
      address: 0x58
      eco2:
      name: "eCO2"
      accuracy_decimals: 1
      id: eco2
      tvoc:
      name: "TVOC"
      accuracy_decimals: 1
      id: tvoc
      update_interval: 1s
      baseline:
      eco2_baseline: 0x86C5
      tvoc_baseline: 0x8B38

    • platform: sht3xd
      temperature:
      name: "temperature SHT30
      humidity:
      name: "humidity
      address: 0x44
      update_interval: 1s

    • platform: qmp6988
      temperature:
      name: "temperature QMP6988
      accuracy_decimals: 1
      oversampling: 16x
      id: ENVIII
      pressure:
      name: "air pressure
      oversampling: 64x
      accuracy_decimals: 1
      address: 0x61
      update_interval: 1s
      iir_filter: 2x

    • platform: bh1750
      name: "LUX
      address: 0x61
      update_interval: 1s
      address: 0x61
      update_interval: 1s

    The sensors are displayed. But the values are wrong. Here still the LOG:
    [10:53:37][C][logger:293]: Logger:
    [10:53:37][C][logger:294]: Level: DEBUG
    [10:53:37][C][logger:295]: Log Baud Rate: 115200
    [10:53:37][C][logger:296]: Hardware UART: UART0
    [10:53:37][C][spi:101]: SPI bus:
    [10:53:37][C][spi:102]: CLK Pin: GPIO18
    [10:53:37][C][spi:103]: MISO Pin: GPIO26
    [10:53:37][C][spi:104]: MOSI Pin: GPIO23
    [10:53:37][C][spi:106]: Using HW SPI: YES
    [10:53:37][C][i2c.arduino:052]: I2C Bus:
    [10:53:37][C][i2c.arduino:053]: SDA Pin: GPIO26
    [10:53:37][C][i2c.arduino:054]: SCL Pin: GPIO32
    [10:53:37][C][i2c.arduino:055]: Frequency: 400000 Hz
    [10:53:37][C][i2c.arduino:058]: Recovery: bus successfully recovered
    [10:53:37][I][i2c.arduino:068]: Results from i2c bus scan:
    [10:53:37][I][i2c.arduino:074]: Found i2c device at address 0x61
    [10:53:37][C][sgp30:220]: SGP30:
    [10:53:37][C][sgp30:221]: Address: 0x58
    [10:53:37][W][sgp30:237]: Unknown setup error!
    [10:53:37][C][sgp30:251]: Update Interval: 1.0s
    [10:53:37][C][sgp30:252]: eCO2 sensor 'eCO2'
    [10:53:37][C][sgp30:252]: Device Class: 'carbon_dioxide'
    [10:53:37][C][sgp30:252]: State Class: 'measurement'
    [10:53:37][C][sgp30:252]: Unit of Measurement: 'ppm'
    [10:53:37][C][sgp30:252]: Accuracy Decimals: 1
    [10:53:37][C][sgp30:252]: Icon: 'mdi:molecule-co2'
    [10:53:37][C][sgp30:253]: TVOC sensor 'TVOC'
    [10:53:37][C][sgp30:253]: Device Class: 'volatile_organic_compounds'
    [10:53:37][C][sgp30:253]: State Class: 'measurement'
    [10:53:37][C][sgp30:253]: Unit of Measurement: 'ppb'
    [10:53:37][C][sgp30:253]: Accuracy Decimals: 1
    [10:53:37][C][sgp30:253]: Icon: 'mdi:radiator'
    [10:53:37][C][sgp30:256]: Store baseline: YES
    [10:53:37][C][sgp30:262]: Compensation: No source configured
    [10:53:37][C][sht3xd:029]: SHT3xD:
    [10:53:37][C][sht3xd:030]: Address: 0x44
    [10:53:37][E][sht3xd:032]: Communication with SHT3xD failed!
    [10:53:37][C][sht3xd:034]: Update Interval: 1.0s
    [10:53:37][C][sht3xd:036]: Temperature 'Temperatur SHT30'
    [10:53:37][C][sht3xd:036]: Device Class: 'temperature'
    [10:53:37][C][sht3xd:036]: State Class: 'measurement'
    [10:53:37][C][sht3xd:036]: Unit of Measurement: '°C'
    [10:53:37][C][sht3xd:036]: Accuracy Decimals: 1
    [10:53:37][C][sht3xd:037]: Humidity 'Luftfeuchtigkeit'
    [10:53:37][C][sht3xd:037]: Device Class: 'humidity'
    [10:53:37][C][sht3xd:037]: State Class: 'measurement'
    [10:53:37][C][sht3xd:037]: Unit of Measurement: '%'
    [10:53:37][C][sht3xd:037]: Accuracy Decimals: 1
    [10:53:37][C][qmp6988:368]: QMP6988:
    [10:53:37][C][qmp6988:369]: Address: 0x61
    [10:53:37][C][qmp6988:373]: Update Interval: 1.0s
    [10:53:37][C][qmp6988:375]: Temperature 'Temperatur QMP6988'
    [10:53:37][C][qmp6988:375]: Device Class: 'temperature'
    [10:53:37][C][qmp6988:375]: State Class: 'measurement'
    [10:53:37][C][qmp6988:375]: Unit of Measurement: '°C'
    [10:53:37][C][qmp6988:375]: Accuracy Decimals: 1
    [10:53:37][C][qmp6988:376]: Temperature Oversampling: 16x
    [10:53:37][C][qmp6988:377]: Pressure 'Luftdruck'
    [10:53:37][C][qmp6988:377]: Device Class: 'pressure'
    [10:53:37][C][qmp6988:377]: State Class: 'measurement'
    [10:53:37][C][qmp6988:377]: Unit of Measurement: 'hPa'
    [10:53:37][C][qmp6988:377]: Accuracy Decimals: 1
    [10:53:37][C][qmp6988:378]: Pressure Oversampling: 64x
    [10:53:37][C][qmp6988:379]: IIR Filter: 2x
    [10:53:37][D][qmp6988:389]: Temperature=44.34°C, Pressure=-4106.19hPa
    [10:53:37][D][sensor:127]: 'Temperatur QMP6988': Sending state 44.33594 °C with 1 decimals of accuracy
    [10:53:38][D][sensor:127]: 'Luftdruck': Sending state -4106.18994 hPa with 1 decimals of accuracy
    [10:53:38][C][bh1750.sensor:118]: BH1750 'LUX'
    [10:53:38][C][bh1750.sensor:118]: Device Class: 'illuminance'
    [10:53:38][C][bh1750.sensor:118]: State Class: 'measurement'
    [10:53:38][C][bh1750.sensor:118]: Unit of Measurement: 'lx'
    [10:53:38][C][bh1750.sensor:118]: Accuracy Decimals: 1
    [10:53:38][C][bh1750.sensor:119]: Address: 0x61
    [10:53:38][C][bh1750.sensor:124]: Update Interval: 1.0s
    [10:53:38][C][captive_portal:088]: Captive Portal:
    [10:53:38][C][mdns:108]: mDNS:
    [10:53:38][C][mdns:109]: Hostname: esphome-web-06c2e0
    [10:53:38][C][ota:093]: Over-The-Air Updates:
    [10:53:38][C][ota:094]: Address: esphome-web-06c2e0.local:3232
    [10:53:38][C][api:138]: API Server:
    [10:53:38][C][api:139]: Address: esphome-web-06c2e0.local:6053
    [10:53:38][C][api:141]: Using noise encryption: YES
    [10:53:38][D][bh1750.sensor:159]: 'LUX': Got illuminance=28.9lx
    [10:53:38][D][sensor:127]: 'LUX': Sending state 28.86319 lx with 1 decimals of accuracy
    [10:53:38][D][qmp6988:389]: Temperature=44.34°C, Pressure=-4106.19hPa
    [10:53:38][D][sensor:127]: 'Temperatur QMP6988': Sending state 44.33594 °C with 1 decimals of accuracy
    [10:53:38][D][sensor:127]: 'Luftdruck': Sending state -4106.18994 hPa with 1 decimals of accuracy

    Have already tried a few things, but just do not get to the goal! Thanks for your help!



  • Im after help on this also.
    see here for a lead on using the hub
    https://github.com/Chill-Division/M5Stack-ESPHome/blob/main/IO Hub 1 to 6 Expansion Unit (STM32F0).md
    I would like to hire someone who can do integrations in esphome



  • @gunnm Hi!
    PbHub is for digital I/O. (like switches)
    It is not for I2C devices. (like ENVIII)
    -Terry



  • @teastain Hello
    Thank you for the feedback. But how do I get all the sensors through the ATOM? PaHub? Or are there other possibilities?



  • @gunnm I do not have any experience with ESPHOME, I use Arduino and write directly with C, C++! The PaHub (named after the 'Grove port A' I2C port in the M5Stack system) is an i2c expander. So if you have a bunch of i2c devices they can be plugged in and "polled" and read over a single i2c connection. The devices can even have the same i2c address, like having two ENV sensors, without conflict. Works very well. 'Polled' is where sensors are read one at a time and their value 'at that moment' is read and transmitted to the Atom
    The PbHub (also polled) on the other hand connects to your controller the same way, i2c, but hosts almost any 'discrete' sensor like a switch or a lamp (GPIO, PWM, Servo control, ADC sampling, RGB light control) but remember that it has to squish the signals of all those devices into one i2c channel, so some very high speed devices may jitter. Very short signals such as an encoder blip could be missed altogether, periodically.
    -Terry