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

    Paired by Bluetooth the Lopy with a Android mobile

    Scheduled Pinned Locked Moved LoPy
    blepairedmobilesmartphonebluetooth
    8 Posts 6 Posters 3.7k Views 6 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.
    • X Offline
      xallano
      last edited by livius

      Hello everyone,

      I begin on the bluetooth and the lopy.

      I made a Android application using bluetooth, for now it's just giving order to change the led color for testing and see if the connection bewteen the lopy and the smartphone working, but the goal is to read some data (for example sensor connected on the lopy) or give order.

      I need first be paired, then I launch the application which list all devices paired, then I can choose the device for read/write data.

      So, my problem is when I try to pair my smartphone on the Lopy, the Lopy seems to connect (the consol print "connected") on the mobile, but the mobile cannot pair. I use example code on the documentation (link below) but I'm lost.

      https://docs.pycom.io/pycom_esp32/library/network.Bluetooth.html

      Here, the code I use :

      from network import Bluetooth
      
      bluetooth = Bluetooth()
      bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890123456')
      
      def conn_cb (bt_o):
          events = bt_o.events()   # this method returns the flags and clears the internal registry
          if events & Bluetooth.CLIENT_CONNECTED:
              print("Client connected")
          elif events & Bluetooth.CLIENT_DISCONNECTED:
              print("Client disconnected")
      
      bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
      
      bluetooth.advertise(True)
      
      

      I have 2 mobiles phone, one is 4.1.2, the other is 5.1

      If someone can give me some help, it would be nice.

      Thanks, and sorry for my english.

      I 1 Reply Last reply Reply Quote 1
      • I Offline
        Innocenzo @xallano
        last edited by

        @xallano Hi, I had the same problem with WiPy 2.0 with an old firmware. In these days I try with the latest firmware which has made many changes on BT.

        Anyway, what is your LoPy firmware? Try:

        import os
        os.uname()
        
        1 Reply Last reply Reply Quote 0
        • X Offline
          xallano
          last edited by

          I have the lastest so 1.6.12.b1

          1 Reply Last reply Reply Quote 0
          • J Offline
            jmarcelino
            last edited by

            The LoPy cannot currently pair (at least in the Bluetooth pairing sense) however you can just scan for it and connect from your Android app without pairing.

            For that you'll also need to create some services and characteristics in your Python code, see the GATTSCharacterist example https://docs.pycom.io/pycom_esp32/library/network.Bluetooth.html#class-gattscharacteristic

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              panos29 @jmarcelino
              last edited by

              @jmarcelino so it's possible to send big amounts of data from like a sensor on the wipy to my android device via BT?

              1 Reply Last reply Reply Quote 0
              • J Offline
                jmarcelino
                last edited by

                @panos29
                Well you can send as much data as you want over Bluetooth - but it'll be slow

                1 Reply Last reply Reply Quote 0
                • G Offline
                  Gaby
                  last edited by

                  Hey xallano,

                  I know it is a one-year-old post. However, I am trying to connect an Android device to a Lopy, to eventually send data from my android device to the Lopy.
                  What have you done so far? Can you provide me with the source code for both the Android App and the Lopy?

                  Thank you.

                  1 Reply Last reply Reply Quote 0
                  • Z Offline
                    zhongyuan ren
                    last edited by

                    Have you solved this problem?

                    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