我尝试使用带有arduino uno的HC-05蓝牙模块发送数据。我在发送和接收数据方面都很成功。但是,接收的数据不是人类可读的。我正在使用pybluez连接到模块。以下是收到的数据:
received: ÿ
received: °■
received: ÿ
received: °
received: ÿ°
received: ÿ°
received: ÿ°
received: ÿ°
received: ÿ°
received: ÿ°
这是我的.ino
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
void setup(){
mySerial.begin(9600);
}
void loop(){
if(mySerial.available())
mySerial.write(mySerial.read());
}
这是我的.py
# simple inquiry example
import bluetooth
import sys
addr = "20:16:12:05:69:99"
port = 1
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((addr,port))
print 'connected'
sock.settimeout(15.0)
sock.send('10\r\n')
count = 0
while (count<10):
data = sock.recv(12)
print 'received: %s'%data
sock.send(data)
count += 1
sock.close()