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

    LoRa and BLE simultaneously

    Scheduled Pinned Locked Moved LoPy
    3 Posts 2 Posters 294 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.
    • S Offline
      sarthak04
      last edited by

      Hello everyone!
      I started working on LoPy a while back and it's been fun so far. Right now, as per my project requirements, I'm supposed to use BLE and LoPy simultaneously. But I'm stuck because I want to send the messages over LoRa at an interval of 30 seconds if there is no BLE beacon around, and send a message as soon as any beacon is detected (This means BLE is always in scanning mode). And I'm not able to use time.sleep() as it stops BLE scanning too. So, I would appreciate some help addressing the issue.
      Thanks :)

      C 1 Reply Last reply Reply Quote 0
      • C Offline
        crumble @sarthak04
        last edited by

        The easy way is to remember the time like lastLoRa = rtc.now() and check each couple of iterations if 30 seconds are past and set the lastLoRa after you have send a message.

        The nicer way is to seperate LoRa and Bluetooth into seperate threads, so that the LoRa thread can sleep without blocking the Bluetooth thread

        S 1 Reply Last reply Reply Quote 2
        • S Offline
          sarthak04 @crumble
          last edited by sarthak04

          @crumble Thanks for the quick reply.

          I had tried a similar thing with Chrono earlier, but it failed because while executing, if that section of code isn't encountered within the stipulated time, then it skips it and the model would lose a message.

          This is the sample code I had tried (For testing purpose, I kept the interval of 5 seconds):

          #When no beacon nearby
          else:
            chrono = Timer.Chrono()
            chrono.start()
            if (chrono.start() or 5<chrono.read()<=6):
                 s.send(msg)
                 if (s.send(msg)):
                       print("Message Sent")
            chrono.reset()
          
          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