ADC internal channels read example.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
bcostm
Date:
Tue Nov 15 10:04:05 2016 +0000
Child:
1:55c36e464885
Commit message:
Initial version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 15 10:04:05 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file