Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post here first, or if you can't find a relevant section!
Post Reply
Piter_de_Vries
Posts: 11
Joined: Sat Sep 17, 2022 4:12 pm

Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post by Piter_de_Vries »

I have an STM32F103C8 Blue Pill board of which I am using every pin (so I have no pins to write to an SD card). I want the board to store some data from the ADC in RAM while being powered by NiMH battery (three or four cells in series). I then want to connect the board to my PC to retrieve the data from RAM over serial. My problem is how to power the board without causing a problem.

I was originally going to use a buck converter to take the voltage from the battery and give 3.3 V on the 3.3 V pin but I've heard that the ADC won't appreciate the oscillations coming from the buck converter so I think that maybe I should connect the battery to the 5 V pin instead, utilising the onboard 3.3 V regulator. A fully charged set of four NiMH in series have 5.8 V and I don't suppose my computer will appreciate it when I connect to upload my data. Conversely, I don't think the cells will like it if there are only three of them and they're connected to 5 V.

I think that the red area in the below image is the 5 V that comes from the USB. Perhaps I should break the track and bridge it through a diode? I couldn't find anyone discussing how they dealt with this problem on the forum.

Image
ag123
Posts: 1388
Joined: Thu Dec 19, 2019 5:30 am
Answers: 18

Re: Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post by ag123 »

To power the "blue pill" board, I'd think it is OK to power just the 5v line. The LDO on board will take care of supplying the stm32.

To prevent possible power issues with USB, it could damage your computer instead, if those circuits in there won't handle it, the easiest way is to make a switch so that you can disconnect the battery when connecting the BP board to usb
Piter_de_Vries
Posts: 11
Joined: Sat Sep 17, 2022 4:12 pm

Re: Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post by Piter_de_Vries »

If I disconnect the power from the battery before connecting to USB, I will lose the data in the RAM.
ag123
Posts: 1388
Joined: Thu Dec 19, 2019 5:30 am
Answers: 18

Re: Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post by ag123 »

My guess is if your battery source is 5v, it may be 'safe' to connect to usb. But that the pc/host should be powered.
It is less certain about the implications if the pc / usb to host is after all powered off while you connect it.
GonzoG
Posts: 293
Joined: Wed Jan 15, 2020 11:30 am
Answers: 23
Location: Prudnik, Poland

Re: Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post by GonzoG »

LDO on blue pill have very limited input range. 5.5V is maximum.
If you want to use 2 sources of power you need to properly isolate them. Easier way is to put a diode on 5V from USB.
ag123
Posts: 1388
Joined: Thu Dec 19, 2019 5:30 am
Answers: 18

Re: Connecting to USB while powering with battery: STM32F103C8 Blue Pill

Post by ag123 »

For Ni-MH, I think it is ok, I've a setup where I used Ni-MH batteries, nominal voltage is about 1.2v more often I see 1.3-1.35v when it is fully charged.
That gives like 5.4v when it is fully charged and it could stay fairly flat declining to 4.8v nominal. But I powered off the Ni-MH if I'm connecting usb to the host pc. In my app, I write the data to an SD card, so I'm not dependent on SRAM to keep the memory

powering from both batteries (e.g. Ni MH) and USB may be 'dicy', it is less predictable about what may happen to PC.
But I'd guess it is 'ok' if you consider that both USB and the Battery should be at 5v, same potential or little current flows.
Post Reply

Return to “General discussion”