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 time
import RPi.GPIO as GPIOGPIO.setmode(GPIO.BCM)
GPIO_TRIGECHO = 15print "Ultrasonic Measurement"
GPIO.setup(GPIO_TRIGECHO,GPIO.OUT)
GPIO.output(GPIO_TRIGECHO, False)def measure()
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 distancetry:
while True:
distance = measure()
print " Distance : %.1f cm" % distance
time.sleep(1)except KeyboardInterrupt:
print("Stop")
GPIO.cleanup() -
Hi @Jen,
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!
Thanks!
Alex
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login