All,
I have a setup with ESPHome for reading 8 channels of temperatrure data out of a SHT45 Temperature and Humidity Sensor.
Because the sensor has a fixed I2C address I use the TCA9548A I²C Multiplexer to address the 8 sensors connected to the multiplexer.
What wonders me, is, that the reading order is not channel 0,1,2…7 with a constant fixed timing interval, instead the sensors are read in a order (see log) 2,6,3,4,5,0,7,1 with time gaps of 1-6 seconds.
Can someone help me
1.) to defined the reading order
2.) control the timing between the reading to be äquidistant?
Many thanks,
Rainer
INFO ESPHome 2024.11.1
INFO Reading configuration /config/esphome/i2clogger.yaml...
INFO Starting log output from 192.168.1.180 using esphome API
INFO Successfully connected to i2clogger @ 192.168.1.180 in 0.082s
INFO Successful handshake with i2clogger @ 192.168.1.180 in 0.113s
[15:29:41][I][app:100]: ESPHome version 2024.10.3 compiled on Nov 16 2024, 15:26:11
[15:29:41][C][wifi:600]: WiFi:
[15:29:41][C][wifi:428]: Local MAC: 88:13:BF:09:18:5C
[15:29:41][C][wifi:433]: SSID: '217x205'[redacted]
[15:29:41][C][wifi:436]: IP Address: 192.168.1.180
[15:29:41][C][wifi:440]: BSSID: E0:28:6D:68:58:E8[redacted]
[15:29:41][C][wifi:441]: Hostname: 'i2clogger'
[15:29:41][C][wifi:443]: Signal strength: -58 dB ▂▄▆█
[15:29:41][C][wifi:447]: Channel: 6
[15:29:41][C][wifi:448]: Subnet: 255.255.255.0
[15:29:41][C][wifi:449]: Gateway: 192.168.1.1
[15:29:41][C][wifi:450]: DNS1: 192.168.1.1
[15:29:41][C][wifi:451]: DNS2: 0.0.0.0
[15:29:41][C][logger:185]: Logger:
[15:29:41][C][logger:186]: Level: DEBUG
[15:29:41][C][logger:188]: Log Baud Rate: 115200
[15:29:41][C][logger:189]: Hardware UART: UART0
[15:29:41][C][i2c.arduino:071]: I2C Bus:
[15:29:41][C][i2c.arduino:072]: SDA Pin: GPIO21
[15:29:41][C][i2c.arduino:073]: SCL Pin: GPIO22
[15:29:41][C][i2c.arduino:074]: Frequency: 1000 Hz
[15:29:41][C][i2c.arduino:086]: Recovery: bus successfully recovered
[15:29:41][I][i2c.arduino:096]: Results from i2c bus scan:
[15:29:41][I][i2c.arduino:102]: Found i2c device at address 0x70
[15:29:41][C][tca9548a:037]: TCA9548A:
[15:29:41][C][tca9548a:038]: Address: 0x70
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][sht4x:050]: Address: 0x44
[15:29:41][C][captive_portal:089]: Captive Portal:
[15:29:41][C][mdns:116]: mDNS:
[15:29:41][C][mdns:117]: Hostname: i2clogger
[15:29:41][C][esphome.ota:073]: Over-The-Air updates:
[15:29:41][C][esphome.ota:074]: Address: i2clogger.local:3232
[15:29:41][C][esphome.ota:075]: Version: 2
[15:29:41][C][esphome.ota:078]: Password configured
[15:29:41][C][safe_mode:018]: Safe Mode:
[15:29:41][C][safe_mode:020]: Boot considered successful after 60 seconds
[15:29:41][C][safe_mode:021]: Invoke after 10 boot attempts
[15:29:41][C][safe_mode:023]: Remain in safe mode for 300 seconds
[15:29:41][C][api:140]: API Server:
[15:29:41][C][api:141]: Address: i2clogger.local:6053
[15:29:41][C][api:143]: Using noise encryption: YES
[15:29:59][D][sensor:094]: 'Temperatur Kanal 2': Sending state 21.92645 °C with 2 decimals of accuracy
[15:29:59][D][sensor:094]: 'Feuchtigkeit Kanal 2': Sending state 50.24285 % with 2 decimals of accuracy
[15:29:59][D][sensor:094]: 'Temperatur Kanal 6': Sending state 21.42977 °C with 2 decimals of accuracy
[15:29:59][D][sensor:094]: 'Feuchtigkeit Kanal 6': Sending state 52.07584 % with 2 decimals of accuracy
[15:30:00][D][sensor:094]: 'Temperatur Kanal 3': Sending state 22.11070 °C with 2 decimals of accuracy
[15:30:00][D][sensor:094]: 'Feuchtigkeit Kanal 3': Sending state 52.24369 % with 2 decimals of accuracy
[15:30:00][D][sensor:094]: 'Temperatur Kanal 4': Sending state 21.46449 °C with 2 decimals of accuracy
[15:30:00][D][sensor:094]: 'Feuchtigkeit Kanal 4': Sending state 50.63958 % with 2 decimals of accuracy
[15:30:01][D][sensor:094]: 'Temperatur Kanal 5': Sending state 21.83032 °C with 2 decimals of accuracy
[15:30:01][D][sensor:094]: 'Feuchtigkeit Kanal 5': Sending state 50.17800 % with 2 decimals of accuracy
[15:30:07][D][sensor:094]: 'Temperatur Kanal 0': Sending state 21.72083 °C with 2 decimals of accuracy
[15:30:07][D][sensor:094]: 'Feuchtigkeit Kanal 0': Sending state 50.56138 % with 2 decimals of accuracy
[15:30:07][D][sensor:094]: 'Temperatur Kanal 7': Sending state 21.81163 °C with 2 decimals of accuracy
[15:30:07][D][sensor:094]: 'Feuchtigkeit Kanal 7': Sending state 50.70253 % with 2 decimals of accuracy
[15:30:08][D][sensor:094]: 'Temperatur Kanal 1': Sending state 21.56863 °C with 2 decimals of accuracy
[15:30:08][D][sensor:094]: 'Feuchtigkeit Kanal 1': Sending state 53.15351 % with 2 decimals of accuracy
ESPHome YAML
esphome:
name: i2clogger
friendly_name: I2CLogger
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: <>
ota:
- platform: esphome
password: <>
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "I2Clogger Fallback Hotspot"
password: <>
captive_portal:
# https://esphome.io/components/i2c
# https://lastminuteengineers.com/esp32-pinout-reference/
i2c:
- id: i2c0
sda: GPIO21
scl: GPIO22
scan: true
frequency: 1.0kHz # 10 kHz min freq
# https://esphome.io/components/tca9548a
# Address: 0x70
tca9548a:
- address: 0x70
id: multiplex0
i2c_id: i2c0
channels:
- bus_id: multiplex0channel_0
channel: 0
- bus_id: multiplex0channel_1
channel: 1
- bus_id: multiplex0channel_2
channel: 2
- bus_id: multiplex0channel_3
channel: 3
- bus_id: multiplex0channel_4
channel: 4
- bus_id: multiplex0channel_5
channel: 5
- bus_id: multiplex0channel_6
channel: 6
- bus_id: multiplex0channel_7
channel: 7
# https://github.com/esphome/esphome-docs/blob/d9e8baafd3a9cb21472d29aa7b594e63f7a839b1/components/sensor/sht4x.rst
# Address 0x44
sensor:
# ------------- Kanal 0 -----------------
- platform: sht4x
i2c_id: multiplex0channel_0
update_interval: 30s
temperature:
name: "Temperatur Kanal 0"
id: Temperatur_Kanal_0
humidity:
name: "Feuchtigkeit Kanal 0"
id: Feuchtigkeit_Kanal_0
# # ------------- Kanal 1 -----------------
- platform: sht4x
i2c_id: multiplex0channel_1
update_interval: 30s
temperature:
name: "Temperatur Kanal 1"
id: Temperatur_Kanal_1
humidity:
name: "Feuchtigkeit Kanal 1"
id: Feuchtigkeit_Kanal_1
# ------------- Kanal 2 -----------------
- platform: sht4x
i2c_id: multiplex0channel_2
update_interval: 30s
temperature:
name: "Temperatur Kanal 2"
id: Temperatur_Kanal_2
humidity:
name: "Feuchtigkeit Kanal 2"
id: Feuchtigkeit_Kanal_2
# ------------- Kanal 3 -----------------
- platform: sht4x
i2c_id: multiplex0channel_3
update_interval: 30s
temperature:
name: "Temperatur Kanal 3"
id: Temperatur_Kanal_3
humidity:
name: "Feuchtigkeit Kanal 3"
id: Feuchtigkeit_Kanal_3
# ------------- Kanal 4 -----------------
- platform: sht4x
i2c_id: multiplex0channel_4
update_interval: 30s
temperature:
name: "Temperatur Kanal 4"
id: Temperatur_Kanal_4
humidity:
name: "Feuchtigkeit Kanal 4"
id: Feuchtigkeit_Kanal_4
# ------------- Kanal 5 -----------------
- platform: sht4x
i2c_id: multiplex0channel_5
update_interval: 30s
temperature:
name: "Temperatur Kanal 5"
id: Temperatur_Kanal_5
humidity:
name: "Feuchtigkeit Kanal 5"
id: Feuchtigkeit_Kanal_5
# ------------- Kanal 6 -----------------
- platform: sht4x
i2c_id: multiplex0channel_6
update_interval: 30s
temperature:
name: "Temperatur Kanal 6"
id: Temperatur_Kanal_6
humidity:
name: "Feuchtigkeit Kanal 6"
id: Feuchtigkeit_Kanal_6
# ------------- Kanal 7 -----------------
- platform: sht4x
i2c_id: multiplex0channel_7
update_interval: 30s
temperature:
name: "Temperatur Kanal 7"
id: Temperatur_Kanal_7
humidity:
name: "Feuchtigkeit Kanal 7"
id: Feuchtigkeit_Kanal_7