Description
I was tinkering around with the HC-SR04 Ultrasonic Rangers and I figured I’d use them to try and detect hand motion in the form of “swipe” gestures. In the module’s current form it allows you to detect swiping left or right along with a “press” (when both sensors are covered). The module then sends a notification & payload to other modules for their usage.
It has a calibration mode which allows you to see the raw distance data from each sensor so you can determine what a good “detection” distance is. I use 20cm for mine. There is also a “verbose” mode which will show you the “swipes” on the screen so you can see if it works for you. The normal mode is invisible, since it is used to send data to other modules for their use.
The issue I ran into was permissions. I couldn’t figure out a way to use the GPIO portion of the pi without running MagicMirror using sudo npm start
Screenshots
Calibrate Mode
This will constantly update with both sensor’s distances. You can see that I put my hand in front of the right sensor. This is used to tweak the initial trigger distance (how far out from the sensors you want to have your hand to register a movement).
Verbose Mode
This will show you when you perform a swipe or press movement. The program waits for a trigger by you putting your hand in front of a sensor, then it looks to see if you move it away and put it in front of the other sensor. This will give you a swipe. If you put your hand in front of both sensors at the same time, it give you a press.
Here’s the testbed so you can see the wiring.
Download
[card:mochman/MMM-Swipe]