I recently ordered the DFRobotShop Rover Mobile Robot Shield to simplify a simple Arduino-based robot build. The shield itself works well for driving motors and accepting commands via Serial.read() commands on my Arduino Uno.
I’ve hit a wall trying to integrate the BTBee Pro module I ordered at the same time. The BTBee plugs into the shield and powers up fine, and I can establish connections by choosing the BTBee tty port in the Arduino interface and bringing up a serial monitor. The LEDs on the BTBee show a connection (con light goes off, status light stops its constant blinking), but the commands I send have no effect. I was initially trying to drive the motors, but have since backed off to simply debugging by looping Serial.print(“test”) with a delay. This does output something to the serial monitor in a loop, but it’s gibberish. Once in a while, through some magic of resetting the Arduino and/or the BTBee, it will print the correct text once at the very start, but then it goes back to gibberish. I also established that the BTBee seems to be receiving something from the monitor. I used an LED to report the value of Serial.available(), and it returns true when the BTBee is paired and I provide input from the serial monitor.
Any idea what’s going on here? The Arduino Serial communication baud is set to 38400 and the same for the serial monitor, per the BTBee Pro default specs in the documentation. I also tried setting both to 9600 baud just in case, but no dice. I wanted to try reconfiguring the BTBee for 9600 baud in case it would smooth things out, but I have no idea how to issue the required AT commands to the BTBee when I can’t seem to establish a functional connection in the first place.
Any suggestions would be most appreciated! I’m also glad to post more detailed code if that would be useful.
Could you provide us with a few more details about your setup:
]Could you list all the devices you have connected to your Arduino and shield? Maybe provide a picture(s) showing all the connections clearly./:m] ]Could you provide an attachment of the code you are currently using with for this setup?/:m]
We are currently investigating your issue and will reply as soon as we have more information.
void loop()
{
delay(500);
if (Serial.available() > 0) {
blink();
Serial.println(“received, so let’s read”);
incomingByte = Serial.read();
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
if (!Serial.available()){
Serial.println(“no data”);
delay(2000);
}
}
void blink() {
int waitTime = 50;
for (int i = 1; i < 5; i++) {
digitalWrite(led, HIGH);
delay(waitTime);
digitalWrite(led, LOW);
delay(waitTime);
}
}
[/code]
Whenever the DATARATE value in the code is set to 38400, I get gibberish in the serial monitor, whether the monitor is set to 9600 or 38400 baud. It spits back garbled nonsense every 2 seconds if I input nothing, or spits back slightly different garbage if I send something over the monitor, so the loop seems to be operating properly and successfully detecting and reporting data, it’s just unintelligible. If I instead set DATARATE to 9600, I get nothing in the serial monitor.
I don’t have the hardware in front of me just now, but will take a picture once I’m home. I’ve stripped it down to just the shield mounted on the Uno and then the BTBee pro plugged into the XBee slot on the shield (correctly oriented ). Power comes from a USB cable from my laptop to the Uno. I also tried powering off a 3.7v LiPo to the shield and unplugging the USB, but the behavior remains the same.
I’m attaching a photo of the hardware setup and a screen capture from the serial monitor. The junk on the monitor keeps appending every 2 seconds per the code, and it looks the same whether I set the monitor to use 38400, 9600, or any other baud. However, the DATARATE value for serial communication in the Arduino sketch has to be set to 38400; otherwise, I see nothing at all in the serial monitor.
We took one RB-Dfr-583 and one RB-Ite-110 from inventory and tried your code without modifying anything except for the baud rate [9600, 38400, 115200]. Only 115200 worked.
See the attached image for an example of the code running at 115200.
It seems the BT Pro is set to 115200 by default, not 38400. From what we understand of the datasheet, 38400 is the default baud rate in AT mode to configure the device. But, it seems its communication rate is 115200.
Please make sure your BT Pro is set to COM mode, not AT / Upload mode (small switch at the base of the module, see other attached image).
That did the trick! With everything configured at 115200 baud, I’ve got the module talking to my laptop just fine now, and the Arduino is properly interpreting the data coming across Serial. It’s strange that the datasheet I was working from seemingly had the wrong default baud listed, but I’m glad you worked it out.
Many thanks for figuring this out so quickly. With that kind of response, I’ll keep shopping with you guys in the future.
So I have just received a BTBee Pro and am trying to run the exact same code posted be the original poster. I am running it on an Uno with an xbee shield. I have been able to pair the BTBee Pro to my computer successfully. When I run this code over the usb connection everything functions properly. When I try and run it using the Bluetooth connection nothing appears in the serial monitor. The Com light on the BTBee does go off as it should but no messages are being received by the computer or the Arduino (Pin 13 light never blinks as it should in the code). I have the baud rate set to 115200 in the serial monitor and the code. Any help would be greatly appreciated. Thanks!!
The code from the original poster was used on a DFRobotShop Rover Mobile Robot Shield. Which XBee shield are you using? If it is different, it probably requires using different code or pin assignments to function properly.
Did you make sure your shield allows this speed of connection and is properly configured? If you could offer details on which shield you are using it would be helpful.