Hardware Reference
In-Depth Information
Figure 13-23: Entrance logger trained on a door
LoggerSoftware
For the entrance logger, reading configuration variables from the SD card is
not particularly useful, so you can remove those parts of the code. You want to
add some code to check the state of the distance and to see whether its readings
have changed drastically between pollings. If they have, you can assume that
something moved in front of the distance sensor and that somebody must have
entered or exited the room.
You also need to choose a “change threshold.” For my setup, I found that an
analog reading change of more than 75 between pollings was a good indication
of movement. (Your setup will probably be different. It's a good idea to check
the values of your system once you have the physical setup fixed.) You want
to make sure you're checking the distance sensor frequently enough that you
capture movement every time. However, it doesn't make sense to run it so often
that you end up with millions of readings for a day's worth of logging.
I recommend that you write to the SD card every time movement is detected,
but that you only periodically write to the SD card when there is no movement.
This methodology strikes a good balance between storage space required and
accuracy. Because you care the most about having accurate timing for when
somebody passes the sensor, that detection is recorded with a higher temporal
resolution than when nothing is happening in front of the sensor. This technique
Search WWH ::




Custom Search