Can pins take 5v?

I wanted to read the vUSB pin to see if usb power was active or not, I didn’t know if the electrons pins could handle 5V in without dividing voltage, if so are all pins 5v tolerant? or should i read on a specific pin? Sorry if this has been asked, but I looked and don’t see it asked for the electron specifically. If there is an easier way to do this also, i’m all ears.

This might be a place to find the info you were looking for
https://docs.particle.io/datasheets/electron-datasheet/#peripherals-and-gpio

Especially the Note [1] and there especially the statement in parenthesis

Got it, thanks.

Also, you can determine if the Electron has external power (USB or VIN) entirely through software without adding any connections or IO pins.

#include "Particle.h"

bool isUsbPowered(); // forward declaration

PMIC pmic;
bool lastPowerState = false;


void setup() {
	pmic.begin();
}

void loop() {
	bool powerState = isUsbPowered();
	if (powerState != lastPowerState) {
		Particle.publish("usbPowered", (powerState ? "true" : "false"), 60, PRIVATE);
		lastPowerState = powerState;
	}

	delay(2000);
}

bool isUsbPowered() {
	bool isUsbPowered;

	// Get the system status register from the PMIC
	byte systemStatus = pmic.getSystemStatus();

	// Normally you want to use this. It will return true if the Electron is powered by a USB host (computer/laptop),
	// USB charger, or the VIN pin. Basically, it really determines if it's externally powered, not USB powered.
	isUsbPowered = (systemStatus & 0x4) != 0;

	// Alternatively, you could use this. This will return true if the Electron is powered by a USB host.
	// It will return false for a USB charger or VIN.
	// Basically, it's not possible to tell the difference between VIN and USB Charger in software, as far as I can tell
	// isUsbPowered = ((systemStatus & 0xc0) == 0x40);

	return isUsbPowered;
}

/*
Fuel Gauge MAX 17043
Power Management BQ24195

//System Status Register
//NOTE: This is a read-only register
REG08
BIT
--- VBUS status
7: VBUS_STAT[1]	| 00: Unknown (no input, or DPDM detection incomplete), 01: USB host
6: VBUS_STAT[0]	| 10: Adapter port, 11: OTG
--- Charging status
5: CHRG_STAT[1] | 00: Not Charging,  01: Pre-charge (<VBATLOWV)
4: CHRG_STAT[0] | 10: Fast Charging, 11: Charge termination done
3: DPM_STAT		0: Not DPM
				1: VINDPM or IINDPM
2: PG_STAT		0: Power NO Good :(
				1: Power Good :)
1: THERM_STAT	0: Normal
				1: In Thermal Regulation (HOT)
0: VSYS_STAT	0: Not in VSYSMIN regulation (BAT > VSYSMIN)
				1: In VSYSMIN regulation (BAT < VSYSMIN)ault is 3.5V (101)
0: Reserved
 */



3 Likes

rickkas,

thank you for this, perfect.

The datasheet is not clear. It says UART (3) are 3V3. IO pins are FT (fault tolerant). I’m configuring a UART on pins C2 and C3. I shall assume that those pins are FT if configured as IO pins and 3V3 if configured as a UART.

FT does not stand for Fault Tolerant but for Five Volt Tolerant (in the Particle context)

https://docs.particle.io/datasheets/electron-datasheet/#peripherals-and-gpio

But sure, the FT is not explicitly mentioned in the UART row.
Maybe @rickkas7 can take this one on, since UART may use pull-up resistors and hence the condition of the footnote is not fully satisfied - but for the brief moments the RX pin receives 5V the current via the pull-up won’t hurt IMO. I guess the [4] footnote applies to UART just the same.

C2 and C3 are 5-volt tolerant, even in UART mode. There are no pull-ups in UART mode, and note 4 is the one that applies. Since the TX is only 3.3V, it’s not technically 5V TTL serial compatible, since the high voltage is too low. However, it often works. The Electron won’t be damaged by receiving 5V on the RX pin. This applies to the real TX/RX pins, as well as the additional serial ports of the Electron.

2 Likes

Thank you for that information. Perfect timing. I sent out for prototype boards a few days ago then over the weekend I thought about 5V tolerance. I redesigned the board with two different 3.3V transceivers. The first boards will arrive this week. I expect they’ll work as you’ve said because that’s how I tested the concept in the first place. I’ll not order the redesigned boards until I see how the first ones work. If we go to Production, of course I’ll do it with 3.3V transceivers.