VUSB pin on Argon

The datasheet for the Argon says that the VUSB pin on the Argon is connected to USB power. Does this mean that there is not a diode between this pin and the power from the on-board USB connector (as on the Photon)? It was really handy to supply external 5 volt power to the Photon via that pin on a PCB but also have the option to simply plug in a USB cable (power and all) for debugging (the diode would isolate the PCB 5 volt power from the USB power). Please confirm that the Argon (and Xenon) do not have this isolation diode on the module; it would need to be supplied externally on the PCB.

There is no diode between the USB power pin and the VUSB pin on the Argon and Xenon.

If you are powering by VUSB, you should not power by USB at the same time. I use a data-only USB adapter for this purpose.

Not sure if I should start a new topic for this question or not, so here goes. Back in 2016 you posted some code that worked with the Electron for determining if it was being powered by USB or battery. I need to do the same for the Argon. I came up with what looked like a solution by checking the voltage on the VUSB pin and that’s how I discovered your post. I tried the code used for the Electron but it failed because I don’t have the particle.h library. Before I go looking for that, was curious if these 3rd generation devices have an easier method for determining the current power source. I basically want to be able to send a webhook to an alerting app if the Argon goes from USB power to Battery power for more than x amount of time. Thank you for any information you can provide.

On the Argon, there's a 3 line function in this post that will do it:

On the Boron, Electron, and E Series, it's now built into Device OS 1.5.0 and later:

https://docs.particle.io/reference/device-os/firmware/boron/#powersource-

That’s awesome. I was hoping this was the case. I appreciate your quick response and apologies for not finding this in my pre-post research. Kind regards.

Me again. Apologies. I'm looking at replacing the Argon's in my closet sensors with Photon 2. As expected, determining if on battery or usb power does not work the same. I have not found an API solution. Any assistance is appreciated. Thank you.

Unfortunately there's no good way to tell if a Photon 2 is powered externally vs. battery.

The technique used on the Argon only works because the nRF52 has a separate connection to 5V USB power that's used to determine whether the USB port and circuitry is powered up internal to the MCU. This is to save power when powered by battery. The RTL872x does not have this feature. (The STM32 doesn't either.)

No worries. This will likely be the deciding factor in staying with the Argon as determining if the power goes off is one of the functions I need and this is a simple solution. I appreciate the quick response.

Would you be able to work out a bit less simple solution and add a resistor divider to a GPIO on the photon2?
That's one way to detect usb power perhaps.

3 Likes

I hadn't thought of that. I'll give that a try. Thank you.

1 Like

Okay. This works. Thanks to Grok, here is what I did as quick test.

10k resistor between vusb and A1. 20k resistor from A1 to ground. Using the following code:

// Include Particle Device OS APIs
#include "Particle.h"

// Pin Definitions
const int voltageSensePin = A1;

// Variables for state change detection
String currentState = "OFF"; // Initial state

// Function to publish state changes to the dashboard
void publishState(String state) {
    if(state == "ON") {
        Particle.publish("USBStatus", "ON", PRIVATE);
    } else {
        Particle.publish("USBStatus", "OFF", PRIVATE);
    }
}

void setup() {
  // Initialize serial communication at 9600 bps
  Serial.begin(9600);
  
  // Set the voltage sense pin as an input
  pinMode(voltageSensePin, INPUT);
  
  // Wait for Serial Monitor to open
  waitFor(Serial.isConnected, 5000);
  
  Serial.println("USB Power Monitor");
}

void loop() {
  // Read the analog value from the voltage divider
  int sensorValue = analogRead(voltageSensePin);

  // Convert the analog reading (which goes from 0 - 4095) to a voltage (0.0V - 3.3V)
  float voltage = sensorValue * (3.3 / 4095.0); // 12-bit ADC conversion

  // Threshold to determine if USB power is on (adjust as needed based on your setup)
  float thresholdVoltage = 1.5;  // Assuming USB voltage is about 5V, divided by 3, should be around 1.67V

  // Determine the new state
  String newState = voltage > thresholdVoltage ? "ON" : "OFF";

  // Check for state change and report if changed
  if (newState != currentState) {
    currentState = newState;
    Serial.print("USB Power is ");
    Serial.println(currentState);
    publishState(currentState);
  }

  // Small delay to avoid flooding the serial monitor and dashboard
  delay(1000);  // 1 second delay
}

So this adds a bit of complexity, but not unreasonable as it provides my solution. You coders may see an easier way. Many thanks.

cool, just have in mind to NEVER remove the 20k resistor from the divider, or you might be exposing the GPIO pin A1 to 5V.

2 Likes

Thank you. And Grok was very good about pointing that out. :slightly_smiling_face:

1 Like

@ssw_txed, to simplify your code and speed it up, you can pre-calculate the raw ADC value that represents your threshold voltage instead of converting to voltage. Also note that if you use +/- 10% resistors, it is possible to have a voltage of about 3.5v at the input pin. You may want to use +/- 5% or better resistors.

I have seen "safe" designs that use a cheap low current 3.3v LDO regulator (e.g. Microchip MIC5504-3.3YM5-TR) to achive the same thing while providing over-voltage protection.

1 Like

oh that is a better idea than a resistor divider. Thank you.
Now, do you think this one would do the trick as well, Paul? (it's more breadboard friendly).

2 Likes

That regulator would work. We use the AP2204K for this purpose as it's inexpensive, tiny, and does not require an external inductor.

3 Likes