A
A
andrewMus2021-02-27 15:59:21
Python
andrewMus, 2021-02-27 15:59:21

Bluetooth and raspberry pi, how to connect to HC-05 raspberry pi or laptop via python (RFCOMM)?

Here is the code I found

import socket

baddr = 'D4:36:39:6D:B6:4D'
channel = 4
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.connect((baddr, channel))
s_sock = server_sock.accept()
print ("Accepted connection from " + address)

data = s_sock.recv(1024)
print ("received [%s]" % data)

s.listen(1)

In this case, using socket
I want to do something similar to the terminal.
(the task is to send commands to the module and arduino from the raspberry instead of the phone)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question