STM32F103CB ‘Sleepy mode’ and ‘Wake up’ function

Post here first, or if you can't find a relevant section!
ag123
Posts: 1709
Joined: Thu Dec 19, 2019 5:30 am
Answers: 27

Re: STM32F103CB ‘Sleepy mode’ and ‘Wake up’ function

Post by ag123 »

it depends on how much data you are trying to store

I've used some of these:
https://www.digikey.com/en/products/det ... IG/2815931
https://www.winbond.com/hq/product/code ... o=W25Q64FV
https://www.aliexpress.com/w/wholesale-w25q64.html

what you need to do is to get spi working correctly, many libraries if you are looking for it
https://github.com/search?q=spi%20flash ... positories
and coding one from scratch isn't after all too difficult
oh and one thing good about spi flash, it can normally write even a few bytes of data e.g. a record, review the datasheets for the details.

it is easy enough to keep a 'blue pill' style board (e.g. stm32f103c8) running on a usb charger.
I didn't bother with sleep mode. so if you have access to fixed power supply e.g. a usb charger (5v) that'd be good enough to keep it running perpetually.

without a power connection, lipo batteries (you can even use 'power banks' used to charge phones for that), nimh batteries comes next. those can be recharged. and if your app don't take too much power it can even run on ordinary AA batteries for days

'sleep' / 'low power' modes are normally used for 1 purpose, to 'swtich it off' in software.
actually to do that you need to turn off all other peripherals too, e.g. to make sure that all the other external on board components are not drawing power.
and as well to unclock the gpio and such on chip pheriperials.
simply running 'sleep' or 'low power' or even 'standby' mode normally only switches off the cpu part of the microcontroller.
it won't save much power if all the other things are taking much more power than stm32 itself.

a simple way to reduce power i find is simply

Code: Select all

asm("wfi");
in loop()
that is just wait for interrupt, systick interrupts every milli second, that makes your loop() runs every millisecond.
that is good enough for me and more often than not i find that stm32 chip run cooler with that asm("wfi"); which indicates using less power.

if you have lots of data, then the only way left is sd cards. that is actually pretty complex but that there are libraries like sd_fat etc around.
sd cards isn't that easy to deal with, it can take like 400 ms to wait for an ACK before say writing the next sector etc. and if your app isn't well written
try to imagine 400 ms stalls between samples, and that is still quite 'benign'. apps not written properly can even lockup / hang working with sd cards.
sd cards is *not for novices*, hence, it is better to get familiar with more basic stuff with stm32 stm32duino before playing with sd cards.

if you really want to use sd cards and make a logger, adafruit has a rather pricy but high performance
STM32F405 Express
https://www.adafruit.com/product/4382
that one runs stm32duino (Arduino_core_stm32) and circuit python
Adafruit has various tutorials about that board and many tutorials on circuit python, including making loggers that logs to sd cards.
review the tutorials from adafruit about that board, etc
https://learn.adafruit.com/adafruit-stm ... er-express
that one even have the micro sd card slot built on board
and adafruit sells various sensor modules to go with their boards, pretty polished / posh for 'diy' projects.
Post Reply

Return to “General discussion”