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) {
incomingByte = rf.read();
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).
Best Answer
That doesn't sound right. When a UART is not transmitting any data, it stays in the idle "1" state. I expected the wires connected to the Arduino to be so-called RS232TTL levels of +5V in the "1" state and close to GND in the "0" state. (d) When the UART is transmitting lots of data, a multimeter typically shows some sort of average voltage between the "1" state and the "0" state, bouncing around 2 V to 4 V. Perhaps a power or data line got disconnected or wired up wrong?
That's very unexpected. Most Arduino documentation says things like "Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode()." (a)
Some tutorials for SoftwareSerial suggest explicitly declaring the TX pins to be output. (b) Perhaps whatever is listening to "txPin" is picking up noise, making it do something unexpected?
Most Arduino tutorials seem to use 9600 bps for the hardware Serial uart. (c)
How could you possibly know that? I'm beginning to suspect the code in your Arduino is some program other than what you posted.
What happens when you test exactly the same program, but with a known serial source? For example, rather than connect Arduino D10 (your SoftwareSerial rxPin) to the radio, instead connect D10 to Arduino D0 (the data you type in your PC's serial monitor), and type a few words. What happens then?
Maybe the SoftwareSerial works fine with normal UART data, but it can't handle the high-frequency glitches common in low-cost radio receivers. In that case, maybe it would work better to
Some test code: