stm32f103 clones
Posted: Sat Aug 17, 2024 6:50 pm
this is a plain old topic
https://hackaday.com/2020/10/22/stm32-c ... -the-ugly/
viewtopic.php?t=2038
https://hackaday.com/2020/10/22/stm32-c ... -the-ugly/
viewtopic.php?t=2038
Everything relating to using STM32 boards with the Arduino IDE and alternatives
https://www.stm32duino.com/
Code: Select all
// specs 5.3.19 temp sensor characteristics
// V 25 deg ~ 1.43v
// slope 4.3 mv/C
float temp = (mv - 1430) * 1.0 / 4.3 + 25.0;
room temperature is 30 deg C (around there)temp sensor analogRead:1597, mvolt:1271, temp(deg C:)-11.98
temp sensor analogRead:1590, mvolt:1266, temp(deg C:)-13.14
Code: Select all
* \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023).
*
* \param res
*/
extern void analogReadResolution(int res);
Code: Select all
void setup() {
pinMode(PAxx, INPUT_ANALOG); // etc
analogReadResolution(12);
}
Code: Select all
uint16_t value = analogRead(ATEMP);
Code: Select all
float mVolt = value / 4096 * 3.3 * 1000; // convert to millivolt
Code: Select all
// specs 5.3.19 temp sensor characteristics
// V 25 deg ~ 1.43v
// slope 4.3 mv/C
float temp = (mVolt - 1430) * 1.0 / 4.3 + 25.0;
Code: Select all
void setup() {
// pinMode(ATEMP, INPUT_ANALOG); // I'm not sure if this is needed at all
analogReadResolution(12);
}
void loop() {
uint16_t value = analogRead(ATEMP);
float mVolt = value * 1000 / 4096 * 3.3 ; // convert to millivolt
// V 25 deg ~ 1.43v
// slope 4.3 mv/C
float temp = (mVolt - 1430) * 1.0 / 4.3 + 25.0;
Serial.print("temp (deg C): ");
Serial.println(temp);
delay(1000);
}