[SOLVED] Arduino Uno + RFID NewSoftSerial problem

Hi all,

I'm struggling with an annoying problem on my home automation setup. I have a seeedstudio RFID reader connected to Arduino Uno board. It uses pins 2 and 3 with NewSoftSerial library. Everything works beautifully, but after I unplug the USB cable from arduino the reader stops working. I use external 12V source on the board.

http://www.seeedstudio.com/depot/electronic-brick-125khz-rfid-card-reader-p-702.html

Here is a stripped down version what i'm doing:

NewSoftSerial rfidSerial(2, 3);

void setup() {
  rfidSerial.begin(9600);
}

void loop() {
  
  // RFID
  if (rfidSerial.available() > 0) {
    data[counter] = rfidSerial.read();
    counter++;
    
    if(counter > 13) {
      // Message received, so reset counter
      counter = 0;

      // Process RFID tag...
    }
  }
}

I managed to do some quick debugging and turn on a led after the serial.available() method in if-statement turns true in the loop. The led lights up immediately after I plug in the 12V. The led lights up before the serial.read() method so that might cause the hang because there is no data available? If I try to read a tag it won't work...

Also if I have the USB cable connected but have not opened the serial monitor in arduino software it hangs also. But after the serial monitor is active everything works ok.

I'm not using the normal arduino UART port (pins 0, 1) in the code and only the RFID software port is activated. I will use both serials in the future to communicate with a Linux ALIX board.

Any ideas? Have I missed something obvious?

Here is a stripped down version what i'm doing...

What you posted "should" work, as far as I can see... but since it doesn't, maybe you should post the full version?

I'd put a volt meter on the supply to the RFID reader... maybe there's some issue with the power to it when you work off of the 12v vs via USB power?

=== One aspect of your code worries me:

What would happen if a byte or two were lost, and another card were not presented to the reader? Reading would stop when the serial buffer was empty, but the "Process tag" wouldn't happen because 13 bytes had not yet been seen??

Thanks for the reply!

I not sure if it's a power issue, because it doesn't matter if you connect the external 12V or/and the USB to power the arduino. The reader is working only when I open the serial monitor.

I'm not 100% sure if I remembered to put a pull-up resistor on the input pin. Can't check this at the moment, but I have a screwshield where I soldered pullups on inputs i'm using... I might missed the softserial rx pin... Could this cause the problem?

I also have a Dallas 1-wire setup on pin 4, could this interfere some how?

I try to post the full source later, because I have it on a another computer...

Did you happen to fix this issue? As I'm having the exact same problem. Thanks

No, not yet... been too busy with other projects. Today I'm planning to investigate this a little more, but can't really figure out where to start...

I'll let you know if I find something!

OK,

As suggested in the first reply this was an power issue. The internal 5V regulator was not up for the task. I added an external supply for the relays and use the internal for rfid reader + sensors. Everything is working fine now! The external supplys 12V is fed from the vin terminal, because I use the DC jack for input.

I used this pololu supply: http://www.pololu.com/catalog/product/2110

Here's and image of the setup just for fun...