BlueSMiRF silver - seemingly corrupted data

I’m using a BlueSMiRF silver on an Arduino Micro to communicate with a PC. The PC is running a VB.NET program. The PC appears to flawlessly receive data from the Arduino but I get what appears to be corrupted data when I send data from the PC to the Arduino. For example, if I send the string “4444” to the Arduino 4 times with 1 second intervals, I will often see the following at the Arduino end: “4444” “¢¢Dø” “444M” “4444”. As far as I can tell the corruption is random. Here is what I have tried so far:

-confirmed that the Bluetooth baud is 9600

-confirmed that the BlueSMiRF to Arduino baud is 9600

-confirmed that the Bluetooth and VB serial connection Parity (none), Data bits (8), and Stop bits (1) match

-confirmed that the PC is sending ASCII 10 and 13 along with each string, e.g. “4444(cr lf)”

-tried many different ways of parsing data received on the Arduino, e.g. as individual chars, parseInt, as a string, etc…

-tried sending data without end line characters

-tried alternate PC with unique bluetooth radio

-tried alternate BlueSMiRF module

-tried alternate Arduino Micro

-shielded Tx and Rx wires between SMiRF and Arduino and tied to Arduino gnd

-set unused Arduino I/O pins to low digital outputs

-tried shorting CTS-I to RTS-O

Other possibly relevant info:

-VB.NET code uses SerialPort class and writes using .WriteLine(myInt)

-BlueSMiRF has following connections CTS-I(NC), VCC(+5 from Arduino), GND(gnd from Arduino), TX-O(pin9 Arduino), RX-I(pin10 Arduino), RTS-O(NC)

-Arduino uses SoftwareSerial class and pins 9 and 10

-Arduino/SMiRF are approximately 2ft from PC bluetooth radio

Your consideration and suggestions are greatly appreciated.

How about avoiding the use of the SoftwareSerial library and use the hardware serial port on pin 0 and 1? If only for testing

Valen, Thank you so much for your suggestion!

I used the UART on pins 1 and 0 and the data transfers perfectly! Thrilled to have it working, thanks again!

I plan on using the UART but, out of curiosity, I tried to further isolate the SoftwareSerial issue. Here’s what I found:

-If I stop sending data from the Arduino to the PC I can properly send data from the PC to the Arduino

-Adding delays before and after reading from, and writing to, SoftwareSerial didn’t appear to help

-bypassing the VB.NET code on the PC by establishing a connection via PuTTY and manually sending messages suffered the same corruption

theproteungroup:
Valen, Thank you so much for your suggestion!

I used the UART on pins 1 and 0 and the data transfers perfectly! Thrilled to have it working, thanks again!

:handgestures-thumbupleft:

I plan on using the UART but, out of curiosity, I tried to further isolate the SoftwareSerial issue. Here’s what I found:

-If I stop sending data from the Arduino to the PC I can properly send data from the PC to the Arduino

Thats reads to me like a contradiction, and doesn’t make sense.

-Adding delays before and after reading from, and writing to, SoftwareSerial didn’t appear to help

-bypassing the VB.NET code on the PC by establishing a connection via PuTTY and manually sending messages suffered the same corruption

As the software serial library uses a software algorithm for detecting the serial bit it depends on strict timing. So delays between the bytes will not help much. You need to make sure the Arduino is not disturbed with doing other things, like whatever could trigger interrupts, while the serial data is coming in. So, what other stuff do you have the code doing in the mean while?

Also, I have no personal experience with using software serial yet, but I understand that over the years some people have made improved software serial libraries that are less vulnerable to timing issues. I don’t know if this is included in the stock IDE library collection yet. May be. Some thing to look out for/research.

Valen,

Thanks again for your help, the UART has been working well for a couple months now. To answer your questions let me clarify my earlier statement…

theproteungroup:
I plan on using the UART but, out of curiosity, I tried to further isolate the SoftwareSerial issue. Here’s what I found:

-If I stop sending data from the Arduino to the PC I can properly send data from the PC to the Arduino

The Arduino is periodically sending data chunks to the PC (~4 times a second). The integrity of the Arduino->PC data was never compromised. I am also sending data from the PC to the Arduino (random timing, typically intervals of tens of minutes). I was having trouble with the integrity of the PC->Arduino data. What I was trying to say is that if I temporarily disabled the Arduino->PC data stream then I no longer had trouble with the PC->Arduino stream. I believe that answers your second question:

Valen:
You need to make sure the Arduino is not disturbed with doing other things, like whatever could trigger interrupts, while the serial data is coming in. So, what other stuff do you have the code doing in the mean while?

My theory is that the “other stuff” is the periodic transmission of data to the PC and SoftwareSerial wasn’t able to do both so quickly.

Ok, that clears it up. Just outbound serial data from Arduino that disturbs the detection of incomming data. As I said, if you must use a software-based serial solution then there are other libraries to try out. But each has it’s particular drawbacks and point where it excels in. You would have to investigate that.