From 4c6444650da3a0aa1e2e9b00f42cc4e2af057fe6 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 18 Jun 2014 11:48:46 +0200 Subject: initial commit Signed-off-by: Florian Pritz --- src/main.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..d8122a6 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include + +// Pin setup +const int oneWirePin = 7; +const int dhtPin = 2; +#define DHTTYPE DHT22 + +#define BUFSIZE 32 + +OneWire oneWire(oneWirePin); +DallasTemperature sensors(&oneWire); +DHT dht(dhtPin, DHTTYPE); + +void setup () { + Serial.begin(9600); + dht.begin(); +} + +void loop () { + sensors.requestTemperatures(); + + float t1 = sensors.getTempCByIndex(0); + + float t2 = dht.readTemperature(); + float h1 = dht.readHumidity(); + + char temp[BUFSIZE]; + + // format: t:1= t:2= h:1= + String line = ""; + line += 0; + + line += " t:1="; + dtostrf(t1, 5, 2, temp); + line += temp; + + line += " t:2="; + dtostrf(t2, 5, 2, temp); + line += temp; + + line += " h:1="; + dtostrf(h1, 5, 2, temp); + line += temp; + + + Serial.println(line); + delay(10000); +} -- cgit v1.2.3-24-g4f1b