I simply asked, if I understand the values correctly ...
fpiSTM wrote: Tue Jul 16, 2024 3:07 pm
Did you test default example ? Did it work?
I can compile and upload, but it doesn't work.
The output is:
Code: Select all
12:12:58.278 -> ----- internal ADC channels -----
12:12:58.342 -> �
The first line is from an additional Serial.printf(), I placed in setup().
And if I add some output at beginning of loop()
Code: Select all
void loop() {
Serial.println("inside loop() ...");
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
bool icache_enabled = false;
I get this:
Code: Select all
12:15:08.358 -> ----- internal ADC channels -----
12:15:08.403 -> i�
one time!
So it doesn't look like loop() is working like a loop.
----------------------------------------------------------------------------------
I moved setup() in front of loop() and add some global variables:
Code: Select all
int32_t VRef;
int32_t temp;
int32_t vbat;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
delay(2000);
Serial.printf("\n\n ----- internal ADC channels ----- \n");
analogReadResolution(12);
VRef = readVref();
temp = readTempSensor(VRef);
vbat = readVoltage(VRef, AVBAT);
Serial.printf("VRef = %imV temp = %i°C Vbat = %imV ", VRef, temp, vbat);
}
Now I get this output:
Code: Select all
12:35:17.469 -> ----- internal ADC channels -----
12:35:17.502 -> VRef = 3281mV temp = 29°C Vbat = 1090mV inside loop() ...
12:35:17.569 -> VRef(mv)= 3281�
Value of VBAT is wrong!
I connected a mignon cell between VB-pin and GND-pin of board. It should be the V
BAT-pin. Even without a cell in battery holder, sketch returns 1,09 V.
This is the part of schematic:

- RTC circuit.png (46.1 KiB) Viewed 3826 times
So measuring of V
BAT is useless.
But sketch should show V
CC.
Is there a bug not taking care about voltage divider? 1,09 * 3 would make sense ..
--------------------------------------------------------------------------------------
I throw away all content from loop() and moved 4 last lines from setup() there.
I placed something out of cooler on chip and temperature is going down.
Code: Select all
12:48:54.207 -> VRef = 3279mV temp = 30°C Vbat = 1090mV
12:48:59.198 -> VRef = 3283mV temp = 30°C Vbat = 1091mV
12:49:04.212 -> VRef = 3283mV temp = 30°C Vbat = 1091mV
12:49:09.186 -> VRef = 3279mV temp = 29°C Vbat = 1088mV
12:49:14.180 -> VRef = 3281mV temp = 30°C Vbat = 1090mV
12:49:19.198 -> VRef = 3283mV temp = 30°C Vbat = 1091mV
12:49:24.169 -> VRef = 3279mV temp = 30°C Vbat = 1089mV
12:49:29.172 -> VRef = 3283mV temp = 24°C Vbat = 1091mV
12:49:34.159 -> VRef = 3281mV temp = 23°C Vbat = 1089mV
12:49:39.178 -> VRef = 3281mV temp = 23°C Vbat = 1089mV
12:49:44.149 -> VRef = 3281mV temp = 22°C Vbat = 1091mV
12:49:49.159 -> VRef = 3283mV temp = 22°C Vbat = 1091mV
12:49:54.145 -> VRef = 3281mV temp = 21°C Vbat = 1091mV
A last remark: example calls two times Error_Handler();
I placed a Serial.println(...) before and forget semicolon at the end. Compiler doesn't complain. So I guess that preprocessor removes those parts.