Driver for TMP06 temperature sensor. Data is sent by PWM. Tested on Hani-IoT board with TMP06BRTZ sensor.
Example usage
main.cpp
#include "mbed.h" #include "TMP06.h" int main() { TMP06 temp_sensor(P0_1); float temperature; while (true) { if(temp_sensor.read(&temperature) == SUCCESS) { printf("Temperature: %f\n", temperature); } else { printf("Error!\n"); } ThisThread::sleep_for(2000); } }
Diff: TMP06.h
- Revision:
- 2:1ff2f041925a
- Parent:
- 0:cee46eec60a8
--- a/TMP06.h Tue Feb 25 11:36:34 2020 +0100 +++ b/TMP06.h Tue Mar 03 14:28:12 2020 +0100 @@ -7,7 +7,7 @@ #define SUCCESS 0 #define FAILURE 1 -#define SEM_TIMEOUT_MS 200 +#define SEM_TIMEOUT_MS 250 class TMP06 { public: @@ -24,6 +24,7 @@ Timer _timer2; Semaphore _semaphore; bool _first_run; + bool _started; }; #endif /* _TMP06_H_ */ \ No newline at end of file