The Grove - Human Presence Sensor can be used to detect the presence of the human body or any other infrared objects. As it has four IR sensors, it can be used to detect the motion of the IR object and the relative position where the IR object moves. The locations of the four IR sensors are defined as:
(Please note that the location description of the four IR sensors in the datasheet might be wrong)
This library has two classes - AK9753
and PresenceDetector
. The AK9753
class does basic read/write with the sensor. Taking the AK9753 as an input paramenter, the PresenceDetector
class does some upper level calculation based on the readings from the sensor.
The sensor needs an issue of start sample
signal before every conversion. Calling AK9753::startNextSample()
does this trick. The AK9753::startNextSample()
will be called in the PresenceDetector::loop()
method, also in the loop
method, it will read the sensor, do calculations and save the result.
Typically the class you need to use is the PresenceDetector
class, but you need to ensure that AK9753::initialize()
is successful before calling any method of PresenceDetector
.
There're two parameters you might need to adjust:
These parameters are used to determine the sensitivity of the detection. threshold_presence
compares with the derivative of the readings of a specific IR sensor (1/2/3/4). threshold_movement
compares with the derivative of the difference value between IR sensor 1-3 or 2-4. Without a lens, the readings of the IR sensor attenuate very quickly when the distance gets longer. So you need to lower down the threshold in order to detect a distant object.
File name: examples/Example1-BasicReadings/Example1-BasicReadings.ino
This example reads the raw (uint16_t) data of four IR sensors, and print these raw data in the serial.
File name: examples/Example2-DiffPlot/Example2-DiffPlot.ino
This example reads the data of four IR sensors and converts them into current (pA), then plot diff13 and diff24 into the Arduino IDE Serial Plotter.
diff13 = IR1 - IR3 // blue line
diff24 = IR2 - IR4 // red line
File name: examples/Example3-DetectPresence/Example3-DetectPresence.ino
This example detects the presence of IR object. The detection is based on the derivative of the sensor value. If the derivative is greater than a threshold, we think that some IR object entered the view of the sensor.
File name: examples/Example4-PlotMovement/Example4-PlotMovement.ino
The detection is based on the derivative of the difference value of IR1/IR3 or IR2/IR4. The legends of the plot are: (in order)
For more information, please refer to wiki page.
This software is written by Jack Shao for seeed studio and is licensed under The MIT License. Check License.txt for more information.
Contributing to this software is warmly welcomed. You can do this basically by
forking, committing modifications and then pulling requests (follow the links above
for operating guide). Adding change log and your contact into file header is encouraged.
Thanks for your contribution.
Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
Benefiting from local manufacture power and convenient global logistic system,
we integrate resources to serve new era of innovation. Seeed also works with
global distributors and partners to push open hardware movement.