![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Temperature dashboard assignment
Dependencies: EthernetInterface LM75B mbed-rtos mbed
Fork of temperature-dashboard-start by
Diff: TemperatureSensor.cpp
- Revision:
- 17:c8a4886ba688
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TemperatureSensor.cpp Sat Jan 16 17:13:41 2016 +0000 @@ -0,0 +1,19 @@ +#include "TemperatureSensor.h" +#include "LM75B.h" +#include <mbed.h> +#include <string> + + +TemperatureSensor::TemperatureSensor(PinName sca, PinName scl, std::string key, std::string name) + :LM75B(sca,scl){ +this->key = key; +this->name = name; +this->sca = sca; +this->scl = scl; +} + +std::string TemperatureSensor::getDataPacket(){ + char buffer[100]; + sprintf(buffer,"{\"key\":\"%s\",\"title\":\"%s\",\"temperature\":\"%f\"}", key.c_str(), name.c_str(), temp()); + return string(buffer); +} \ No newline at end of file