M5Stick - axp192 no longer working since upgrading to ESPHome 2022.3.0 - 16th March 2022

Hello, I have several M5 products, M5StickC, M5StickCPlus. M5Though, M5Core2 that need the APX192 in the custom_components to work and since the latest upgrades I have been getting these errors, however the library is still located in the custom_components…

INFO Reading configuration /config/esphome/m5stick1.yaml…
ERROR Unable to load component axp192.sensor:
Traceback (most recent call last):
File “/esphome/esphome/loader.py”, line 162, in _lookup_module
module = importlib.import_module(f"esphome.components.{domain}")
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 790, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/config/esphome/custom_components/axp192/sensor.py”, line 16, in
sensor.sensor_schema(UNIT_PERCENT, ICON_BATTERY, 1).extend({
TypeError: sensor_schema() takes from 0 to 1 positional arguments but 3 were given
INFO Detected timezone ‘America/Toronto’
WARNING GPIO15 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
Failed config

sensor.axp192: [source /config/esphome/m5stick1.yaml:139]

Platform not found: ‘sensor.axp192’.
platform: axp192
address: 52
i2c_id: bus_b
update_interval: 30s
battery_level:
name: m5stick1_Bat
id: m5stick1_batterylevel

I’m stumped, I restarted the ESPHome addon, restarted the host…
Anyone else experiencing this?

Latest is not a version.

We would need your yaml.

Thanks. Here is one of them:

esphome:
name: shed
platform: ESP32
board: m5stick-c

Enable logging

logger:

Enable Home Assistant API

api:

ota:
password:

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

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Shed Fallback Hotspot”
password: !secret apoint_password

captive_portal:

time:

  • platform: homeassistant
    id: homeassistant_time

font:
#- file: “fonts/ArchitectsDaughter.ttf” *
#- file: "fonts/Courier Prime Code Italic.ttf "
#- file: “fonts/MicroFLF.ttf” *
#- file: “fonts/SciFly-Sans.ttf” *
#- file: “fonts/Ubuntu-R.ttf” *
#- file: “fonts/arial.ttf” *
#- file: “fonts/atomicage-regular” *
#- file: “fonts/codystar-regular.ttf” *
#- file: “fonts/Electrolize-Regular.ttf” *
#- file: “fonts/COMPUTER LOVE.ttf” * increase size
#- file: “fonts/CaviarDreams.ttf” **
#- file: “fonts/LANENAR_.ttf” *
#- file: “fonts/.ttf”
#- file: “fonts/.ttf”

  • file: “fonts/CaviarDreams.ttf”
    id: myfont_10
    size: 10

  • file: “fonts/CaviarDreams.ttf”
    id: myfont_20
    size: 20

color:

  • id: my_red
    red: 100%
    green: 0%
    blue: 0%

  • id: my_blue
    red: 0%
    green: 0%
    blue: 100%

  • id: my_green
    red: 0%
    green: 100%
    blue: 0%

  • id: my_white
    red: 100%
    green: 100%
    blue: 100%

  • id: my_gray
    red: 50%
    green: 50%
    blue: 50%

  • id: my_yellow
    red: 100%
    green: 100%
    blue: 0%

  • id: my_orange
    red: 100%
    green: 30%
    blue: 0%

spi:
clk_pin: GPIO13
mosi_pin: GPIO15

i2c:

  • id: bus_a
    sda: GPIO0
    scl: GPIO26
    scan: true

  • id: bus_b
    sda: GPIO21
    scl: GPIO22
    scan: true

output:

  • platform: gpio
    pin: GPIO10
    id: gpio_10

binary_sensor:

  • platform: gpio
    pin: GPIO36
    id: shed_pir_sensor
    name: “Shed PIR Sensor”
    device_class: motion
    on_press:
    then:
    output.turn_off: gpio_10
    on_release:
    then:
    output.turn_on: gpio_10

sensor:

AXP192 power management - must be present to initialize TFT power on

  • platform: axp192
    address: 0x34
    i2c_id: bus_b
    update_interval: 30s
    battery_level:
    id: “shed_m5_battery_level”
    name: “Shed m5 Bat”

  • platform: bh1750
    id: “shed_illuminance”
    name: “Shed Illuminance”
    i2c_id: bus_a
    address: 0x23
    #measurement_duration: 69
    update_interval: 30s

  • platform: bmp280
    pressure:
    id: shed_pressure
    name: “Shed Pressure”
    i2c_id: bus_a
    address: 0x76
    update_interval: 60s

  • platform: ina219
    i2c_id: bus_a
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
    id: “shed_solar_panel_current”
    name: “Solar Panel Battery Current”
    power:
    id: “shed_solar_panel_power”
    name: “Solar Panel Battery Power”
    bus_voltage:
    id: “shed_solar_panel_battery”
    name: “Solar Panel Battery Voltage”
    shunt_voltage:
    id: “shed_solar_panel_shunt_voltage”
    name: “Solar Panel Battery Shunt Voltage”
    max_voltage: 12.0V
    max_current: 3.2A
    update_interval: 30s

  • platform: sht3xd
    temperature:
    id: shed_temperature
    name: “Shed Temperature”
    humidity:
    id: shed_humidity
    name: “Shed Humidity”
    i2c_id: bus_a
    address: 0x44
    update_interval: 60s

display:

  • platform: st7735
    model: “INITR_MINI160X80”
    device_height: 160
    device_width: 80
    col_start: 26
    row_start: 1
    eight_bit_color: false
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    #rotation: 180
    invert_colors: true
    lambda: |-
    it.printf( 0, 3, id(myfont_20), id(my_green), " %.1f°", id(shed_temperature).state);
    it.printf( 0, 26, id(myfont_20), id(my_blue), " %.1f %%", id(shed_humidity).state);
    it.printf( 0, 49, id(myfont_20), id(my_gray), " %.1f", id(shed_pressure).state);
    it.printf( 0, 72, id(myfont_20), id(my_green), " %.1f i", id(shed_illuminance).state);
    it.printf( 0, 95, id(myfont_20), id(my_yellow), " %.1f %%", id(shed_m5_battery_level).state);
    it.printf( 0, 118, id(myfont_20), id(my_yellow), " %.1f V" , id(shed_solar_panel_battery).state);

Yaml not markdown!

Sorry, chose the wrong formatting…

esphome:
  name: shed
  platform: ESP32
  board: m5stick-c

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: <removed>

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Shed Fallback Hotspot"
    password: !secret apoint_password


captive_portal:


time:
  - platform: homeassistant
    id: homeassistant_time

    
font:  
  #- file: "fonts/ArchitectsDaughter.ttf"       *
  #- file: "fonts/Courier Prime Code Italic.ttf "
  #- file: "fonts/MicroFLF.ttf"                 *
  #- file: "fonts/SciFly-Sans.ttf"              *
  #- file: "fonts/Ubuntu-R.ttf"                 *
  #- file: "fonts/arial.ttf"                    *
  #- file: "fonts/atomicage-regular"            *
  #- file: "fonts/codystar-regular.ttf"         *
  #- file: "fonts/Electrolize-Regular.ttf"      *
  #- file: "fonts/COMPUTER LOVE.ttf"            * increase size
  #- file: "fonts/CaviarDreams.ttf"             **
  #- file: "fonts/LANENAR_.ttf"                 *
  #- file: "fonts/.ttf"
  #- file: "fonts/.ttf"

  - file: "fonts/CaviarDreams.ttf"
    id: myfont_10
    size: 10 
  
  - file: "fonts/CaviarDreams.ttf"
    id: myfont_20
    size: 20
    
    
color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%
  
  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%
    
  - id: my_green
    red: 0%
    green: 100%
    blue: 0%    

  - id: my_white
    red: 100%
    green: 100%
    blue: 100%
    
  - id: my_gray
    red: 50%
    green: 50%
    blue: 50%  
    
  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%   

  - id: my_orange
    red: 100%
    green: 30%
    blue: 0% 

    
spi:
  clk_pin: GPIO13
  mosi_pin: GPIO15  


i2c:
   - id: bus_a
     sda: GPIO0
     scl: GPIO26
     scan: true
     
   - id: bus_b
     sda: GPIO21
     scl: GPIO22
     scan: true    
     
     
output:
  - platform: gpio
    pin: GPIO10
    id: gpio_10

    
binary_sensor:
  - platform: gpio
    pin: GPIO36
    id: shed_pir_sensor    
    name: "Shed PIR Sensor"
    device_class: motion
    on_press:
      then:
        output.turn_off: gpio_10
    on_release:
      then:
        output.turn_on: gpio_10        
    
    
sensor:
  # AXP192 power management - must be present to initialize TFT power on
  - platform: axp192
    address: 0x34
    i2c_id: bus_b
    update_interval: 30s
    battery_level:
      id: "shed_m5_battery_level"
      name: "Shed m5 Bat"

  - platform: bh1750
    id: "shed_illuminance"  
    name: "Shed Illuminance"
    i2c_id: bus_a      
    address: 0x23
    #measurement_duration: 69
    update_interval: 30s

  - platform: bmp280
    pressure:
      id: shed_pressure
      name: "Shed Pressure"
    i2c_id: bus_a       
    address: 0x76
    update_interval: 60s
    
  - platform: ina219
    i2c_id: bus_a      
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      id: "shed_solar_panel_current" 
      name: "Solar Panel Battery Current"
    power:
      id: "shed_solar_panel_power" 
      name: "Solar Panel Battery Power"
    bus_voltage:
      id: "shed_solar_panel_battery"     
      name: "Solar Panel Battery Voltage"     
    shunt_voltage:
      id: "shed_solar_panel_shunt_voltage" 
      name: "Solar Panel Battery Shunt Voltage"
    max_voltage: 12.0V
    max_current: 3.2A
    update_interval: 30s

  - platform: sht3xd
    temperature:
      id: shed_temperature
      name: "Shed Temperature"
    humidity:
      id: shed_humidity
      name: "Shed Humidity"
    i2c_id: bus_a      
    address: 0x44
    update_interval: 60s
    
display:
  - platform: st7735
    model: "INITR_MINI160X80"
    device_height: 160
    device_width: 80
    col_start: 26
    row_start: 1
    eight_bit_color: false
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    #rotation: 180
    invert_colors: true
    lambda: |-
      it.printf(   0, 3,    id(myfont_20), id(my_green),  " %.1f°",   id(shed_temperature).state);      
      it.printf(   0, 26,   id(myfont_20), id(my_blue),   " %.1f %%", id(shed_humidity).state); 
      it.printf(   0, 49,   id(myfont_20), id(my_gray),   " %.1f",    id(shed_pressure).state); 
      it.printf(   0, 72,   id(myfont_20), id(my_green),  " %.1f i",  id(shed_illuminance).state);
      it.printf(   0, 95,   id(myfont_20), id(my_yellow), " %.1f %%", id(shed_m5_battery_level).state);      
      it.printf(   0, 118,  id(myfont_20), id(my_yellow), " %.1f V" , id(shed_solar_panel_battery).state); 

I have the same bug. The latest changelog under Breaking Changes says: " * Add class as first positional arg to sensor_schema esphome#3216 by @jesserockz (breaking-change)" My configuration.yaml in part says
`
external_components:
- source: github://airy10/esphome-m5stickC
components: [ axp192 ]

AXP192 power management - must be present to initialize TFT power on

  • platform: axp192
    address: 0x34
    i2c_id: bus_a
    update_interval: 5min
    battery_level:
    name: “M5Stick Battery Level”
    id: m5stick_batterylevel
    `
    Seems to me axp192.cpp needs updating by airy10 but I am not equipped to do it.

Something is weird as is shows as an error right off the bat:

This is frustrating, I can’t even get the logs. I spent money and time to configure these and now suddenly I can’t upgrade, get logs or make changes to them.
This is the error message I get when I try t get the log:

INFO Reading configuration /config/esphome/shed.yml...
ERROR Unable to load component axp192.sensor:
Traceback (most recent call last):
  File "/esphome/esphome/loader.py", line 162, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/esphome/custom_components/axp192/sensor.py", line 16, in <module>
    sensor.sensor_schema(UNIT_PERCENT, ICON_BATTERY, 1).extend({
TypeError: sensor_schema() takes from 0 to 1 positional arguments but 3 were given
INFO Detected timezone 'America/Toronto'
WARNING GPIO15 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING Pin 10 (9-10) might already be used by the flash interface in QUAD IO flash mode.
Failed config

sensor.axp192: [source /config/esphome/shed.yml:134]
  
  Platform not found: 'sensor.axp192'.
  platform: axp192
  address: 52
  i2c_id: bus_b
  update_interval: 30s
  battery_level: 
    id: shed_m5_battery_level
    name: Shed m5 Bat

Go back to the esphome version that works.

Well aren’t the esphome config files .yaml not .yml? Where did this shed.yml file come from?

Well, I have been trying to figure it out by removing and re-adding and I guess I misspelled that file name when I added it again, however that is not causing the problem, all my m5 products are in limbo since the ESPHome upgrade. I’m running Home Assistant Operating System on a Pi4, I will try reverting and see, thanks for the suggestion.

Thank you again for the simple fix, reverting to the previous version worked.
I somehow forgot that you can do that, I never had to do it before in the many years I used Home Assistant.
I guess I will keep an eye on this issue…

1 Like

@therafman : I think this is fixed now; was having a similar issue following ESPHome 2022.3.0; if you are using the code from here it appears the dev has updated it and it’ll compile once more.

airy10/esphome-m5stickC: esphome components for the M5StickC (github.com)

1 Like

@satmjm : Thank you! Yes it works now, however I could only use the axp192 component, the st7735 wouldn’t compile so I ended up reverting to my previous version. Now every one of my M5 products works with ESPHOME (except for the M5 Core 2 for AWS, but it is a known issue with this one…)
FYI I converted to an Atom Lite as my Bluetooth Low Energy Tracker Hub, it’s tucked away in the laundry room and it has been rock solid, awesome buy for $8.
Thanks again for the update.

Hi there @therafman, just to clarify, so you can get the M5 Core2 working with ESPHome using this? Just not the AWS version?

From memory the Core2 LCD backlight output from the AXP192 chip is different to the StickC plus. Do you have a different configuration for the Core2?