Created
August 13, 2019 10:23
-
-
Save bavensky/85c742cc1d6525fa1fa971fce71a13c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <WiFi.h> | |
#include "pins_arduino.h" | |
#include "board_def.h" | |
#include <Wire.h> | |
#include "axp20x.h" | |
AXP20X_Class axp; | |
void setup() | |
{ | |
Serial.begin(115200); | |
Wire1.begin(SENSOR_SDA, SENSOR_SCL); | |
axp.begin(Wire1); | |
axp.setPowerOutPut(AXP202_LDO2, AXP202_ON); | |
axp.enableIRQ(AXP202_ALL_IRQ, AXP202_OFF); | |
axp.adc1Enable(0xFF, AXP202_OFF); | |
axp.adc2Enable(0xFF, AXP202_OFF); | |
axp.adc1Enable(AXP202_BATT_VOL_ADC1 | AXP202_BATT_CUR_ADC1 | AXP202_VBUS_VOL_ADC1 | AXP202_VBUS_CUR_ADC1, AXP202_ON); | |
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_CHARGING_FINISHED_IRQ, AXP202_ON); | |
axp.clearIRQ(); | |
pinMode(AXP202_INT, INPUT_PULLUP); | |
} | |
void loop() | |
{ | |
Serial.print("isChargeing ? : "); | |
Serial.print(axp.isChargeing()); | |
if(axp.isChargeing()) { | |
Serial.print(" getBattChargeCurrent : "); | |
Serial.print( axp.getBattChargeCurrent()); | |
} else { | |
Serial.print(" getBattDischargeCurrent : "); | |
Serial.print( axp.getBattDischargeCurrent()); | |
} | |
Serial.print(" getVbusVoltage : "); | |
Serial.print( axp.getVbusVoltage()); | |
Serial.print(" getVbusCurrent : "); | |
Serial.print( axp.getVbusCurrent()); | |
Serial.print(" getBattInpower : "); | |
Serial.print( axp.getBattInpower()); | |
Serial.print(" getTemp : "); | |
Serial.print( axp.getTemp()); | |
Serial.print("\n"); | |
delay(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment