The sensor is enabled (from Read Vcc post):
void setup_vcc_sensor() {
adc_reg_map *regs = ADC1->regs;
regs->CR2 |= ADC_CR2_TSEREFE; // enable VREFINT and temp sensor
regs->SMPR1 = ADC_SMPR1_SMP17; // sample rate for VREFINT ADC channel
}Now it works with
// Reading Vdd and Temperature Sensor
// Pito 8/2016
// Temperature sensor at ADC16, VREFINT at ADC17
// BluePill and Maple Mini
void setup_vdd_tempr_sensor() {
adc_reg_map *regs = ADC1->regs;
regs->CR2 |= ADC_CR2_TSEREFE; // enable VREFINT and Temperature sensor
// sample rate for VREFINT ADC channel and for Temperature sensor
regs->SMPR1 |= (0b111 << 18); // sample rate temperature
regs->SMPR1 |= (0b111 << 21); // sample rate vrefint
adc_calibrate(ADC1);
}
void setup(){
setup_vdd_tempr_sensor();
Serial.begin(115200);
delay(1);
}
void loop() {
float tempr, vdd;
// reading Vdd by utilising the internal 1.20V VREF
vdd = 1.20 * 4096.0 / adc_read(ADC1, 17);
// following 1.43 and 0.0043 parameters come from F103 datasheet - ch. 5.9.13
// and need to be calibrated for every chip (large fab parameters variance)
tempr = (1.43 - (vdd / 4096.0 * adc_read(ADC1, 16))) / 0.0043 + 25.0;
Serial.print("Vdd= ");
Serial.print(vdd);
Serial.println(" V");
Serial.print("Temp= ");
Serial.print(tempr);
Serial.println(" C");
delay(500);
}
Perhaps we should add this function somewhere inside libmaple ??
(any suggestions welcome ![]()
Btw – do we Calibrate the ADCs somewhere in the ADC init code? (there is an ADC self-calibration procedure for STM3210x).
A: there is adc_calibrate(ADC1); available..
Perhaps we should add this function somewhere inside libmaple ??
(any suggestions welcome ![]()
There is only 2.3bit/degC, what is inside the noise background on the BluePill, so the measurement is really rather indicative.
There is only 2.3bit/degC, what is inside the noise background on the BluePill, so the measurement is really rather indicative.
Then measured (BP still in the fridge):
10seconds after power on = -13C
5min after power on = -5C
The readings are noisy, jump +/- 1.5C, so the numbers are rather average.
Interestingly, the Vdd measurement is rock stable, much stable than under ambient temp.
And finally I dipped the BP into boiling water. It stopped sending data almost immediately (last data 40C). Immersing only the crystal part/side of the pcb into the boiling water stops the data, so it seems to me this part is critical. Or the water from my water tap is too conductive ![]()
I did with hair dryer and I got 60C reading (the max of my dryer) while BP worked. I can try harder with my hot air soldering gun but I do not want to remove the chip off the BP’s pcb ![]()
So subtracting 10C from my readings may indicate the ambient temperature with say +/- 2degC accuracy. That is valid for my chip only, of course..
I have an infrared thermometer and I measured the temperature of the GD32 at different clock rates ( I think i probably posted the data to the forum, but it would be ages ago)
I also have a thermocouple thermometer ( but I don’t trust it that much), but I could clip the thermocouple to the top of the STM32 and take a reading if you want.
There is an option to spend winter holidays in Oymyakon, Russia, and open your window for a while when calibrating your BPill
In all seriousness… I suspect there is probably some way to test in a vacuum using fairly readily available items.
Perhaps using a vacuum pump used in commissioning air conditioning systems.
( probably not as good as the vacuum in space, but probably good enough for testing )
But of course, irradiating with heat from the sun while testing in a vacuum would be challenging.
For example try your hoover
“Vacuum” is a common term mostly used for describing “lower than atmospheric pressure”. For example 10000 Pascal.
Vacuum in space (say interstellar space) is something like 0.00000000000000001 Pascal.
I just wondered how good a vacuum you get from a $50 pump used to install air conditioning.
Probably not that good, but I wonder what vacuum you would need to achieve to give a good simulation of orbital space etc.
Unfortunately, I can’t find the specification of the vacuum used when commissioning air conditioning systems.
Good point.
However the 32khz crystal side of the device is still running, so some heat will be generated.. Just , a small fraction as much as when its running at full speed.
../hardware/STM32F1/2016.11.18/libraries/A_STM32_Examples/examples/General/InternalTempSensor/InternalTempSensor.ino
.. but it fails to compile for the generic stm2f103 board with the following error
/home/ahull/.arduino15/packages/stm32duino/hardware/STM32F1/2016.11.18/libraries/A_STM32_Examples/examples/General/InternalTempSensor/InternalTempSensor.ino: In function 'void setup_temperature_sensor()':
InternalTempSensor:22: error: 'ADC_CR2_TSEREFE' was not declared in this scope
regs->CR2 |= ADC_CR2_TSEREFE;
^
exit status 1
'ADC_CR2_TSEREFE' was not declared in this scope
I recall there was a PR / Fix for incorrect definitions in that area. That ADC_CR2_TSEREFE may have been one of them
regs->CR2 |= ADC_CR2_TSVREFE;
The Git PR was
https://github.com/rogerclarkmelbourne/ … /132/files
@stevstrong proposed it, so you could PM him, as he is active at the moment
The Git PR was
https://github.com/rogerclarkmelbourne/ … /132/files
@stevstrong proposed it, so you could PM him, as he is active at the moment
OK.
I’ll try to update it later.
Unfortunately my local copy of the repo has a load of other changes for various things I was hacking about with, so I’ll need to get rid of those (or save them etc) before I can update the example
I’ve edited the sketch file online in github, and committed the change. Can you download it again and test for me as my local repo isnt working at the moment
