Hi,
I’ve been writing a simple code to register to bucket each time motion is detected.
void loop() {
thing.handle();
unsigned int pir = digitalRead(PIR);
if (pir == HIGH && pir != status) {
Serial.println("Motion detected");
digitalWrite(LED, LOW);
bool done = thing.stream(thing["motion"]);
Serial.print("Push data ");
Serial.println(done ? "ok" : "failed");
status = pir;
} else if (pir == LOW && pir != status) {
Serial.println("Motion ended");
digitalWrite(LED, HIGH);
bool done = thing.stream(thing["motion"]);
Serial.print("Push data ");
Serial.println(done ? "ok" : "failed");
status = pir;
}
}
How come this is not registered properly to the bucket? When i display it at the dashboard, it reacts immediatly, but when register a bucket on the motion sensor, it only registers a few events. The bucket is created as “updated from device”.
Serial.println("Adding PIR");
thing["motion"] >> [](pson& out){
out = digitalRead(PIR);
};
Any tips are welcome!
Kind Regards, Kristian