Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:bd554f9d9a54
- Child:
- 1:55c36e464885
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Nov 15 10:04:05 2016 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+#define AMBIENT_TEMP 25.0f /* Ambient Temperature in °C */
+#define VSENS_AT_AMBIENT_TEMP 760.0f /* VSENSE value in mV at ambient temperature */
+#define AVG_SLOPE 25.0f /* Average slope in mV/°C multiplied by 10 */
+#define VREF 3300.0f /* Device power supply in mV */
+
+AnalogIn tempsensor(ADC_TEMP);
+
+DigitalOut led(LED1);
+
+int main()
+{
+ float meas_f;
+ float JTemp_f;
+
+ printf("\nSTM32 Internal Temperature Sensor example\n");
+
+ while(1) {
+
+ meas_f = tempsensor.read();
+
+ /* Compute the Junction Temperature value
+ JTemp = ((Vsens - V25)/Avg_Slope) + 25°C
+ The internal temperature sensor supports a temperature range of –40 to 125°C with an accuracy of +/-1.5°C. */
+
+ JTemp_f = (((meas_f * VREF) - VSENS_AT_AMBIENT_TEMP) * 10.0f / AVG_SLOPE) + AMBIENT_TEMP;
+
+ printf("Internal Temperature = %.1f degree C\n", JTemp_f);
+
+ led = !led;
+ wait(1.0);
+ }
+}