Me bluetooth character reception


#1

Hello,

I have a problem with the Me Bluetooth Module

I have created an android application which sends a value between 0 and 20 like this :

public void write(String msg) {
try {
byte[] buffer = msg.getBytes(“UTF-8”);
mmOutStream.write(buffer);
} catch (Exception e) { }
}

My arduino code is the following :

MeBluetooth bluetooth(4);

void setup()
{
Serial.begin(9600);
bluetooth.begin(9600);
Serial.println(“Bluetooth Start!”);

}

void loop()
{
unsigned char inDat;
char outDat;
if(bluetooth.available())
{
inDat = (unsigned char)bluetooth.read();
Serial.print(inDat);
}
}

I was hoping to get numbers between 0 and 20 on the serial console but i only get “ÿÿÿ”

Can someone help me please ?


Just trying to read a simply character via Bluetooth
#2

I know nothing about android programming, and it has been a while since I did any programming with my arduino, but in my limited experience (1) I have gotten extraneous characters on the arduino console when the baud rad was not right [e.g., the rate set in the serial console has to match the transmission rate] and (2) to get numbers to display in the console I am pretty sure I had to convert data to a string. That’s what the “ÿÿ” tells me–again, based on my limited experience. Maybe a coder here can help, but this might be a start.
Steve


#3

Hi Steve, thanks for your answer

By any chance, do you know what is the default baud rate of the Me Bluetooth module ?


#4

Hi @quentin, I had the same problem and the situation got better when I set baudrate to 115200. However, I was still getting some garbled characters.

Over the time, I got the impression that MeBluetooth is actually not supported. If you look at the official “firmware”, Makeblock products do not use MeBluetooth. Instead they use “hardware serial” on port 5 through the “Serial” class. (This likely means that you cannot use USB serial and BT serial at the same time)


#5

Hi. I know nothing about Bluetooth–the Robot Tank was the first use I had for Bluetooth on my Android-based tablet. I don’t have any other Bluetooth devices, that I know of. If I knew what sketch the MakeBlock App uses to let me move the robot around, I’d look up the code to see if the rate is specified there. Hmmmm. Maybe Bluetooth uses a standardized rate. Maybe an internet search will tell.
Steve

Update 1: I just looked up Bluetooth. Based on what I read, I think the rate for communication with the serial port depends on the sketch. Again, this is 100% speculation. I looked at the TestSlaveBluetoothBySoftSerial.ino file. It uses 9600 to print “Bluetooth Start!” Most arduino examples I have seen use that. However, in playing around with sending MIDI data from an Arduino through usb using a midi-usb bridge, I was able to send midi data to softsynths using the maximum rate. I would guess that with the TestSlave . . . program, if it works with the serial monitor matching the sketch (9600), you should be able to try different rates which the arduino console supports to test this. I’d do it myself, but I am trying to see if I can figure out why the MakeBlock Android App is unpredictable. So I am leaving the sketch in there and running the tank robot.

Steve


#6

PS: I just stumbled onto this. I don’t know if it helps, but thought I’d post the url here:

Steve


#7

@iSteve: The “firmware” source for the sketch that communicates with the mobile app is here:


See this FAQ page http://forum.makeblock.cc/t/how-to-upload-the-firmware-of-me-orion-board/919

There is no reference to MeBluetooth. All the communication is over “Serial” no baudrate setting either.


#8

Thanks for the reply. Both the link you gave and the FAQ are of no use to me–I have no idea how to get github to give me a bunch of files that I can extract and use, When I tried the page you gave and the page pointed to by the FAQ, all I got a whole bunch of html files.

However, I did have success a few weeks ago here: https://github.com/Makeblock-official/Makeblock-Firmware/tree/master/resources/firmware . Those files could be unzipped [extracted] and loaded into the Arduino IDE.

That being said, I couldn’t find where the baud rate of the bluetooth serial communication was set. Maybe its set in the Android and iOS app.

Maybe I will upload the Bluetooth Test sketch and just change the rate to see for myself. I cannot imagine it would be harder than getting the tank to work.

Steve

Update 1: After verifying my tank ran properly, I did the BT test and successfully changed the rate to 115200. Since I don’t know how to do Android programming, I am not sure how I can get my tablet to send characters to the Orion via Bluetooth…\

Update 2: I tried the MakeBlock robot control app, but in order for it to work, it had to upload the “firmware” [aka sketch]. The good news is: the tank runs from the tablet app, just like it did before I ran the BT test. :smile:

Update 3: GOT IT!!! I found an app called Bluetooth teminal. I am using the basic BT test example that echoes to the console via usb serial connection what I type on the tablet.

Update 4: Once I set up line feeds and carriage returns on both the console and the bluetooth terminal app, I have two way communication between the tablet (BT to Orion) and the Arduino serial monitor (usb to laptop).

Footnote: It looks like BT communication and usb serial communication can be running at the same time. However, any time I tried to load a sketch via usb, I got an avrdude error until I disconnected the BT device.

PS: I used Bluetooth Teminal by Querty. There are others; I assume they will work, too.

Hope this helps on the BT/Orion end of things. As for Android programming, maybe I will get into that someday. What program do you use?

Steve


#9

I have been doing some targeted testing–bouncing back and forth uploading the BaseboardBuzzerTest.ino sketch and a minimally modified TestSlaveBluetoothBySoftSerial.ino. (I changed it to use PORT_5, 115200 for serial and bluetooth rates, and my own message: “SUCCESS!! The Bluetooth module has been started!”)

I am not sure how/why, but with (1) the Bluetooth Terminal by Querty Android app on, paired, connected, and running, and (2) both the usb cable and the BT module connected, I was able to transfer sketches from the Arduino IDE (1.6.1) through the usb cable to the Orion >>without any avrdude errors!!!<<

After turning off the tablet, sketches still load with the BT module connected without creating the avrdude error.

Next I turned the Orion off then back on. As expected, sketches loaded, but an avrdude error message was generated. I reloaded the Buzzer sketch several times and each time I got an error.

Next, I tuned on the tablet, started the Bluetooth Terminal by Querty app. As expected, the Buzzer sketch loaded with no avrdude error message.

BTW, the app has settings so you can display and/or send either hex or text. Back to the original issue, if you haven’t solved it,I suggest running your android app with the terminal displaying hex. Perhaps you are getting the numbers and not the ascii characters.

Thanks for asking the question, I learned quite a bit!

Steve


#10

Thanks to the both of you for your answers !

I’ve set the baudrate to 115200 and it works perfectly


#11

Hi,

This email thread has been very helpful, because I have been struggling through all these issues, just over a much shorter time frame (two weeks). I would read the thread, say to myself - I haven’t seen that yet - and Bam! I would encounter the problem almost exactly as described!

So, to all you pioneers and first-adopters who stuck it out; and returned to report your results - successful or not - Thanks! - it has kept me from repeating the same things over and over - hoping for a different result, which - as you all have noted - didn’t come easily.

Anyway, I still have the same problems, but I will now follow your bread crumbs!


#12