Pages: [1]   Go Down
Author Topic: RFID not reading?  (Read 548 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

RFID shield: https://www.sparkfun.com/products/10406
RFID tag (blank): https://www.sparkfun.com/products/10128?
Arduino Board: ATMega Lite/ATMega 328

I have all the ground pins wired the the Arduino ground pin and I have "5v" wired to pin 6 (named "D6") for turning on manually.  SoftwareSerial had a note about pins: "Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69"

I used pin 13 for TX (named "B5") and pin 12 for RX (named "B4").  Here is my code:

Quote
#include <Streaming.h>
#include <SoftwareSerial.h>

// Pin numbers.
const int RX = 12;
const int TX = 13;
const int LED_ORANGE = 7;
const int LED_BLUE = 6;
const int TAG_IN = 14;
const int SHIELD = 6;

// Timing
const int SECOND = 1000;
const int BAUD_RATE = 19200 ;

SoftwareSerial mySerial(RX, TX);

void setup(){
  pinMode(SHIELD, OUTPUT);
  
  Serial.begin(BAUD_RATE);
  mySerial.begin(BAUD_RATE);
  
  Serial << "Powering RFID Reader..." << endl;
  digitalWrite(SHIELD, HIGH);
  
  Serial << "Initialized...";
}

void loop(){
  getRFIDInput();
  writeToRFID("HELLO!");
  delay(10);
}

void getRFIDInput(){
  int c = mySerial.read();
  if (c != -1){
    Serial << "Read character " << (char) c << endl;
  }
}

/**
 * write a message to an RFID tag.
 * @param message the message to write.
 */
void writeToRFID(char message[]){
  mySerial.write(message);
}


The problem is that the variable "c" (in method "getRFIDInput") is always -1 so I'm not reading a character.  Did I write to it correctly?  I've been following different tutorials online.  The only variations seem to be they're changing the format in which the data is; the basis, though seems to be SoftwareSerial.read() and SoftwareSerial.write().

So confuzzled.  smiley-confuse
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5228
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have all the ground pins wired the the Arduino ground pin and I have "5v" wired to pin 6 (named "D6") for turning on manually.

This is a bad idea. According to the datasheet the SM130 draws a current of 180mA while reading. A GPIO pin of the ATmega is delivering 40mA at absolute maximum, so you probably damaged your D6 port.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, then I assume I should wire it directly from the 5v pin on the Arduino board.  Thankfully, I didn't brick it because the red light on the RFID board still comes on when I do a digitalWrite.
In any case, the problem is still there.
I think I realized what I'm doing wrong, though.  http://forums.parallax.com/showthread.php?129430-Interface-Arduino-to-RFID-Read-Write.  On this forum I see that there are codes (e.g. 0x01) for reading and writing.  Duh.  smiley-red  I'll have to do more research.
Logged

Pages: [1]   Go Up
Jump to: