With this libary you can read the I2C tempsensor off the appboard.
Revision 0:1a9f04f52745, committed 2015-12-25
- Comitter:
- de_geeter_alexander
- Date:
- Fri Dec 25 20:41:34 2015 +0000
- Commit message:
- With this libary you can read the temperatuur of the I2C sensor of the appboard.
Changed in this revision
TemperatureSensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
TemperatureSensor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 1a9f04f52745 TemperatureSensor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TemperatureSensor.cpp Fri Dec 25 20:41:34 2015 +0000 @@ -0,0 +1,22 @@ +#include "MbedJSONValue.h" +#include "TemperatureSensor.h" + +TemperatureSensor::TemperatureSensor(PinName SDA, PinName SCL, std::string key, std::string name) : + LM75B(SDA, SCL) +{ + this->key=key; + this->name=name; + +} + +std::string TemperatureSensor::getDataPacket(void) +{ + char buffer[100]; + MbedJSONValue jstring; + jstring["data"][0]=name; + jstring["data"][1]=key; + jstring["data"][2]=temp(); + std::string s = jstring.serialize(); + return s; + +} \ No newline at end of file
diff -r 000000000000 -r 1a9f04f52745 TemperatureSensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TemperatureSensor.h Fri Dec 25 20:41:34 2015 +0000 @@ -0,0 +1,18 @@ +#ifndef TEMPERATURESENSOR_H +#define TEMPERATURESENSOR_H + +#include "LM75B.h" +#include <string> + +class TemperatureSensor : public LM75B +{ +public: + TemperatureSensor(PinName SDA, PinName SCL, std::string key, std::string name); + std::string getDataPacket(void); +private: + std::string name; + std::string key; + +}; + +#endif \ No newline at end of file