Raspberry with Maxbotics
I have tried Raspberry Pi with Ultrasonic HCSR 04 Sensor. I have written a program for that. I got a proper result, but I am facing some reliability issue with that. So I thought I will use other sensors.
Statement 2: I bought Maxbotics sensor MB 1040. I have written program in python, I got readings but that is not proper reading, I have not achieved accuracy. Kindly assist me solve this issue. Here I have attached program
import RPi.GPIO as GPIO
GPIO_TRIGECHO = 15
print "Ultrasonic Measurement"
GPIO.output(GPIO_TRIGECHO, True) time.sleep(0.00001) GPIO.output(GPIO_TRIGECHO, False) start = time.time() GPIO.setup(GPIO_TRIGECHO, GPIO.IN) while GPIO.input(GPIO_TRIGECHO)==0: start = time.time() while GPIO.input(GPIO_TRIGECHO)==1: stop = time.time() GPIO.setup(GPIO_TRIGECHO, GPIO.OUT) GPIO.output(GPIO_TRIGECHO, False) elapsed = stop-start distance = (elapsed * 34300)/2.0 time.sleep(0.1) return distance
distance = measure()
print " Distance : %.1f cm" % distance
bucknall last edited by
I think you might be in the wrong place! These forums are for the Pycom (https://pycom.io) products such as the WiPy, LoPy, etc.
It seems as though you are using the Raspberry Pi which uses a different version of Python from that found on our devices! I'll point you towards https://www.raspberrypi.org/forums/ to find some more support for your issue!