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

    Guru Meditation Error of type LoadProhibited occurred on core.

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy2.0errorcrashultrasonicguru error
    13 Posts 4 Posters 4.5k Views 4 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.
    • B Offline
      bucknall
      last edited by

      Please be aware that there are also a number of difference between the pyboard and the Pycom devices namely that Pycom doesn't use the pyb library and that a number of the standard classes/methods are different.

      Developer Evangelist - Pycom

      1 Reply Last reply Reply Quote 0
      • tobzT Offline
        tobz
        last edited by

        I think my issue might actaully be related to this post: https://forum.pycom.io/topic/1061/https-post-using-urequests-py-and-guru-mediation-error

        the urequest class and nothing to do with the ultrasonic sensor.

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

          @tobz Ah ok, you are using the urequests library? We're looking into this.

          Thanks!

          Developer Evangelist - Pycom

          tobzT 1 Reply Last reply Reply Quote 0
          • tobzT Offline
            tobz @bucknall
            last edited by

            @bucknall Cool. I'll follow along with that thread & hopefully that IS my issue and it gets resolved :)

            RobTuDelftR 1 Reply Last reply Reply Quote 1
            • RobTuDelftR Offline
              RobTuDelft @tobz
              last edited by

              @tobz Did you manage to get the HC-SR04 working after all?

              Without data you're just another person with an opinion.
              Hackster | About me

              tobzT 1 Reply Last reply Reply Quote 0
              • tobzT Offline
                tobz @RobTuDelft
                last edited by tobz

                @RobTuDelft yeah the sensor works fine (once I worked out you need a resistor in the circuit - derp). The crash appears to be caused by the urequest library (see https://forum.pycom.io/topic/1061/https-post-using-urequests-py-and-guru-mediation-error).

                RobTuDelftR 1 Reply Last reply Reply Quote 0
                • RobTuDelftR Offline
                  RobTuDelft @tobz
                  last edited by

                  @tobz That's nice, could you share your code perhaps? Got one of these sensors coming in soon and would help to have a starting point.

                  Without data you're just another person with an opinion.
                  Hackster | About me

                  tobzT 2 Replies Last reply Reply Quote 0
                  • tobzT Offline
                    tobz @RobTuDelft
                    last edited by

                    @RobTuDelft sorry - I've been head down in work - will hopefully get some time later this week & post my code if you're still interested in it.

                    1 Reply Last reply Reply Quote 1
                    • tobzT Offline
                      tobz @RobTuDelft
                      last edited by

                      @RobTuDelft Here's the code I was using for the HC-SR04.
                      I hope it makes sense & works for you.

                      import machine
                      import time
                      import math
                      from machine import Timer
                      
                      class Ultrasonic:
                          def __init__(self, name, trigPin, echoPin, delay = 60):
                      
                              self.name = name
                              self.triggerPin = trigPin
                              self.echoPin = echoPin
                              self.delay = delay
                      
                              self.last_distance = 0
                      
                              # Init trigger pin (out)
                              self.trigger = machine.Pin(self.triggerPin)
                              self.trigger.init(machine.Pin.OUT, None)
                              self.trigger.value(False)
                      
                              # Init echo pin (in)
                              self.echo = machine.Pin(self.echoPin)
                              self.echo.init(machine.Pin.IN)
                      
                          def distance_in_inches(self):
                              return (self.distance_in_cm() * 0.3937)
                      
                          def distance_in_cm(self):
                              start = 0
                              end = 0
                      
                              # Create a microseconds counter.
                              micros = Timer.Chrono()
                              micros.reset()
                              micros.start()
                      
                              # Send a 10us pulse.
                              self.trigger.value(True)
                              Timer.sleep_us(10)
                              self.trigger.value(False)
                      
                              # Wait 'till whe pulse starts.
                              while self.echo.value() == 0:
                                  start = micros.read_us()
                      
                              # Wait 'till the pulse is gone.
                              while self.echo.value() == 1:
                                  end = micros.read_us()
                      
                              # Deinit the microseconds counter
                              micros.stop()
                      
                              # Calc the duration of the recieved pulse, divide the result by
                              # 2 (round-trip) and divide it by 29 (the speed of sound is
                              # 340 m/s and that is 29 us/cm).
                              dist_in_cm = ((end - start) / 2) / 29
                      
                              return dist_in_cm
                      
                          def start(self, threshold, callback):
                              print('Start reading Ultrasonic Sensor')
                              while True:
                                  # get the current distance
                                  distance = self.distance_in_cm()
                      
                                  # if the distance between this reading and the previous one
                                  # and the difference is greater than the threshold then
                                  # run the callback method
                                  if (math.fabs(self.last_distance - distance) > threshold):
                                      print("%s value: %s -> %s at %s" % (self.name, self.last_distance, distance, time.time()))
                      
                                      if callback(self.name, distance) is True:
                                          # set this readding as the previous reading for next run
                                          self.last_distance = distance
                      
                                  else:
                                      print("%s value: %s <-> %s at %s" % (self.name, self.last_distance, distance, time.time()))
                      
                                  time.sleep(self.delay)
                      

                      useage:

                      // init sensor, reading every 60 seconds
                      sensor = Ultrasonic('some-name', triggerPin, echoPin, 60)
                      sensor.start(changeThreshold, callbackMethod)
                      
                      T 1 Reply Last reply Reply Quote 1
                      • T Offline
                        tobru @tobz
                        last edited by

                        @tobz Thanks a lot for sharing the code. How did you connect the sensor to the board? You mentioned something about a resistor you had to use?

                        tobzT 1 Reply Last reply Reply Quote 0
                        • tobzT Offline
                          tobz @tobru
                          last edited by

                          @tobru From memory I think it was a 10k resister - check the spec sheet for the HC-SR04. I probably just attached it straight onto the expansion board, maybe via a breadboard - I can't remember sorry.

                          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