esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

ESPHome ADS1115 esp-idf multiplexer wrong values #5045

Open cho0p opened 8 months ago

cho0p commented 8 months ago

The problem

I'm trying to measure two different voltages but the ESP32 or ESPHome is mixing up the values with different multiplexer configs.

The first voltage via multiplexer: 'A0_A1' The second voltage via multiplexer: 'A2_A3'

The measured values are not correctly mapped.

I have removed the cable from the ADS1115 on Pin A2 and A3 and the ESP32 is still showing values from the A0 and A1 measurement on that Sensor/multiplexer config.

When you have a look at the config and the corresponding log you can already see that it doesn't make any sense.

Same in the UI/frontend. "Akku Spannung" and "Akku Spannung Internal" should be equal while "ESP32 Spannung" should be 0.

image

Which version of ESPHome has the issue?

2023.10.3

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

core-2023.10.1

What platform are you using?

ESP32-IDF

Board

No response

Component causing the issue

ads1115/i2c

Example YAML snippet

esphome:

  name: esp32_solar_lte

esp32:
  board: nodemcu-32s 
  framework:
    type: esp-idf
    version: recommended

wifi:

  ssid: " "
  password: " "
  power_save_mode: none
  fast_connect: true
  reboot_timeout: 15min

  manual_ip:

    static_ip: 192.168.6.2
    gateway: 192.168.6.1
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 192.168.6.1

logger:

ota:

switch:
  - platform: restart
    name: "restart_button"
    id: restart_button

time:
  - platform: sntp
    id: sntp_time
    timezone: Europe/Berlin
    on_time:
      - seconds: 0
        minutes: 0
        hours: 12
        days_of_week: MON-SUN
        then:
          - switch.toggle: restart_button 

i2c:

  sda: GPIO21
  scl: GPIO22
  scan: true
  setup_priority: -100.0

ads1115:

  - address: 0x48
    continuous_mode: true
    setup_priority: -100.0

sensor:

  - platform: wifi_signal
    name: "ESP32 Solar LTE"
    update_interval: 300s 

  - platform: ads1115
    multiplexer: 'A0_A1'
    gain: 6.144
    name: "Akku Spannung Internal"
    accuracy_decimals: 2
    update_interval: 5s
    unit_of_measurement: "V"

  - platform: ads1115
    multiplexer: 'A0_A1'
    gain: 6.144
    name: "Akku Spannung"
    accuracy_decimals: 2
    update_interval: 5s
    unit_of_measurement: "V"

  - platform: ads1115
    multiplexer: 'A2_A3'
    gain: 6.144
    name: "ESP32 Spannung"
    accuracy_decimals: 2
    update_interval: 5s
    unit_of_measurement: "V"

Anything in the logs that might be useful for us?

[20:16:16][C][i2c.idf:061]: I2C Bus:
[20:16:16][C][i2c.idf:062]:   SDA Pin: GPIO21
[20:16:16][C][i2c.idf:063]:   SCL Pin: GPIO22
[20:16:16][C][i2c.idf:064]:   Frequency: 50000 Hz
[20:16:16][C][i2c.idf:067]:   Recovery: bus successfully recovered
[20:16:16][I][i2c.idf:077]: Results from i2c bus scan:
[20:16:16][I][i2c.idf:083]: Found i2c device at address 0x48
[20:16:16][C][ads1115:073]: Setting up ADS1115...
[20:16:16][C][ads1115:074]:   Address: 0x48
[20:16:16][C][ads1115:080]:   Sensor 'Akku Spannung Internal'
[20:16:16][C][ads1115:080]:     Device Class: 'voltage'
[20:16:16][C][ads1115:080]:     State Class: 'measurement'
[20:16:16][C][ads1115:080]:     Unit of Measurement: 'V'
[20:16:16][C][ads1115:080]:     Accuracy Decimals: 2
[20:16:16][C][ads1115:081]:     Multiplexer: 0
[20:16:16][C][ads1115:082]:     Gain: 0
[20:16:16][C][ads1115:083]:     Resolution: 16
[20:16:16][C][ads1115:080]:   Sensor 'Akku Spannung'
[20:16:16][C][ads1115:080]:     Device Class: 'voltage'
[20:16:16][C][ads1115:080]:     State Class: 'measurement'
[20:16:16][C][ads1115:080]:     Unit of Measurement: 'V'
[20:16:16][C][ads1115:080]:     Accuracy Decimals: 2
[20:16:16][C][ads1115:081]:     Multiplexer: 0
[20:16:16][C][ads1115:082]:     Gain: 0
[20:16:16][C][ads1115:083]:     Resolution: 16
[20:16:16][C][ads1115:080]:   Sensor 'ESP32 Spannung'
[20:16:16][C][ads1115:080]:     Device Class: 'voltage'
[20:16:16][C][ads1115:080]:     State Class: 'measurement'
[20:16:16][C][ads1115:080]:     Unit of Measurement: 'V'
[20:16:16][C][ads1115:080]:     Accuracy Decimals: 2
[20:16:16][C][ads1115:081]:     Multiplexer: 3
[20:16:16][C][ads1115:082]:     Gain: 0
[20:16:16][C][ads1115:083]:     Resolution: 16

[20:16:17][D][ads1115:186]: 'Akku Spannung Internal': Got Voltage=3.493313V
[20:16:17][D][sensor:094]: 'Akku Spannung Internal': Sending state 3.49331 V with 2 decimals of accuracy

[20:16:19][D][ads1115:186]: 'Akku Spannung': Got Voltage=3.492750V
[20:16:19][D][sensor:094]: 'Akku Spannung': Sending state 3.49275 V with 2 decimals of accuracy

[20:16:19][D][ads1115:186]: 'ESP32 Spannung': Got Voltage=3.492000V
[20:16:19][D][sensor:094]: 'ESP32 Spannung': Sending state 3.49200 V with 2 decimals of accuracy

[20:16:22][D][ads1115:186]: 'Akku Spannung Internal': Got Voltage=-0.000375V
[20:16:22][D][sensor:094]: 'Akku Spannung Internal': Sending state -0.00038 V with 2 decimals of accuracy

[20:16:24][D][ads1115:186]: 'Akku Spannung': Got Voltage=3.492938V
[20:16:24][D][sensor:094]: 'Akku Spannung': Sending state 3.49294 V with 2 decimals of accuracy

[20:16:24][D][ads1115:186]: 'ESP32 Spannung': Got Voltage=3.492188V
[20:16:24][D][sensor:094]: 'ESP32 Spannung': Sending state 3.49219 V with 2 decimals of accuracy

[20:16:27][D][ads1115:186]: 'Akku Spannung Internal': Got Voltage=-0.000562V
[20:16:27][D][sensor:094]: 'Akku Spannung Internal': Sending state -0.00056 V with 2 decimals of accuracy

[20:16:29][D][ads1115:186]: 'Akku Spannung': Got Voltage=3.491062V
[20:16:29][D][sensor:094]: 'Akku Spannung': Sending state 3.49106 V with 2 decimals of accuracy

[20:16:29][D][ads1115:186]: 'ESP32 Spannung': Got Voltage=3.493875V
[20:16:29][D][sensor:094]: 'ESP32 Spannung': Sending state 3.49388 V with 2 decimals of accuracy

[20:16:32][D][ads1115:186]: 'Akku Spannung Internal': Got Voltage=-0.000375V
[20:16:32][D][sensor:094]: 'Akku Spannung Internal': Sending state -0.00038 V with 2 decimals of accuracy

[20:16:34][D][ads1115:186]: 'Akku Spannung': Got Voltage=3.493125V
[20:16:34][D][sensor:094]: 'Akku Spannung': Sending state 3.49312 V with 2 decimals of accuracy

[20:16:34][D][ads1115:186]: 'ESP32 Spannung': Got Voltage=3.494062V
[20:16:34][D][sensor:094]: 'ESP32 Spannung': Sending state 3.49406 V with 2 decimals of accuracy

Additional information

No response

ssieb commented 8 months ago

Why are you using continuous mode? Try the external component config from https://github.com/esphome/issues/issues/4890#issuecomment-1726646700 and see what happens.

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.