Bulme lib for temp sensor LM75B
Dependents: mbed-os-example-wifi-ThingSpeak mbed_freeRTOS_send STM_Statemachine
Diff: LM75B.cpp
- Revision:
- 0:29546bb2c7dd
diff -r 000000000000 -r 29546bb2c7dd LM75B.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.cpp Mon Mar 14 13:23:07 2016 +0000 @@ -0,0 +1,19 @@ +#include "LM75B.h" + +LM75B :: LM75B(PinName sda, PinName scl) : i2c(sda, scl) +{ + cmd[0] = LM75B_CONF; // Pointerregister + cmd[1] = 0x0; // Default siehe 7.4.2 Tabelle 8 + i2c.write(LM75B_ADDR, cmd, 2); // Adr., char *, Länge +} + +float LM75B :: read() +{ + cmd[0] = LM75B_TEMP; + + i2c.write(LM75B_ADDR, cmd, 1); // sende Temperatur Befehl + i2c.read(LM75B_ADDR, cmd, 2); // bekommmen den command string + return (float ((cmd[0] << 8) | cmd[1])/256.0); +} + +LM75B :: ~LM75B() {}