Motion Detector
Last updated
Was this helpful?
Last updated
Was this helpful?
Working with a sensor or sensor works as described in the general article on . In this article, we assume you have successfully initialized the devices with the , and you stored all connected devices on a global variable devices
. We also declared a global variable called motionDetector
.
Next, we need to know the device identifier, which 292 (Motion Detector 2.0) or 233 (Motion Detector 1.0):
Once we have a reference to the sensor, we can register a callback function:
Of course, we have to actually define the function:
In the callback function motionDetected()
, we can access the information about the event via the val
parameter:
The motion detector sends to types of events:
One type motion_detected
, when the sensor detects a new motion.
Following a few seconds after a motion was detected, we get an event detection_cycle_ended
, that signals that the sensor is now ready to detect another motion.