If the Bluetooth dongle you're talking about is something like this: Nordic nRF51 Dongle
(first Google hit), that plugs in to USB, there's no need to connect it to the Pi's serial I/O pins. Just plug it into a USB port on the Pi.
I have an app that reads "serial" data from an Arduino that's plugged into a USB port on the Pi, using a library called PySerial
that should already be on your Pi. Reading and printing data is as easy as this:
Code: Select all
port = '/dev/ttyACM0'
bps = 57600
ser = serial.Serial(port, bps)
line = ser.readline() # read bytes until line-ending
line = line.decode(encoding='UTF-8') # convert to string
line = line.rstrip('\r\n') # remove line-ending characters
You could likely start from there (copy into a file called, say, "usbcat", then "chmod 755 usbcat", and then run it with "./usbcat" and stop it with control-C), change the port and speed to meet your needs (the setup call to Serial can take all sorts of other parameters as needed), and have a bit of code that you can expand to do whatever you want with the device.