STM32F: Blinking red Neo when EN and USB in use
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- hockeygoalie35
- Posts: 6
- Joined: Mon Jul 25, 2022 12:55 pm
STM32F: Blinking red Neo when EN and USB in use
Hi! I'm a Mech-E, so forgive maybe the noob-ish question. I have a little board that connects to my STM32F Express feather, which connects USB to A1 (for USB voltage monitoring), and a switch between EN and GND. when I flip the switch to connect the two (hoping to turn off the feather), the Neopixel blinks red and doesn't actually shut off. Am I shorting something? Once I remove the USB -> A1 connection, it works fine.
- dastels
- Posts: 15608
- Joined: Tue Oct 20, 2015 3:22 pm
Re: STM32F: Blinking red Neo when EN and USB in use
What connection on USB? AI'm assuming the 5v line. Is it connected directly to A1?
Dave
Dave
- hockeygoalie35
- Posts: 6
- Joined: Mon Jul 25, 2022 12:55 pm
Re: STM32F: Blinking red Neo when EN and USB in use
Hi Dave. Yes, 5V on the USB, and USB pin is direct connected to A1. Any easy way to try it out: plug the feather into a 5V USB C source, put a jumper from pins A1 to USB, and EN to GND. Either right away or after hitting reset, the neopixel begins to blink red until you disconnect one of the jumpers.
- dastels
- Posts: 15608
- Joined: Tue Oct 20, 2015 3:22 pm
Re: STM32F: Blinking red Neo when EN and USB in use
You shouldn't connect 5v to A1. From the tutorial guide:
Dave
You need to use a voltage divider to halve the 5v input then double the voltage that you read.A1 / GPIO 17 / PA5
This pin is analog input A1 (ADC12 IN5)
... You can set the raw voltage to anything from 0 to 3.3V ...
Dave
- alpierce
- Posts: 206
- Joined: Mon May 13, 2013 2:44 am
Re: STM32F: Blinking red Neo when EN and USB in use
If you don’t need to know the exact voltage of the USB, but only need to know if it is present or not you can also use the voltage divider dastels mentioned and read A1 (or any other analog or digital pin) as a digital input. It will be True if there is USB voltage present and False if there is not. Simplifies your code somewhat.
- dastels
- Posts: 15608
- Joined: Tue Oct 20, 2015 3:22 pm
- hockeygoalie35
- Posts: 6
- Joined: Mon Jul 25, 2022 12:55 pm
Re: STM32F: Blinking red Neo when EN and USB in use
I haven't decided yet if I'm going to show the user battery percentage yet, but if I don't, that's a good option, thanks. 2 questions:alpierce wrote: ↑Sat Sep 17, 2022 1:01 pm If you don’t need to know the exact voltage of the USB, but only need to know if it is present or not you can also use the voltage divider dastels mentioned and read A1 (or any other analog or digital pin) as a digital input. It will be True if there is USB voltage present and False if there is not. Simplifies your code somewhat.
- Any ideas on the "why" this happens?
- Also, do I need to worry about current in the voltage divider, or not really since I'm just measuring voltage?
- alpierce
- Posts: 206
- Joined: Mon May 13, 2013 2:44 am
Re: STM32F: Blinking red Neo when EN and USB in use
Putting 5v on an input pin can cause unreliable functionality and/or destroy the input, depending on the input circuitry of the chip.
I typically use high value resistors (100k) for voltage dividers to keep the current use low, especially for battery powered designs. Check out the Measuring Battery section of the Power Management topic in the Primary Guide: Adafruit STM 32F405 Feather Express towards the bottom of the product page.
I typically use high value resistors (100k) for voltage dividers to keep the current use low, especially for battery powered designs. Check out the Measuring Battery section of the Power Management topic in the Primary Guide: Adafruit STM 32F405 Feather Express towards the bottom of the product page.
- hockeygoalie35
- Posts: 6
- Joined: Mon Jul 25, 2022 12:55 pm
Re: STM32F: Blinking red Neo when EN and USB in use
Ooh, that's super helpful, turns out they had the functionality all along on A6. Great find, thanks! Guess I didn't RTFM enough. I can then infer if the value on A6 is 0, then it must be on USB.alpierce wrote: ↑Sat Sep 17, 2022 2:46 pm Putting 5v on an input pin can cause unreliable functionality and/or destroy the input, depending on the input circuitry of the chip.
I typically use high value resistors (100k) for voltage dividers to keep the current use low, especially for battery powered designs. Check out the Measuring Battery section of the Power Management topic in the Primary Guide: Adafruit STM 32F405 Feather Express towards the bottom of the product page.
EDIT: I can copy the voltage divider from the schematic and make A1 a digital input to test if the USB pin is active. If it isn't, then use A6 to get the battery voltage.
Please be positive and constructive with your questions and comments.