#include <Notecard.h>
#include "DHT.h"
Notecard notecard;
DHT dht(2, DHT22);
void setup() {
Serial.begin(115200);
notecard.begin();
dht.begin();
Serial.println(F("Setting up the notecard... "));
J *req = notecard.newRequest("hub.set");
JAddStringToObject(req, "product", "com.urishaked.uri:undefined_gravity");
notecard.sendRequest(req);
Serial.println(F("Done"));
Serial.println(F("Notecard configuration: "));
req = notecard.newRequest("hub.get");
J *res = notecard.requestAndResponse(req);
Serial.println(JPrint(res));
}
void loop() {
Serial.print(F("Reading temperature... "));
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
Serial.println(temperature);
Serial.print(F("Sending to Notehub..."));
J *req = notecard.newRequest("note.add");
if (req != NULL) {
JAddBoolToObject(req, "sync", true);
J *body = JCreateObject();
if (body != NULL) {
JAddNumberToObject(body, "temperature", temperature);
JAddItemToObject(req, "body", body);
}
notecard.sendRequest(req);
}
Serial.println("Done!");
Serial.println("Sleeping for 5 seconds");
delay(5000);
Serial.println();
}
Loading
notecarrier-a
notecarrier-a