Software Serial

Hi all,

I am trying to do the Instructables on reading data from a UHF RFID antenna, http://www.instructables.com/id/Use-Arduino-and-RS232-Shield-to-interface-Integrat/ . The thing is that the code seems to not work. I have tried just using the softwareSerial library on my Arduino UNO and not even getting a reading from mySerial(5,6) works.

Yes, I have looked at other threads that are sort of similar, but none fill or explain what is going on with my code :'(

Here is part of my manipulated code

include "Arduino.h"

include "SoftwareSerial.h"

SoftwareSerial mySerial (5,6); unsigned char incomingByte;

void setup() { mySerial.begin(9600); Serial.begin(4800); }

void loop() { mySerial.write(0x7d); delay(1000); while (mySerial.available() > 0) { incomingByte = mySerial.read(); mySerial.print(incomingByte); Serial.println(incomingByte,HEX); } delay(1000); }

  • I'll go line by line. SO mySerial(5,6) = Sets pins 5 to Rx, and 6 to Tx
  • I start the Serial monitor to see what data I am getting sent back from pin 5
  • Start the transfer on the defined mySerial pins

On the loop - I write on pin 6, 0x7d . Just an arbitrary HEX val (On the background I have a jumper cable going from pin 5 to pin 6 just to test out the code and see if I am really getting something.)

On the while loop - I wait for Serial that should be transferred from pin 6 to 5, since I have em going to each other. - If any serial data is received it is read and stored onto the unsigned character incomingByte -Then mySerial prints it - Also I print it to the serial monitor on the PC to see what I got.

Serial.println(incomingByte,HEX); Is always giving me FF.

Why I don't know. Maybe when no data is available Serial.println prints FF or -1 saying "nothing here" If I comment out such line, nothing gets printed out. :o

That's what is bothering me neither the Tx nor RX are getting lighted up in my board, signifying that there is any data being sent or received.

Can anybody help? Anybody have an example worked out that I can learn from?

Also, no I don't care about using pins 0,1 since I will be sending and reading data from the RFID antenna.

Thanks in advance,

Hi, welcome to the forum.

This is your RFID device ? http://linksprite.com/wiki/index.php5?title=Long_Range_UHF_RFID_reader_%281-6_meters%29_%28ISO18000-6C_EPC_G2%29_RS232

You echo the received byte to the RFID device ? Then it probably gets confused. Why do you use 4800 baud to the computer ? Did you change that also in the serial monitor. 9600 baud is the default, but some use a faster rate of 115200.

I prefer to show that the serial communication is running like this:

void setup()
{
  Serial.begin(9600);
  Serial.println("Started");
  ...
}

Do you use a RS-232 module in between the Arduino and the RFID ? It is not always clear which one RX or TX is, maybe you have to swap them.