Notification when charging

Tags: #<Tag:0x00007fe2225b38b0>


I’m going to be using wireless charging in a sealed project with a xenon, wireless charging circuit, dfplayer mini, and nfc. Is there any way I can have the system play a sound from the sd card when it detects incoming voltage?


I’d just monitor the VIN-pin with a input-pin (don’t forget to protect it against the 5V using a voltage-divider). You could trigger an interrupt that plays your sound (or better changes a flag and the loop plays the sound).


Xenon I/O pins are not 5V tolerant.

But you can do something like this:

int publish_delay =  5 * 1000 ; // # of Seconds * 1000(mS)
float voltage ;                 // Li-Po Voltage
bool charge ;                   // Li-Po Charging Status
bool onBatteryPower;            // Li-Po Dis-Charging Status
unsigned int lastPublish = 0  ;

void setup() {
  pinMode(PWR, INPUT);
  pinMode(CHG, INPUT);

void loop() {

  if ((millis() - lastPublish) > publish_delay)  {
    voltage = analogRead(BATT) * 0.0011224;
    charge = (digitalRead(PWR) && !digitalRead(CHG));
    onBatteryPower = (!digitalRead(PWR));
    // Perform your Publish or Serial.Print here
    lastPublish = millis();
  // Do Your Other Stuff


A Zero/false for onBatteryPower means the Xenon has an external power source (not the Li-Po).

Check charge to determine if the Li-Po is being charged.


This is what I was wondering, if your device “knows” when its getting input voltage or battery voltage and if so, how to do something with it. Thanks @glx and @Rftop.