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

    Connecting two esp32 devices via bluetooth using micropython

    Scheduled Pinned Locked Moved MicroPython
    1 Posts 1 Posters 54 Views 1 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
      Billy Kimber
      last edited by

      I want to transfer joystick data from one esp32 to another, so that I can make a remote controlled car. I'm having trouble connecting the two esp32 devices. I asked chatGPT and it gave me many codes using the bluetooth module and the BluetoothSocket class, but it seems like the BluetoothSocket class ins't in the bluetooth module.
      import bluetooth

      This is the code:

      Set the MAC address of the other ESP32 device

      other_device_mac = "yy:yy:yy:yy:yy:yy"

      Create a Bluetooth socket and listen for incoming connections

      sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
      sock.bind((other_device_mac, 1))
      sock.listen(1)

      Wait for a connection from the other device

      print("Waiting for connection...")
      client_sock, client_info = sock.accept()
      print("Accepted connection from", client_info)

      Receive data from the other device

      data = client_sock.recv(1024)
      print("Received data:", data.decode())

      Close the client socket and the Bluetooth socket

      client_sock.close()
      sock.close()

      I get this error:

      Traceback (most recent call last):
      File "<stdin>", line 7, in <module>
      AttributeError: 'module' object has no attribute 'BluetoothSocket'

      Does anyone have any suggestions to help connect the two esp32a via bluetooth, so that data transfer is possible?

      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