Fixing common problems

While building the project, many of us will not get the output the first time. Let's solve the common problems collaboratively. There are some frequently occurring problems while building the projects with the RasPi and the ultrasonic sensors.

Is it showing the distance incorrectly?

You are so enthusiastic to write the code by yourselves, and you might have been mistaken. Check the timings of turning the trigger pin for the perfect amount of time, and check whether you have read the echo pin correctly.

Some of the device response may be slow. I recommend that you add a delay of 60 ms after making the trigger pin low, as shown in the following code:

GPIO.output(23, False)
time.sleep(0.06)

If you are still not getting the result, try playing around with these values of delay. Also, check for the correct indentation of the code, which might be the major reason that you are facing the problem.

There is a high chance that you may be having so many things on your table that the reflections are very high, as this sensor has a wide angle of sensitivity. If the sensor is touching any object or metallic surface, then in this case also there is a chance to get a false reading.

Is the module not responding?

There can be many reasons when the module doesn't respond. Either you are not powering the RasPi with the adequate amount of current, or the connections are not proper on the breadboard. The sensor can take quite a high amount of current. You might be in need to connect the 5V, 1A charger or adaptor to your RasPi. Check whether the resistors connected are of correct values either using the resistor color-coding method or using the multimeter. Take the multimeter and change the delay value in program to 5 seconds after turning on the trigger pulse. Check whether pin 16 is getting high or not. RasPi's pin 16 should show 3.3V reading on the multimeter.

Are you measuring the distance less than 2 cm?

The sensor will not respond if any obstacle is very close to it. It is very hard for the sensor to measure a very small distance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.63.5