Read the temperaure in celsius and then convert to Fahrenheit degrees, and also display the value on the serial port.

Dependencies:   Hotboards_temp mbed

Files at this revision

API Documentation at this revision

Comitter:
Hotboards
Date:
Tue Mar 22 22:09:37 2016 +0000
Commit message:
first release

Changed in this revision

Hotboards_temp.lib Show annotated file Show diff for this revision Revisions of this file
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
diff -r 000000000000 -r 44c15fe6cc16 Hotboards_temp.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hotboards_temp.lib	Tue Mar 22 22:09:37 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Hotboards/code/Hotboards_temp/#f850ee1083ba
diff -r 000000000000 -r 44c15fe6cc16 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 22 22:09:37 2016 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+/*
+ Hotboards temp Library - Farenheit degrees
+ Read the temperaure in celsius and then convert to Farenheit degrees, and also display
+ the value on the serial port.
+ The circuit 
+ *  VDD   -->  3.3v
+ *  SDA   -->  PB_9
+ *  SCL   -->  PB_8
+ *  ALERT -->  PB_13
+ *  GND   -->  GND
+ Library and example created by Diego from Hotboards
+ Ported to mbed by Pedro from Hotboards
+ This example code is in the public domain.
+ */
+#include "mbed.h"
+#include "Hotboards_temp.h"
+
+Serial pc(USBTX, USBRX);
+//I2C bus instance for the library
+I2C device( I2C_SDA, I2C_SCL ); 
+// instance a sensor with address number 7 (none of the jumpers on the board is short circuited)
+// and also 0.5 celsius degrees resolution
+Hotboards_temp sensor( device, Sensor_7);
+
+
+
+int main( void ) 
+{
+    
+    // init sensor
+    sensor.init();
+ 
+    while(1)
+    {           
+         // read temperature in celcius degrees
+         float temp = sensor.read();
+         // convert celcius to fahrenheit
+         float tempF = sensor.CelsiusToFarenheit( temp);
+         // print it on the serial port
+         pc.printf("Temp sensor : %3.1f F\r\n",tempF);
+         // take the next value after 2 sec (just to not read too often)
+         wait(2);
+    }
+}
diff -r 000000000000 -r 44c15fe6cc16 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 22 22:09:37 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file