I’m using this IP67 sonar: MB7078 XL-MaxSonar-WRCA with Arduino Mega (i tried to use Arduino UNO, too, but it didn’t solved the problem).
Here you can find the sonar datasheet: http://www.maxbotix.com/uploads/MB7068- … asheet.pdf
I tried to use both the analog sonar output and the PWM one but in both cases i’m not able to read correct values because it always prints random numbers or fixed ones.
For example, if i use the analog output and i try to read the analog value i always have something like sensorValue = 114 and it never changes.
I even tried to directly read values with a voltmeter, but the values seems to be always random.
In the datasheet, there is written:
(AN) This pin outputs analog voltage with a scaling factor of
(Vcc/1024) per cm. A supply of 5V yields ~4.9mV/cm., and 3.3V yields
~3.2mV/cm. Hardware limits the maximum reported range on this output
to ~700 cm at 5V and ~600 cm at 3.3V. The output is buffered and
corresponds to the most recent range data.
int sensorPin = 0; // select the input pin for the potentiometer
int sensorValue = 0;
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
delay(125);
}
I tried to simply print the analog values, but they are random.
I do not think the sonar is broken because i’ve bought in total three sonars (same model) and all of them do not output correct values.
I’m sure i’m not doing it in the correct way.
May be i have to connect some other pin?
Can you help me, please?
I connect the Vcc and GND to Arduino GND and 5VDC and the analog output to analog pin 0 without using a resistor or a capacitors to avoid noise.