Motion detection to bucket

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! :slight_smile:

Kind Regards, Kristian

Hi!

The problem is that the default data buckets have a limited recording rate (around 1 record per minute), in order to keep the accounts stable. Imagine someone pushing data without any delay or constraint… The dashboards have not such limitation, as the information is not persisted in any place.

Bests