# Argon check power source?

**URL:** <https://community.particle.io/t/argon-check-power-source/47694>\
**Category:** Firmware\
**Tags:** argon\
**Created:** [February 10, 2019, 9:27pm UTC](https://community.particle.io/t/argon-check-power-source/47694 "2019-02-10T21:27:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [February 11, 2019, 11:15am UTC](https://community.particle.io/t/argon-check-power-source/47694/3 "2019-02-11T11:15:16Z")

</div>

Yes, all of those are available on the Argon and Xenon.

```auto
#include "Particle.h"

SerialLogHandler logHandler;

char lastMsg[128];
unsigned long lastPublish = 0;

void setup() {
	Serial.begin();
	pinMode(PWR, INPUT);
	pinMode(CHG, INPUT);
}

void loop() {
	float voltage = analogRead(BATT) * 0.0011224;

	// PWR: 0=no USB power, 1=USB powered
	// CHG: 0=charging, 1=not charging
	char buf[128];
	snprintf(buf, sizeof(buf), "voltage=%.1f PWR=%d CHG=%d", voltage, digitalRead(PWR), digitalRead(CHG));

	if (strcmp(buf, lastMsg) != 0 && millis() - lastPublish > 2000) {
		Particle.publish("battery", buf, PRIVATE);
		Log.info(buf);
		strcpy(lastMsg, buf);
		lastPublish = millis();
	}
}

```

They’re available on the Boron as well, but the technique is different because you need to query the PMIC instead.

---

_[View the full topic](https://community.particle.io/t/argon-check-power-source/47694)._
