Configuring M5Stack AtomS3 and MLX90640 Thermal Imager

I’m trying to configure an AtomS3 (with the LCD) and the MLX90640 Thermal unit (m5-docs) in ESPHome, using Chill-Division’s custom component (M5Stack-ESPHome/Thermal Camera Unit (MLX90640).md at 926ca7b10b82df20872bbf22a2cf2f8d11cd30bc · Chill-Division/M5Stack-ESPHome · GitHub), but I’m not having much success.

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

external_components:
  - source:
      type: git
      url: https://github.com/chill-Division/M5Stack-ESPHome/
      ref: main
    components: camera_mlx90640

i2c:
  - id: bus_a
    sda: GPIO38
    scl: GPIO39
    scan: true
  - id: grove
    sda: GPIO1
    scl: GPIO2
    scan: true

camera_mlx90640:
  id: thermal_cam
  update_interval: 5s
  sda: 1  # I2C SDA PIN
  scl: 2  # I2C SCL PIN
  frequency: 400000  # I2C Clock Frequency
  address: 0x33 # MLX90640 Address
  mintemp: 15 # Minimal temperature for color mapping
  maxtemp: 40 # Maximal temperature for color mapping
  refresh_rate: 0x04 # 0x05 For 16Hz or 0x04 for 8Hz
  min_temperature:
      name: "MLX90640 Min temp"
  max_temperature:
      name: "MLX90640 Max temp"
  mean_temperature:
      name: "MLX90640 Mean temp"
  median_temperature:
      name: "MLX90640 Median temperature"

I’ve swapped the yellow and grey wires in the grove cable to get SDA and SCL in the right positions. The I2C scan is showing a device with address 0x33 on GPIO1 and 2, with a frequency of 50000. (I’ve tried changing the frequency value, above from 400000 to 50000, but it makes no difference).

The log shows “[E] [MLX90640:206] The sensor is not connected”

@Chilling_Silence or anyone else, any clues?

Update: I got the thermal imager working with an Atom S3 Lite instead.

Hi, Just wondering what you changed to get this working with the AtomS3 Lite? I have so far had no luck

The first thing I needed to do was swap a couple of pins on the grove connector. You’ll noticed that the pins on the AtomS3 Lite are not in the standard order. From memory the yellow and white need to be swapped at one end of the cable.

Here’s the code I’m using. I didn’t fully clean up once I got it working, so there might be some elements there you don’t want or need:

esphome:
  name: atom-s3-lite-thermal-cam
  friendly_name: "Thermal Camera"
  platformio_options:
    build_flags:
      - "-w" # https://docs.platformio.org/en/latest/projectconf/sections/env/options/build/build_flags.html
  libraries:
    - FS
    - Wire
    - SPIFFS

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

web_server:
  port: 80

# Enable logging
logger:
# level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "####"

ota:
  password: "####"
  platform: esphome

wifi:
  ssid: ####
  password: ####
  fast_connect: true
  ap:
    ssid: "Atom-S3-Lite-1 Fallback Hotspot"
    password: "####"

captive_portal:

improv_serial:

#G4=IR
remote_transmitter:
  pin: GPIO4
  carrier_duty_percent: 50%

light:
  #G35=RGB WS2812C-2020
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: 35
    num_leds: 4
    # RMT 0 channels will be occupied by IR
    rmt_channel: 1
    chipset: ws2812
    id: led
    name: "Led"

#G41=Button
binary_sensor:
  - platform: gpio
    name: Button
    pin:
      number: GPIO41
      inverted: true
      mode:
        input: true
        pullup: true
    filters:
      - delayed_off: 10ms
    on_press:
      then:
        - logger.log: Button Pressed

external_components:
  - source:
      type: git
      url: https://github.com/chill-Division/M5Stack-ESPHome/
      ref: main
    components: camera_mlx90640

i2c:
  - id: grove
    sda: GPIO1
    scl: GPIO2
    scan: true

text_sensor:

sensor:

camera_mlx90640:
  id: thermal_cam
  update_interval: 20s
  sda: 1  # I2C SDA PIN
  scl: 2  # I2C SCL PIN
  frequency: 400000  # I2C Clock Frequency
  address: 0x33 # MLX90640 Address
  mintemp: 15 # Minimal temperature for color mapping
  maxtemp: 40 # Maximal temperature for color mapping
  refresh_rate: 0x04 # 0x05 For 16Hz or 0x04 for 8Hz
  min_temperature:
      name: "Minimum"
  max_temperature:
      name: "Maximum"
  mean_temperature:
      name: "Mean"
  median_temperature:
      name: "Median"

Mine’s been working reliably since December. I have it over a lizard enclosure, managing two heat lamps on Shelly dimmers, placed at one end of the enclosure. Every 5 minutes it checks the temperature and adjusts the heat lamps up or down to maintain the correct maximum temperature.

Ok interesting, I have tried your setup and swapped the pins (This can be done in the yaml by simply changing the sda and scl pin assignment, does not need to be a physical swap)

However i am getting a constant issue with any device i run this on it seems to trigger the ‘watchdog’

[14:18:26]E (17058) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
[14:18:26]E (17058) task_wdt: - loopTask (CPU 1)
[14:18:26]E (17058) task_wdt: Tasks currently running:
[14:18:26]E (17058) task_wdt: CPU 0: IDLE
[14:18:26]E (17058) task_wdt: CPU 1: loopTask
[14:18:26]E (17058) task_wdt: Aborting.

Any device? So the S3 Lite works on its own, but gets the above error as soon as a device is connected? I don’t believe I’ve seen a Task Watchdog message. Sorry I can’t be more help.

Good to know. After failing with the Atom S3 (the camera was detected, but not responding) I wasn’t going to take any chances.

Ok so i figured out the issue, I have a thermal 2 not the original thermal, I will try get the original m5stack MLX90640 and try again