Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Raspberry with Maxbotics

    Scheduled Pinned Locked Moved Discussion
    pythonraspberry pimaxbotics
    2 Posts 2 Posters 1.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jen
      last edited by

      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 GPIO

      GPIO.setmode(GPIO.BCM)
      GPIO_TRIGECHO = 15

      print "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 distance
      

      try:
      while True:
      distance = measure()
      print " Distance : %.1f cm" % distance
      time.sleep(1)

      except KeyboardInterrupt:
      print("Stop")
      GPIO.cleanup()

      1 Reply Last reply Reply Quote 0
      • B Offline
        bucknall
        last edited by

        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

        Developer Evangelist - Pycom

        1 Reply Last reply Reply Quote 0

        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
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom