Detect VUSB Feather Huzzah 8266 using a GPIO

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lac
 
Posts: 7
Joined: Wed Aug 16, 2017 11:59 pm

Detect VUSB Feather Huzzah 8266 using a GPIO

Post by lac »

Hi all!

Im using a Feather Huzzah ESP8266 and I would like to know whether the USB voltage is present or not. I want to use a GPIO (let's say pin 14) because I'm using de ADC for the battery. I've tryed with some diodes in series but it didn't work as I expected. I've also noticed that the VUSB pin is connected to VBAT through a diode so even if the USB voltage is not present there is still voltage applied to the pin. I've thought about using a voltage divider but the voltage may fall in the "gray zone" and may not be detected as a "0" logic.

Any tip?

Thanks in advanced!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Detect VUSB Feather Huzzah 8266 using a GPIO

Post by adafruit_support_mike »

It would be easiest to use the ADC pin and scale the voltage so 5v pulls the ADC near 1v and a LiPo pulls it between 0.75v and 0.8v.

A pair of 82k resistors in parallel will give you the equivalent of a 41k, then you can put that in series with a 10k to get the right voltage range.

User avatar
lac
 
Posts: 7
Joined: Wed Aug 16, 2017 11:59 pm

Re: Detect VUSB Feather Huzzah 8266 using a GPIO

Post by lac »

Thanks for the tip!

I'm already using th ADC to measure the battery level so I wanted to use a GPIO and some additional components (the less possible) in order to detect the USB voltage. I'm getting about 4.8V applied to the VUSB pin when the USB is connected and less than 4V running off the battery (fully charged).

Thanks!

User avatar
lac
 
Posts: 7
Joined: Wed Aug 16, 2017 11:59 pm

Re: Detect VUSB Feather Huzzah 8266 using a GPIO

Post by lac »

I didn't get it at first.

So you say I could use the ADC to sense both the battery and VUSB at the VUSB pin and add the voltage drop across the diode "by hand".

Will the voltage drop across the diode stay constant in all the range?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Detect VUSB Feather Huzzah 8266 using a GPIO

Post by adafruit_support_mike »

Yes. The USB pin connects to whatever is powering the onboard voltage regulator, whether it's 5v from the USB jack of the LiPo.

There's a diode between the LiPo and the USB line that isolates the battery when 5v is connected, and the average voltage drop across that will be about 200mV.

User avatar
lac
 
Posts: 7
Joined: Wed Aug 16, 2017 11:59 pm

Re: Detect VUSB Feather Huzzah 8266 using a GPIO

Post by lac »

Thanks @adafruit_support_mike!

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”