-
Notifications
You must be signed in to change notification settings - Fork 13
Added functionality for M5Stack Core2 V1 AXP192 PMU chip #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Display baklight OK as a light Display powers up (as long as it was powering up before) Vibration motor controllable as a light Green LED still to do GPIO still to do Battery voltage, temp and % giving a value but values don't make sense
Correct YAML code block formatting in README.
…ng discharge and battery charge current during charging. Added configurable levels for 0 and 100% thresholds for voltage and current, together with defaults
|
Great, I'll try that out as soon as possible. |
| entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||
| ), | ||
| cv.Optional(CONF_USB_CURRENT): sensor.sensor_schema( | ||
| unit_of_measurement='A', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The currents are low, so it is easier to read in mA than in amperes:
| unit_of_measurement='A', | |
| unit_of_measurement='mA' |
| entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||
| ), | ||
| cv.Optional(CONF_VBUS_CURRENT): sensor.sensor_schema( | ||
| unit_of_measurement='A', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| unit_of_measurement='A', | |
| unit_of_measurement='mA', |
| entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||
| ), | ||
| cv.Optional(CONF_BATTERY_CHARGE_CURRENT): sensor.sensor_schema( | ||
| unit_of_measurement='A', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| unit_of_measurement='A', | |
| unit_of_measurement='mA', |
| entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||
| ), | ||
| cv.Optional(CONF_BATTERY_DISCHARGE_CURRENT): sensor.sensor_schema( | ||
| unit_of_measurement='A', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
| unit_of_measurement='A', | |
| unit_of_measurement='mA', |
|
|
||
| if(usb_current_sensor_ != nullptr) { | ||
| reading = this->parent_->getACINCurrent(); | ||
| usb_current_sensor_->publish_state(reading == 0 ? NAN : reading); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| usb_current_sensor_->publish_state(reading == 0 ? NAN : reading); | |
| usb_current_sensor_->publish_state(reading == 0 ? NAN : reading * 1000); |
|
|
||
| if(vbus_current_sensor_ != nullptr) { | ||
| reading = this->parent_->getACINCurrent(); | ||
| vbus_current_sensor_->publish_state(reading == 0 ? NAN : reading); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| vbus_current_sensor_->publish_state(reading == 0 ? NAN : reading); | |
| vbus_current_sensor_->publish_state(reading == 0 ? NAN : reading * 1000); |
|
|
||
| if(battery_discharge_current_sensor_ != nullptr) { | ||
| reading = this->parent_->getBattDischargeCurrent(); | ||
| battery_discharge_current_sensor_->publish_state(reading == 0 ? NAN : reading); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| battery_discharge_current_sensor_->publish_state(reading == 0 ? NAN : reading); | |
| battery_discharge_current_sensor_->publish_state(reading == 0 ? NAN : reading * 1000); |
|
You should add a yaml config file like cores3-config-example.yaml. |
|
@lboue There already is an example yaml file - see https://github.com/jimwsmith/esphome-yaml/blob/main/components/axp192/README.md |
|
Your other changes are simply changing current units from A to mA which user can do for themselves in Home Assistant. |
|
Apart from changing the accuracy of the entity, I haven't been able to do it in HA frontend. I'm interested in a solution if one exists, because currently it remains in amperes. |
|
The example yaml contains both local and github options I have changed in case that's confusing for you |

My first attempt at a pull request - so apologies if I'm doing this wrong.
I forked your repo and then worked on my copy to add a new component AXP192
Inside that are sensor, switch and output folders
I have tested on my own Core 2 V1 unit but obviously wold be good to try with some others.
Still WIP but the sensors work
Battery level based on battery voltage during discharge and charge current during charging
Display backlight, Geen LED and vibration motor control all work.
Virtual GPIO pins for Display and Touchscreen reset functionality are beyond me (in terms of init.py syntax
hunks of redundant code still need to be removed (I based my work on AXP192 datasheet and the Core2 circuit schematic and your AXP2101 component
Test .yaml file and README.md contain example code of using the new component