Temperature logger with Bluepill, microSD card and DS18B20

What are you developing?
Post Reply
headcra6
Posts: 5
Joined: Wed Jan 03, 2018 10:35 am

Temperature logger with Bluepill, microSD card and DS18B20

Post by headcra6 » Wed Jan 03, 2018 12:00 pm

Hi everyone!

I'm currently building a temperature logger for some guys doing a research in biology. Tried to make it as small as possible, with temperature sensor that can be crammed in small space. I wrote up all I did up to the moment in a blog post here:

http://www.shortn0tes.com/2017/11/diy-t ... 2f103.html

I'm now battling the ridiculously low continuous current that I can pull from a coin cell, even as beefy as CR2477. The device works OK when the coin cell is full, but after a few days of using it the logger collapses the power source when writing to SD memory card. Memory card can pull as much as 100mA during writing, and the absolute maximum for CR2477 seems to be around 15mA.

For now I've resolved this problem by replacing CR2477 with two AA batteries, but I'd like to replace power-hungry SD with serial flash in future revisions. Right now I've ordered M25P128, hope they're better suited for my purposes.

I'd love to know what you think. How can it be improved? Obvious design flaws (other than absense of PCB and the nest of wires inside)?

tfried
Posts: 20
Joined: Mon Dec 04, 2017 8:45 pm

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by tfried » Thu Jan 04, 2018 8:21 am

As far as I understand, there may be quite significant differences between SD cards in the same reader, so you might at least want to experiment with a few different cards.

Also, of course, you probably don't have to write huge amounts of data, so perhaps if you keep a buffer that you write to disk once a minute, and fully shut down the SD card in between, I imagine that might reduce the average power consumption, a lot.

No first-experience on any of this, though. This is what google turned up: https://community.nxp.com/thread/422802.

User avatar
Pito
Posts: 1739
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by Pito » Thu Jan 04, 2018 8:35 am

Today the various SDcards may draw 50-800mA when writing.
Serial flash chips take ~20mA when writing in it.
You have to provide a power consumption budget analysis (actual operations with timing and active currents) for your application when dealing with CRxxxx button cells and low-power.
Also low-power must be built into the design from scratch, the off the shelf modules are not low-power suitable, I am afraid.
It should be about 2-5 microamps and I would be grateful for any advice on how to reduce this tenfold engorgement on my coin cell.
An 1Meg resistor takes 3uA off the CR button cell. To get a few uAmps (as is the goal on your blog) requires many prerequisites..
For example:
1. no pull-up or pull-down resistors active
2. no LEDs
3. voltage regulators - none, or when - then the one with 1-2uA quiescent current
4. no aluminum or tantalum capacitors
5. logic levels pmos transistors for high-side switching on-off the various external modules (like the SDcard - which takes ~200uA in stand by)
6. carefully chosen resistors values
7. stm32 - switching off the internal subsystems, elaborating clock freqs required
8. adding a secondary source for supporting the battery - ie. a solar cell in your case
9. etc.
Pukao Hats Cleaning Services Ltd.

User avatar
zoomx
Posts: 567
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by zoomx » Thu Jan 04, 2018 9:51 am

Maybe this blog has useful informations because the author have build many battery powered dataloggers that were put on the field.
https://edwardmallon.wordpress.com
He uses a trick, put data on the small I2C flash memory and when is close to full it copies data in the SD. He uses cheap DS3231 RTC boards that have a small I2C flash memory.
He uses many tricks like removing unused components.
https://edwardmallon.wordpress.com/2015 ... imization/

headcra6
Posts: 5
Joined: Wed Jan 03, 2018 10:35 am

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by headcra6 » Thu Jan 04, 2018 12:17 pm

tfried wrote:
Thu Jan 04, 2018 8:21 am
This is what google turned up: https://community.nxp.com/thread/422802.
Thanks for the link! This, additionally to what I read on the matter in question before (https://electronics.stackexchange.com/q ... n-cell-bat), further persuades me to migrate to serial flash.
Even though I'd consider it educational and even fun to compare various memory card to find the one with the with smallest power consumption, the customer definitely wants no fuss with that.

User avatar
mrburnette
Posts: 2216
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by mrburnette » Thu Jan 04, 2018 3:07 pm

headcra6 wrote:
Wed Jan 03, 2018 12:00 pm
<...>
The device works OK when the coin cell is full, but after a few days of using it the logger collapses the power source when writing to SD memory card. Memory card can pull as much as 100mA during writing, and the absolute maximum for CR2477 seems to be around 15mA.
<...>
I understand you are moving to flash-based storage which is good. But I thought I would comment on the SD-Card issue.
As you are aware, the SD card can consume bursts of high-current from a battery powered device. The bigger issue is that the voltage drop at the SD card can drop and cause write failure.

The primary issue for the voltage drop is the combined wiring resistance and the lithium cell internal resistance.
In general, the IR of lithium coin
cells is significantly higher than what is found in other common battery chemistry
systems. For example, the starting IR of a 2032 battery is near 10 ohms, the starting IR
of an E92 AAA alkaline battery is near 0.3 ohms. This difference in IR is caused by
different constructions and active materials used in each battery.
Reference PDF: http://data.energizer.com/pdfs/lithiumcoin_appman.pdf

The voltage drop can be mitigated to a degree by using a supercap directly at the SD card Vcc. Even with serial write memory, good Vcc bypassing must be accomplished although a supercap is likely an overkill.
Image
Source: https://edwardmallon.wordpress.com/2017 ... in-review/

Ray

headcra6
Posts: 5
Joined: Wed Jan 03, 2018 10:35 am

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by headcra6 » Thu Jan 04, 2018 8:47 pm

zoomx wrote:
Thu Jan 04, 2018 9:51 am
https://edwardmallon.wordpress.com
Hey, this is a treasure trove of information on power-saving! And it's not just theory. I could use that, thank you!

headcra6
Posts: 5
Joined: Wed Jan 03, 2018 10:35 am

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by headcra6 » Thu Jan 04, 2018 9:06 pm

Thank you for your highly elaborated comment, Ray!
mrburnette wrote:
Thu Jan 04, 2018 3:07 pm
The bigger issue is that the voltage drop at the SD card can drop and cause write failure.
Yes, that's exactly what I've been trying to overcome. Without the additional capacitor connected to SD card power the write operation would fail with FR_DISK_ERR code because the coin cell's voltage dropped to about 2V (which is OK for uC but too low for memory card). When I soldered on the capacitor - well, just turning on the memory card via load switch IC completely collapsed the coin cell for about 5 seconds. Looks like the initial surge of current into the cap does that.
mrburnette wrote:
Thu Jan 04, 2018 3:07 pm
The voltage drop can be mitigated to a degree by using a supercap directly at the SD card Vcc.
How could I not have thought of that! Supercaps are super handy in situations like this one, but they always slip my mind somehow. I suppose connecting it to SD card's supply would do the same thing I described above, only worse. A supercap directly at the coin cell though... I'll have to try that!

User avatar
mrburnette
Posts: 2216
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by mrburnette » Thu Jan 04, 2018 11:37 pm

headcra6 wrote:
Thu Jan 04, 2018 9:06 pm
<...>
How could I not have thought of that! Supercaps are super handy in situations like this one, but they always slip my mind somehow. I suppose connecting it to SD card's supply would do the same thing I described above, only worse. A supercap directly at the coin cell though... I'll have to try that!
Yes, BUT not if you pre-charge the supercap through a small resistance using a much larger capacity battery of the same chemistry. I use one of the current limited lab power supplies on my bench. Assume the cap is a dead short (initially) and calculate the resistance from the max current specified in the supercap datasheet. (Only needed at battery-change. After battery is inserted, the internal R of the coin cell will limit current flow in addition to wiring resistance.)

Ray

ag123
Posts: 854
Joined: Thu Jul 21, 2016 4:24 pm

Re: Temperature logger with Bluepill, microSD card and DS18B20

Post by ag123 » Sat Jan 06, 2018 10:00 am

i used 1 of those 10,000 mah LIPO power bank, last 'forever' in my use case hardly switched on, occasional logging, last for ages, recharge once in a while, place VBAT on a coin cell keeps the rtc running literally perpetually :mrgreen:
https://www.ebay.com/sch/i.html?_nkw=powerbank&_sacat=0

i'm thinking 2xAA alkaline batteries is probably sufficient to power a BP/MM for quite some time even including a ILI9341 lcd and SD card + logging etc, the batteries should be connected directly to 3.3v rails

one thing about LIPO power banks though, for several lipo power banks i tried, it shuts down if the current drawn is too low, that proves to be a frustrating drawback. then i tried an unbranded made-in-china lipo powerbank bought locally, it turns out this particular power bank don't shutdown on low currents, and i'm able to use it pretty much as a 5v battery supply

another thing which i've thought about but didn't try is if the amount of data is minimal, i could literally find a way to write that in the unused flash memory on stm32 itself, i'd think that'd reduce current/power draw quite a bit, but it may possibly reduce the lifespan of the stm32 given the repeated flash re-writing

Post Reply