Arduino Uno SoftwareSerial and Serial conflict

I have a very simple setup with an Arduino Uno R3 connected to my Windows 7 x64 with Arduino 1.0.1.

I have a RF receiver connected to the Arduino on the DI10 port using the SoftwareSerial library. I am using a AM-RRQ3-433 module. See rfsolutions.co.uk/acatalog/AM_Super-heterodyne_Receiver.html

When I receive a byte from the RF receiver, I am simply writing it to the Serial (so that I can see it on my PC in the serial monitor). Doing so seems to conflict between SoftwareSerial and Serial, since the available() function rapidly increases and thus I have a lot of 0's printed (given no data was actually transmitted, but available() returned 63 - the maximum of the receive buffer).

The Arduino code is as follows:

#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11

SoftwareSerial rf(rxPin, txPin);
int incomingByte = 0;

void setup() {
pinMode(rxPin, INPUT);
Serial.begin(57600);
rf.begin(2400);
}

void loop() {
if (rf.available() > 0) {
Serial.println(incomingByte, DEC);
}
}


As a side note, if I remove the pinMode(rxPin, INPUT) line then nothing is ever received (and rf.available() is always 0).

-
 This sounds like a pure software issue. What is your electrical engineering question? – Olin Lathrop Feb 11 at 20:58

I do not thing that using SoftwareSerial and Serial at the same time is a problem. I am using SoftwareSerial to communicate with my GSM module and use Serial.print(ln) at the same time for debugging.

However to test this is easy: comment out the Serial.println and set the oboard LED on the Uno when available() returns 63 and off when != 63.

If you still notice the input buffer fills up, reading the RF module is the problem.

BTW what kind of RF module are you using?

-
 Okay, so I did that now. If I check rf.available() == 63 then the LED never turns on. However, if I merely check rf.available() > 0, then the LED does turn on after a short period of time (as expected). Also, I attempted to check for > 1 and the LED is still not turned on. This suggests that I am actually reading data from the RF module, but that it conflicts with the built-in Serial. I am using a AM-RRQ3-433 module. See rfsolutions.co.uk/acatalog/AM_Super-heterodyne_Receiver.html – kfuglsang Jul 14 '12 at 8:26 It seems I was wrong. The RF module was actually connected to DI8 (from an experiment with AltSoftSerial last night). When I connected it to DI10 the LED is constantly turned on, suggesting that rf.available() is always > 0 (and also becomes 63) even when I am not instantiating or using the built-in Serial. I tried a voltmeter over GND and DI10 and while measuring it showed 0V. – kfuglsang Jul 14 '12 at 9:09 Furthermore, I tried to invert the signal by using the 3rd argument of the SoftwareSerial constructor. This does not change anything (except that if I print the byte it is 255 instead of 0). – kfuglsang Jul 14 '12 at 9:10 I have started thinking more about the pinMode(rxPin, INPUT). From the samples I've seen, this is not necessary. If I remove it, rf.available() never becomes > 0. Additionally, I just tried swapping the RF module for another one (which I have tested in a FEZ Panda). Same problem. – kfuglsang Jul 14 '12 at 9:56

First, you may need to use Serial.print() instead of Serial.println(). Also, one thing to keep in mind is that the SoftwareSerial.h library was changed last year and it requires a different format when you're using Serial.print(). You may actually need to change your output line to

 Serial.print( (Dec) incomingByte );


I had to do this for one of my projects.

-