3
votes

I'm trying to make a serial connection between a BeagleBone and my laptop. This is similar to a set-up I've previously used successfully with an Arduino & the laptop. The problem is, while there's clearly a signal passing between the machines, the output seems corrupt.

The BB is connected to a Bluesmirf Silver on TX & RX lines.

I've written a class in Python to handle serial comms. This works fine when communicating between the BB and an Arduino, so I'm pretty convinced I've handled the setting up on pins, mux modes etc okay.

But the same code, when going via the Bluesmirf fails to work. With everything set to 19200 baud 8-N-1, text send from the BB to the laptop arrives as a series of 0xE0 characters. Changing the baud rate (and yes, I'm careful to change it at both ends) can change what appears on the laptop - sometimes nothing gets through, sometimes it's apparently random. Mostly, though, the bytes appear to have a high value. At 19200, the number of bytes shown coming through is two or three bytes more than the number of characters sent.

Having defined self.serPort as a serial port using Serial() (ie, PySerial), I use the following to send the text (which is passed as a string 'sendStr'):

self.serPort.write(sendStr.encode('utf-8', 'replace'))

I've tried using 'ascii' instead of 'utf-8'

In the same program, I send the same string in the same way to the Arduino, which echoes it back and everything works fine there. It's just the stuff that goes via the Bluesmirf that's causing me grief.

(For the record, on the laptop, a MacBook Pro, I'm using CoolTerm to send and receive. With my previous setup, with an Arduino communicating with the laptop via the Bluesmirf, the laptop was running a Processing sketch. I tried that same sketch with the BB setup, but still no joy).

Any ideas?

2

2 Answers

1
votes

Well, your problem seems to be due to the fact that you omitted to configure the BlueSMIRF module itself. In fact, the baud rate you specify at your computer side doesn't really matter, because you can use any baud rate and it doesn't have to be the same as that used on the BeagleBone (although if it is higher than the baud rate on the Beagle, you might get buffer overflow errors if you are not careful enough).

The Blue module on the other hand needs to be configured so that the baud rate at its local UART interface (which is linked to your BeagleBone) is the same as the latter's. To do so, refer to the command guide from Roving Network's user manual (which can currently be found here). According to the datasheet you need to:

(1) go into command mode (do this in the first 60 seconds after power-up, you can do all config remotely from your PC to your bluetooth module):

$$$ (DO NOT SEND ASCII 13 & 10 chars)

(2) send command:

SU,19 (PRESS ENTER, i.e. send ASCII 13 & 10 chars)

This will set your RN-42 module on your BlueSMIRF to 19200 baud, same as your BeagleBone. You should stop seeing the errors you see (which, from what I can infer from your comments, is probably due to a BlueSMIRF baud rate being set at 57.6 K).

Please note that the module needs to be reset after you are done configuring it.

0
votes

How did you connect bluetooth via USB? You must use code like :

import serial as s
device = "/dev/tty01"
s.Serial(device, 4800)

What is the name of USB port in BBB? or how did you list USB ports in BBB?