Help Requested: i2c device not found

Hello,

I am trying to read a MLX90393 magnetic sensor using an ESP32 V2 feather. I was able to get the device to read using the tutorials on adafruit, which uses arduino.

I am unable to get ESPHome to find the sensor via i2c. My config is:


esphome:
  name: magnetic-sensor-feather
  friendly_name: magnetic-sensor-feather

esp32:
  board: adafruit_feather_esp32_v2
  framework:
    type: arduino

# Enable logging
logger:
    level: VERY_VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: !secret home_assistant_key

ota:
  password: !secret ota_password

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Magnetic-Sensor-Feather"
    password: !secret fallback_password

captive_portal:

i2c:
  sda: GPIO20
  scl: GPIO22
  scan: True
  id: bus_a

sensor:
  - platform: mlx90393
    id: mlx
    update_interval: 10s
    address: 0x18
    i2c_id: bus_a
    x_axis:
      name: "x"
    y_axis:
      name: "y"
    z_axis:
      name: "z"

Reading the device logs indicate no i2c devices are found:


[C][i2c.arduino:053]: I2C Bus:
[C][i2c.arduino:054]:   SDA Pin: GPIO20
[C][i2c.arduino:055]:   SCL Pin: GPIO22
[C][i2c.arduino:056]:   Frequency: 50000 Hz
[C][i2c.arduino:059]:   Recovery: bus successfully recovered
[I][i2c.arduino:069]: Results from i2c bus scan:
[I][i2c.arduino:071]: Found no i2c devices!

[VV][i2c.arduino:141]: 0x18 TX 5000
[VV][i2c.arduino:167]: TX failed: not acknowledged

Where did you get the I2C address?

I got the i2c address from Adafruit’s shop page. They mention on that page that 0x18 is used instead of 0x0C. Additionally the arduino version failed to work until I used 0x18.

  • As of May 1, 2023 - Please note that based on chip shortages we are now shipping with default ‘base’ address of 0x18 not 0x0C

Are you sure GPIO20 is correct?

1 Like

@Mahko_Mahko indeed. I must have misread and swapped the SDA and SCL values. Thank you.

1 Like