I am working with the LV-MaxSonar EZ2 and a Raspberry Pi 3 model B. As you know, The Raspberry Pi can not read analog input, that's why I used an ADC (analog to digital converter), an MCP3008 to convert the analog-volt to a digital input for the the raspberry. I followed this tutorial : [u]https://github.com/alx-s/RPi_tutorials/tree/master/Analog_inputs-MaxBotix[/u]
Except that I wired the VREF pin of the MCP3008 to the 3.3V pin of the raspberry (because I tried with the 5V pin, but it didn't work).
After running the script, I got a logical output. However, there was an error rate that grows with the distance between the sensor and the object. The following examples explain that :
An object that is 16 cm away from the sensor ----> the output is 21 cm
An object that is 17 cm away from the sensor ----> the output is 21 cm
An object that is 18 cm away from the sensor ----> the output is 21 cm
An object that is 19 cm away from the sensor ----> the output is 24 cm
An object that is 35 cm away from the sensor ----> the output is 42 cm
An object that is 56 cm away from the sensor ----> the output is 66 cm & 67cm
An object that is 70 cm away from the sensor ----> the output is 84 cm
An object that is 84 cm away from the sensor ----> the output is 96 cm
Since I got these errors, I decided to try Arduino.
At first, I used an Arduino Nano, and followed the tutorial in published by Maxbotix in their website , link : [u]https://www.maxbotix.com/Arduino-Ultrasonic-Sensors-085/[/u]
Since the Arduino Nano does not contain Pwm pins, I used the Analog-Volt code for a single sensor from the same website (Maxbotix website) and I followed the whole tutorial. The results that I got were closer than with the Raspberry Pi, but they were not precise:
An object that is 30 cm away from the sensors ----> the output is 27.84 cm
An object that is 25 cm away from the sensors ----> the output is 22.94 cm
Since the results were not precise, I decided to use an Arduino Uno this time. I used both the Pwm and the Analog-Volt and I got the same error rate as with the Arduino Nano.
I even tried different sensors, but I got the same errors.
So please, If you have any advices or recommendations about this problem, please mention them. Thank you.