Coder Social home page Coder Social logo

axp202x_library's Introduction

AXP202X_Library

  • How to program AXP20x_Library with ESP-IDF ESP_IDF_AXP20x_Library

  • The setPowerOutPut function has forced DCDC3 to be turned on and cannot be controlled because T-Watch uses DCDC3 as the esp32 to power the main chip. If it is turned off, the hardware cannot be programmed.

TTGO invests time and resources to provide this open source code, please support TTGO and open source hardware by purchasing products from TTGO!

Written by Lewis He for TTGO. MIT license, all text above must be included in any redistribution

Chip resource table

CHIP AXP173 AXP192 AXP202
DC1 0v7~3v5 /1200mA 0v7~3v5 /1200mA X
DC2 0v7~2v275/1600mA 0v7~2v275/1600mA 0v7~2v275/1600mA
DC3 X 0v7~3v5 /700mA 0v7~3v5 /1200mA
LDO1 3v3 /30mA 3v3 /30mA 3v3 /30mA
LDO2 1v8~3v3 /200mA 1v8~3v3 /200mA 1v8~3v3 /200mA
LDO3 1v8~3v3 /200mA 1v8~3v3 /200mA 0v7~3v3 /200mA
LDO4 0v7~3v5 /500mA X 1v8~3v3 /200mA
LDO5/IO0 X 1v8~3v3 /50mA 1v8~3v3 /50mA

axp202x_library's People

Contributors

cyberman54 avatar designer2k2 avatar gitcodegoose avatar lewisxhe avatar lyusupov avatar mrflexi avatar papillon81 avatar peterus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

axp202x_library's Issues

Schematic

Apologies as this is a more general T-watch question. I am trying to understand the circuit for the AXP202. I know that LDO3 is for the main chip, and LDO2 is for the display, but I don't know what the other LDOs power. DO you guys have a full schematic?

Thanks
Chris

[Temp Readings] AXP 192 on TBeam ESP32 Lora32 (T22_V1.1 20191212)

I am able to flash the axp_temp example to the board I have. My question is regarding the temperature readings from the temperature sensor.

Are the temperature readings internal (chip temperature) or are they external environment readings? The reason I am asking this is that the printed readings in the serial output don't really make sense. I don't think the external environment is 175 C or the internal chip is 175 C as well. Any thoughts?

Serial Monitor Readings

16:48:39.415 > rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
16:48:39.415 > configsip: 0, SPIWP:0xee
16:48:39.415 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
16:48:39.415 > mode:DIO, clock div:1
16:48:39.415 > load:0x3fff0018,len:4
16:48:39.415 > load:0x3fff001c,len:1044
16:48:39.415 > load:0x40078000,len:10124
16:48:39.415 > load:0x40080400,len:5856
16:48:39.415 > entry 0x400806a8
16:48:39.531 > 175.90C
16:48:40.532 > 175.90
C
16:48:41.532 > 175.90C
16:48:42.534 > 175.90
C
16:48:43.534 > 175.90C
16:48:44.535 > 175.90
C
16:48:45.536 > 176.00C
16:48:46.537 > 175.90
C

Compile and Upload Output

Sketch uses 216064 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 14188 bytes (4%) of dynamic memory, leaving 280724 bytes for local variables. Maximum is 294912 bytes.
esptool.py v3.0-dev
Serial port COM7
Connecting......
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 10:52:1c:66:40:44
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 10922.6 kbit/s)...
Hash of data verified.
Compressed 17120 bytes to 11166...
Writing at 0x00001000... (100 %)
Wrote 17120 bytes (11166 compressed) at 0x00001000 in 0.2 seconds (effective 866.8 kbit/s)...
Hash of data verified.
Compressed 216176 bytes to 113932...
Writing at 0x00010000... (14 %)
Writing at 0x00014000... (28 %)
Writing at 0x00018000... (42 %)
Writing at 0x0001c000... (57 %)
Writing at 0x00020000... (71 %)
Writing at 0x00024000... (85 %)
Writing at 0x00028000... (100 %)
Wrote 216176 bytes (113932 compressed) at 0x00010000 in 1.6 seconds (effective 1063.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 3071.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Use function pointers for read/write to i2c bus

On multitasking systems, like ESP32 with RTOS, with more than 1 device on i2c bus (e.g. TTGO T-Beam with display and AXP192) it is necessary to have a mutual exclusion between tasks that access the i2c bus. Usually this is done by using semaphore mutex. All I2c read/write functions must take/give the mutex semaphore.

To realize this with this library it would be useful to use function pointers for _readByte() and _write(Byte) functions, so that user can have own functions which implement mutexing.

Without mutexing usage of this library in multitasking environments will likely cause race conditions while acessing the i2c bus if another task needs access to i2c bus, too.

Battery Cutoff voltage?

Great library, thanks. I've been trying to see what the low-voltage cutoff is, and how it works, without much success.

Page 28 of the data sheet says there are some low voltage interrupts on the 202 at least, but none of those numbers on the sheet line up with the actual numbers in the code. So I'm clearly reading it wrong, correction welcome. There's also nothing about the voltage levels that these would fire.

It appears to cut off at 3.2v, which is fine. On the T-beam 1.1 it left a LED on though, but I'm still working through if it's possible to power this board down cleanly e.g. not mess up the bus and leave the AXP uncontactable.

Thanks!

Basic schematic of this chip

Hi,

Quick question, did you have a basic schematic of this chip for connect to just :

  • 1 Lipo 1S
  • 1 Vin by USB
  • esp32 in 3.3V
  • I2C connection
  • 1 power on/off/key

I found the datasheet but it's not explicit for the basic use.

Thanks a lot !

getVbusCurrent() and getVbusVoltage() not working

Methods getVbusCurrent() and getVbusVoltage() are not working on T-Beam V1.0, result values are always zero while VBUS is present. I would expect to get USB voltage and current values while USB is plugged.

I checked schematic, AXP192 and AXP202 datasheets and code of library, but can't catch the problem. Need help.

AXP192 in TTGO T-Beam 1.0 setPowerOutPut function for DCDC3

Hi there, first of all, thank you for this library :)

I am working with a TTGO T-Beam 1.0 and I followed their repo here: https://github.com/Xinyuan-LilyGO/LilyGO-T-Beam to configure the board to go to sleep. I noticed that DCDC3 is commented out for powering it down.
You mentioned that the T-Watch uses DCDC3 as the esp32 to power the main chip, so probably is the same for the T-beam?
I am reading current consumption of 40mA like this and would much prefer to get the consumption they promised of around 0.9mA.
Do you know if I can safely power down DCDC3 and can I wake it up afterwards as well with esp_sleep_enable?
Below I have a snippet of the code:

setChgLEDMode(AXP20X_LED_OFF);
// axp.setPowerOutPut(AXP192_DCDC3, AXP202_OFF);
setPowerOutPut(AXP192_LDO2, AXP202_OFF);
setPowerOutPut(AXP192_LDO3, AXP202_OFF);
setPowerOutPut(AXP192_DCDC2, AXP202_OFF);
setPowerOutPut(AXP192_EXTEN, AXP202_OFF);
setPowerOutPut(AXP192_DCDC1, AXP202_OFF);`
delay(1000);
esp_sleep_enable_ext0_wakeup(emergency_button,0); //1 = High, 0 = Low
esp_sleep_enable_timer_wakeup(time_sleep);
esp_deep_sleep_start();
Serial.println("This will never be printed");`

Thank you

EDIT: bad formatting

AXP192 on T-Beam V1.0 charge current control settings seems not work

When using the newly introduced charge current control settings to any setting (according to getChargeControl() is on AXP1XX_CHARGE_CUR_450MA) then the getBattDischargeCurrent is reporting it is not charging. Even setting setChargeControlCur(AXP1XX_CHARGE_CUR_450MA) to the previously read value with getChargeControl() seems to cause this issue.

getBattChargeCurrent() not working ?

Dear All,

for a few hours i try to use getBattChargeCurrent() to read the actual charging current.
(In fact i want to monitor the charging state by reading the battery voltage and the current)

The issue is that getBattChargeCurrent() always return 0 but the battery is currently charging as the battery voltage increase (and an ampermeter shows me that current is flowing in the battery accordingly with the value i previously set by setChargeControlCur() ).

Did someone already have successful results with getBattChargeCurrent() ?
Did i miss something or is it a bug ?

Edit : i use an AXP192 on the T-Beam board.

Best regards.

Patrick Pollet

Use of setChargeControlCur() disables charging

I use a TTGO T-BEAM rev1.0 and when I use setChargeControlCur() with any of the enum values, it will not charge.
enableChargeing(true) reenables charging, but still, the set current does not apply and it seems ti be charging at about 400mA.

[Question] Chip ID and AXP202 I2C Addr

Thanks a lot for this library! Help me solve the problem with the difference between datasheet and library.

Library:

//! Chip Address
#define AXP202_SLAVE_ADDRESS                    (0x35U)
#define AXP192_SLAVE_ADDRESS                    (0x34U)
#define AXP173_SLAVE_ADDRESS                    (0x34U)

//! Chip ID
#define AXP202_CHIP_ID                          (0x41)
#define AXP192_CHIP_ID                          (0x03)
#define AXP173_CHIP_ID                          (0xAD)     //!Axp173 does not have a chip ID, given a custom ID

But datasheet fro X-powers official site talk about 0x68 and 0x69 AXP202 Address. Its mean (0x34 << 1) for write access. For AXP192 datasheet talk about 0x68 address too.

Than i try using (0x34 << 1 | READ_BIT) for read registers, and it`s work fine. Why lib using 0x35 address?

After that I tried to read Chip ID (03H address in library) and check datasheet for 03H register description. And datasheet not contain 03h register. And any other libs for AXP202 for Linux or ESP or STM32 not contain 0x03 register in defines

int AXP20X_Class::_axp_probe(void)
{
    uint8_t data;
    if (_isAxp173) {
        //!Axp173 does not have a chip ID, read the status register to see if it reads normally
        _readByte(0x01, 1, &data);
        if (data == 0 || data == 0xFF) {
            return AXP_FAIL;
        }
        _chip_id = AXP173_CHIP_ID;
        _readByte(AXP202_LDO234_DC23_CTL, 1, &_outputReg);
        AXP_DEBUG("OUTPUT Register 0x%x\n", _outputReg);
        _init = true;
        return AXP_PASS;
    }
    _readByte(AXP202_IC_TYPE, 1, &_chip_id);
    AXP_DEBUG("chip id detect 0x%x\n", _chip_id);
    if (_chip_id == AXP202_CHIP_ID || _chip_id == AXP192_CHIP_ID) {
        AXP_DEBUG("Detect CHIP :%s\n", _chip_id == AXP202_CHIP_ID ? "AXP202" : "AXP192");
        _readByte(AXP202_LDO234_DC23_CTL, 1, &_outputReg);
        AXP_DEBUG("OUTPUT Register 0x%x\n", _outputReg);
        _init = true;
        return AXP_PASS;
    }
    return AXP_FAIL;
}

AXP202_IC_TYPE -> 0x03
AXP202_CHIP_ID -> 0x41

Where i can find info about 0x03 register in lib and its address. The official datasheet has a difference with this
Thank you!

Bus Invalid State on axp.begin(Wire, AXP192_SLAVE_ADDRESS)

Hi,
I`m on ESP32 Sim800 TT-Go SIM800C AXP192 20200609.
Sometimes i get the error below when calling axp.begin(Wire, AXP192_SLAVE_ADDRESS):

[E][esp32-hal-i2c.c:1426] i2cCheckLineState(): Bus Invalid State, TwoWire() Can't init sda=1, scl=0
chip id detect 0x0
AXP Power begin failed

This also happens with the original example code from https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800/tree/master/examples/Arduino_TinyGSM.

Questions:

  1. Any hint or clue what's causing the issue & how to fix it? Without battery monitoring it's pretty risky to put the unit outside.. If i press PWR 2 seconds i can fix it temporarly, but question then would be how to fix it on the field without physical access?

setChargeControlCur() and getBattPercentage() not working?

Hi, thanks for fixing enableChargeing(), this seems to be fine now!

When implementing this, i discovered that e.g. axp.setChargeControlCur(300) results in axp.getSettingChargeCurrent() returning 1000, and it always returns 1000 no matter what value you provide to setChargeControlCur().

And i also noticed that getBattPercentage() always returns -4 - i wouldn't know if this is correct, and if so, how to get a percentage from that?

It would be great if you could have a look at those two. :-)

Compile error when using ESP-IDF

I am trying to use this library to build ESP-IDF version sources for TTGO Watch 2020 v1.
I obtained the compilation error:

../components/AXP202X/src/axp20x.cpp: In member function 'int AXP20X_Class::_writeByte(uint8_t, uint8_t, uint8_t*)':
../components/AXP202X/src/axp20x.cpp:2251:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1plus: some warnings being treated as errors
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

It is because of conditional compilation.
When I fix it in my local repo it seems to work well.

My ESP-IDF version is : ESP-IDF v4.4-dev-4-g73db14240

possible memory issue

https://github.com/lewisxhe/AXP202X_Library/blob/c5219709b4c91145402b55d16a5571073980c5be/src/axp20x.cpp#L1807

Line 1650, val |= params[vol];

CPPCHECK says: Cppcheck: (warning) arrayIndexOutOfBoundsCond: Either the condition 'vol>sizeof(params)/sizeof(params[0])' is redundant or the array 'params[8]' is accessed at index 8, which is out of bounds.

enableChargeing() not working

Hi, i was trying to disable charging to conserve power sapped from the external power source, but i noticed that it doesn't seem to have an effect?
There's a bool en in the function's signature, but it doesn't seem to be used.

Arduino Library Registry

Hello there :)

Have you considered submitting this library to the official Arduino Library Registry? (https://github.com/arduino/library-registry)

That way, this library could easily be installed in the Arduino IDE via the built-in Library Manager.

As far as I can tell everything in the library.properties file of this library already looks great, the only thing that would be necessary would be a PR on the registry repo and setting a git tag (https://github.com/arduino/library-registry/blob/main/FAQ.md#submission-requirements)

AXP202 GPIO1 'HIGH' voltage value

Hi Lewis!

I've tried first to set AXP_GPIO1 on HIGH in my (T-Watch) sketch to activate BOOT0 in S76G V1.6 - with no success.
Then I've detached LoRa+GPS board and substituted it with "Basic" one.
I've uploaded your axp202_gpio_output.ino sketch and disabled LOW setting in it's loop() function, as follows:

void loop()
{
    //! GPIO0, GPIO1 allows output high and low
    axp.gpioWrite(AXP_GPIO_0, HIGH);
    axp.gpioWrite(AXP_GPIO_1, HIGH);
    delay(1000);
#if 0
    axp.gpioWrite(AXP_GPIO_0, LOW);
    axp.gpioWrite(AXP_GPIO_1, LOW);
    delay(1000);
#endif
}

I've measured voltage on both AXP_0 and AXP_1 pins of the "Basic" board and it showed me some value which was below 1 Volt. I would expect to see 3.3 Volts or close to this value.

Lewis, I am not familiar with AXP202 datasheet yet. Could you, please, look on what is happening wrong here?
Or, please, give me an advice of where should I look at.

Best regards,
Linar.

Target-voltage below 4V possible?

Hi,
I am wondering whether the AXP192 and the library allow to charge LiFEPo4 batteries as well. These need a target voltage of 3.6 Volt.

Best regards,
Peter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.