Arduino Rn-42 Baud Rate Increase

Dear All,

I'm trying to send data from an Arduino wirelessly to my computer using bluetooth. I'm using serial.write() to send data using the RN-41. Right now, this works well with Baud Rates of 9600-115200. However, When I go higher, to let's say 230400 or 921600 (I'm using the Hardware Serial, so this should be possible), I read a bunch of letters on my Serial Terminal Monitor that don't make any sense.

Here is my code for reference.

void setup()
{
 Serial.begin(115200); //This baud rate is ok
}

void loop()
{
  sensorValue1= analogRead(1);  
  sensorValue2= analogRead(2);
  sensorValue3= analogRead(3);
  
  Serial.write(sensorValue1);
  Serial.write(sensorValue2);
  Serial.write(sensorValue3);
  Serial.write(44); //This is a comma to delimit the data
}

Thanks for any help you can provide!

Right now, I'm using an Uno to do analogRead() and then serial.write() the analog inputs using an RN-41 Module to send the data to my computer. Everything works at a baud rate of 115,200. However, when I increase the Baud rate on the Arduino Serial.begin() and RN-41 configuration menu, I get jumbled letters instead of numbers. I talked to RN-41 support, and they said that I need to use "UART Flow Control".

From my understanding, the RN-41 Module's RTS pin sends 3.3Volts when it's busy sending data, and then it sends 0Volts when it's not sending data. When I'm writing at faster rates, it looks like I'm losing data because I'm forcing the RN-41 to send data when it's not ready. Therefore, can I connect the RN-41's RTS pin to a Digital Input pin and use an interrupt or IF statement that monitors the Digital Input pin and therefore send my data once the Digital Input pin reads 0Volts?

This seems fairly easy to do, but I just wanted to check with people with more experience to make sure that's all I need. I have very little microcontroller experience, so any help would be great. Thanks! I attached my code for reference.

void setup()
{
 
 Serial.begin(115200); //This baud rate is ok
}

void loop()
{
  sensorValue1= analogRead(1);  

  Serial.write(highByte(sensorValue1));
  Serial.write(lowByte(sensorValue1));
  Serial.write(44); //This is a comma to delimit the data
}
  Serial.write(highByte(sensorValue1));
  Serial.write(lowByte(sensorValue1));
  Serial.write(44); //This is a comma to delimit the data

How do you distinguish, on the reading end, a comma from a valid value? How can you possibly deal with lost data?

Reading analog data is a relatively slow process. Sending the data at faster rates does not necessarily mean that you'll get more samples per second, if the bottleneck is the analog to digital converter.

Do not cross-post. Threads merged.

Sorry about the cross-threading. I forgot that I posted the previous thread XD

How do you distinguish, on the reading end, a comma from a valid value? How can you possibly deal with lost data?

To tell you the truth, I'm not particularly sure. What would this have to do with my problem of increasing the Baud Rate? Is there a way to monitor if I'm losing data?

Reading analog data is a relatively slow process. Sending the data at faster rates does not necessarily mean that you'll get more samples per second, if the bottleneck is the analog to digital converter.

I'm pretty sure my analog to digital converter is not the bottleneck. I set the A/D prescale factor to procure an A/D sampling rate of 60 microseconds. I tested increasing the A/D sampling rate, and it seems like I'm still getting the same issue.

Thanks for the help!

Well, it turns out that the maximum baud rate possible with the Arduino is 115200. That is why it is not working.

Well, it turns out that the maximum baud rate possible with the Arduino is 115200. That is why it is not working.

I thought that the maximum baud rate for SoftSerial is 115200. For the Hardware Serial, it seems like the maximum Baud Rate can be increased to a higher value, as shown in some forums (Fast communication to PC with low Arduino footprint - #12 by robtillaart - Networking, Protocols, and Devices - Arduino Forum). Is there a way to test the limits of the Arduino max Baud rate without using the Bluetooth Module?

I was able to send readable data with a baud rate of 230400, but the Bluetooth module loses connection after 10 seconds or so.

I also tried using the RTS pin and triggering and interrupt, but it didn't seem to work.

Could it have something to do with something on my receiving side? I'm using a USB Bluetooth Mini Dongle.

Thanks for the help!

Does any who managed to communicate at a higher baud rate with the RN-41/42 have any advice? I've been working on the problem for a while, and still no luck.

crossrunnerzero:
Does any who managed to communicate at a higher baud rate with the RN-41/42 have any advice? I've been working on the problem for a while, and still no luck.

Don't know if this will help you or is relevant, but I have customized my IDE a lot and one of the things I did was add baud rates to the list. I added 230400, 460800 and 921600. These all work (on my machine anyway - running 64 bit Linux), so I can tell you for sure that a stock Arduino board (UNO or MEGA) work just fine at those speeds.

I added 230400, 460800 and 921600. These all work (on my machine anyway - running 64 bit Linux), so I can tell you for sure that a stock Arduino board (UNO or MEGA) work just fine at those speeds.

Thanks for the tip. I also confirmed that the Arduino was not the problem by sending Serial commands using USB directly to Hyperterminal at 921600.

However, I still am not having any success with configuring higher baud rates this RN-41 module... I'll keep this thread updated with any discoveries I'm making just in case someone has an issue similar to mine, but if anyone has any more input, that would be great.

Thanks!

Here's an update on my situation so far. I've tried using my bluetooth dongle as my receiver and also tested a rn-42-ek as my receiver. Changing my receiver fixes my timeout issue, but I'm still receiving the same problem of receiving gibberish at baud rates higher than 230400.

Does anyone have any idea why when I send at higher baud rates than 230400, my data becomes incomprehensible letters?

Thanks!

http://wormfood.net/avrbaudcalc.php

The error at 230400, 460800, and 921600 baud is 7.8%. It is a miracle you are able to communicate at 230400.

If you can, use an Arduino friendly baud like 250k, 500k, or 1M.

The error at 230400, 460800, and 921600 baud is 7.8%. It is a miracle you are able to communicate at 230400

When you run the Arduino Serial port at 230400bps to the Serial Monitor, it is talking to ANOTHER Atmel AVR microcontroller with the same UART hardware logic, and thus the same speed errors in the same direction, so they end up talking just fine. If you talk to a 3rd party Serial port that is accurately running at the configured rate, there error will be too large and it won't work.

I see what your talking about with the baud rate errors. However, what is a possible way to fix this issue? Should I set different baud rates (for example, 1M) for my Bluetooth and arduino, but leave my Hyperterminal baud rate at 921600? Or should I get a microcontroller with a higher clock speed or a different Bluetooth?

Should I set different baud rates (for example, 1M) for my Bluetooth?

Can you? Does the RN-42 support 1M?

Can you? Does the RN-42 support 1M?

According to the RN-42 manual, I can set nonstandard baud rates using the SZ, command, so I believe its possible. However, do I need to set nonstandard baud rates for my serial monitor? I don't believe I can do that using Hyperterminal or Realterm.

Thanks for any help you can give!

Br@y++ terminal supports arbitrary baud rates.

I can't remember if Hyperterminal does.

Realterm does...
http://realterm.sourceforge.net/#possible_baud_rates

Now I appear to receive data again! I set the Baud Rate to exactly to 1Mbps, and it works now. Thanks for the help!