GHI released range sensing module using the HC-SR04. I had previously purchased an HC-SR04 and tried using a breadboard for it. My non-GHI HC-SR04 didn’t work well. At best it would only work within an 6-20cm range. The GHI module looks very different and works well from 6 to 250cm.
To test the module, I created a simple range sensing camera. The camera will only take pictures if an object moves within a 50 -100cm of the sensor.
This full solution can be found on my Gadgeteer GitHub repository.
As usual, the setup is fairly simple:
Assembly is equally easy
I setup a simple timer which gets the distance from the range sensor. I write the distance to the console to ensure the range sensing works. The rest of the code is standard camera capture code.
void timer_Tick(GT.Timer timer)
{
int distance = distance_US3.GetDistanceInCentimeters(5);
Debug.Print("Distance : " + distance);
if (distance > 50 && distance < 100)
{
if (camera.CameraReady)
{
camera.TakePicture();
}
}
}
This module is trivial to use and works very well. If you’re looking for a range sensing module the GHI module is your best bet for ease of use.