Experiences with CR2032 battery backup?

Thank you rickkas7; this works fine.

Hi rickkas7,
A month or so ago you suggested to use your utility to read the VBAT from a Photon, and that was very helpfull for the application that I was working on at that time.

Now I have another application, where I am not interested in reading VBAT, but I sure would like to read the internal sensor temperature. However in that application I do not have an unused input pin available. Is there a possibility to read the internal temperature without the need for an unused pin???

@Jan_dM, if you look back on @rickkas7’s utility, he clearly shows code for reading the internal temperature. However, this only applies to STM32F205 based devices - Photon and Electron.

That’s true, but as you can see it uses a global object photonVBAT (A7, 6.54, 943) in which A7 refers to an unused input. And that is exactly my issue: in my application I have no unused inputs.
So my question is: is there a way to read the temperature in another way (i.e. without the need for an unused input)

peekay123 can you please comment on my reply to your reaction?

@Jan_dM, @rickkas7’s approach is the only one. However, he uses a “spare” analog input as a “trick” to get around some issues with getting accurate readings. @rickkas7, did you test NOT using an analogRead() and doing two consecutive reads instead?

The spare pin doesn’t actually have to be an unused analog input. It can be a pin that you are using as an analog input if you do one extra step. Say you’re using pins A0 and A1 for analog inputs and you don’t have any other spare pins.

Set the photon-vbat spare pin to A0. Since it’s already an analog input it will be fine. However, after reading the battery or temperature, also analogRead(A1). This is necessary because you need to read a different pin in order for device OS to reset all of the necessary settings. Using a spare pin assures it’s always a different pin, but reading two used pins also works.

1 Like

Thank you rickkas7; I will try this next week.