Temperature dashboard assignment

Dependencies:   EthernetInterface LM75B mbed-rtos mbed

Fork of temperature-dashboard-start by Sille Van Landschoot

TemperatureSensor.cpp

Committer:
gimohd
Date:
2016-01-16
Revision:
18:61724d00e95d
Parent:
17:c8a4886ba688

File content as of revision 18:61724d00e95d:

#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);
}