Skip to content

Instantly share code, notes, and snippets.

@Kaniiisek
Created March 14, 2017 12:36
Show Gist options
  • Save Kaniiisek/22ee41c06aa9ac1d93b515be343b1b92 to your computer and use it in GitHub Desktop.
Save Kaniiisek/22ee41c06aa9ac1d93b515be343b1b92 to your computer and use it in GitHub Desktop.
#include <Akeru.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define TX 2
#define RX 3
const int pinCidlaDS = 7;
OneWire oneWireDS(pinCidlaDS);
DallasTemperature senzoryDS(&oneWireDS);
Akeru akeru(RX, TX);
float temperatureInCelsius;
void setup()
{
Serial.begin(9600);
senzoryDS.begin();
if (!akeru.begin())
{
Serial.println("TD1208 KO");
while(1);
}
}
void loop()
{
senzoryDS.requestTemperatures();
Serial.print("Teplota cidla DS18B20: ");
Serial.print(senzoryDS.getTempCByIndex(0));
Serial.println(" stupnu Celsia");
temperatureInCelsius = senzoryDS.getTempCByIndex(0);
String data = akeru.toHex(temperatureInCelsius);
if (akeru.sendPayload(data))
{
Serial.println("Message sent !");
}
for (int second = 0; second < 600; second++)
{
delay(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment