Go Down

Topic: RFID, SD card and real time clock door lock (Read 13976 times) previous topic - next topic

ColeH

Lets just say that I only only use 1 tag, or maybe two like in the sketch.  Do you think it would work?  Also, the RFID reader and the LCD just arrived in the mail and so I tried to set them up as the tutorial I found showed me and with their example code, but the LCD and the RFID reader seem to have problems working together.  There is a little light on the RFID reader that goes red or green depending on wether its on, or maybe depending on whether its reading a code, i'm not really sure.  It seems that whenever the light is red, the LCD's text, instead of being bright white, it is a darker gray, making it harder to read.  I already posted this on a new programming topic, but I was wondering if you had any ideas.  You have been a great help, I really appreciate it.

Grumpy_Mike

#31
Jul 27, 2013, 07:13 pm Last Edit: Jul 27, 2013, 07:15 pm by Grumpy_Mike Reason: 1
Quote
It seems that whenever the light is red, the LCD's text, instead of being bright white, it is a darker gray,

That sounds like a hardware problem of some sorts, either with the wiring or power supply.

Is the LCD using the same pins as the SD card? You might find they are.

ColeH

The SD shield isn't in the code or plugged in. I am just trying to test the RFID.  I found that when I unplug pin 2 of the Arduino, which is for the RFID reader, the LCD works perfectly.

Grumpy_Mike

I am confused now. Can you post the code of what you are testing now along with a schematic of how it is wired up.

ColeH

Sorry, I didn't explain this very well.  I am currently just getting the LCD and RFID to work together, without the SD shield.  The problem is that when the RFID pin 2 is plugged in, then the LCD's text when saying "please swipe your card" is a dark gray.
Schematic
http://imageshack.us/photo/my-images/822/wnpc.png/
Wiring
http://imageshack.us/photo/my-images/23/to9o.png/
Code
Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins

#define TAG_LEN 12
char tag[12] = {
  '0', '1', '0', '0', '4', 'D', 'D', '1', 'D', '3'}; //tag 1
char tag2[12] = {
  '3', '6', '0', '0', '7', '8', '9', 'B', 'B', '5'}; //tag 2
char code[12];
int bytesread = 0;
//Connections to be made:
int ledPin = 13; // Connect LED to pin 13
int rfidPin = 2; // RFID enable pin connected to digital pin 2
//Connect SOUT Pin to pin 0, does not need to be defined because 0 is the default RX pin
int val=0;
void setup() {
  lcd.begin(16, 2); // set up the LCD's number of rows and columns
  lcd.print("Initializing...");
  delay (3000);
  lcd.clear(); //Clears LCD
  lcd.setCursor(0, 0);
  lcd.print("  Please Swipe");
  //lcd.setCursor(0, 1);
  //lcd.print("   Your Card");

  Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
  pinMode(rfidPin,OUTPUT);   // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
  pinMode(ledPin,OUTPUT); // Set ledPin to output

  digitalWrite(rfidPin, LOW); // Activate the RFID reader
}

void loop() {
  digitalWrite(ledPin,LOW); //LED off
  digitalWrite(rfidPin, LOW); // Activate the RFID reader
  //lcd.clear(); //Clears LCD
  //lcd.setCursor(0, 0);
  //lcd.print("  Please Swipe");
  //lcd.setCursor(0, 1);
  //lcd.print("   Your Card");
  if(Serial.available() > 0) {    // if data available from reader
    if((val = Serial.read()) == 10) {   // check for header
      bytesread = 0;
      while(bytesread<10) {  // read 10 digit code
        if( Serial.available() > 0) {
          val = Serial.read();
          if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
            break;     // stop reading
          }
          code[bytesread] = val;   // add the digit
          bytesread++; // ready to read next digit
          digitalWrite(rfidPin, HIGH); //Turns off RFID reader, THIS IS IMPORTANT so it doesn't double read the card
        }
      }

      if(bytesread >= 10) {  // if 10 digit read is complete

        if(strcmp(code, tag) == 0) {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print(" Access Granted");
          lcd.setCursor(0, 1);
          lcd.println(code);
          delay (1500);
          lcd.setCursor(0, 1);
          lcd.print("Jonnyblanch  ");
          digitalWrite(ledPin,HIGH);
          Serial.print("Tag matches: ");
          Serial.println(code);
          //digitalWrite(ledPin,HIGH);
          digitalWrite(rfidPin, HIGH);
          delay(2000);
          lcd.clear(); //Clears LCD
          //lcd.setCursor(0, 0);
          //lcd.print("  Please Swipe");
          //lcd.setCursor(0, 1);
          //lcd.print("   Your Card");     // wait for a second or two
          return;                   //Go to the top, skip the bottom
        }
        if(strcmp(code, tag2) == 0) {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print(" Access Granted");
          lcd.setCursor(0, 1);
          lcd.println(code);
          delay (1500);
          lcd.setCursor(0, 1);
          lcd.print("Hector Lopez");
          digitalWrite(ledPin,HIGH);
          Serial.print("Tag matches: ");
          Serial.println(code);
          digitalWrite(ledPin,HIGH);
          digitalWrite(rfidPin, HIGH);
          delay(2000);     // wait for a second
          return;

        }
        else {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Access Denied");
          lcd.setCursor(0, 1);
          lcd.println(code);
          Serial.print(code);
          Serial.println(" does not match");
          digitalWrite(rfidPin, HIGH);

        }


      }
      bytesread = 0;
      delay(2000);     // wait for a second
      digitalWrite(ledPin,LOW);   
    }
  }
}

Grumpy_Mike

I can't spot anything that is wrong with your description of what you are doing, you need to take some measurements.
When you say:-
Quote
the LCD's text when saying "please swipe your card" is a dark gray.

Is this due to the background getting dimmer? As if you had turned the contrast knob down?
Get a multimeter and measure the voltage with this pin 2 connected and not connected and look at the voltage:-
1) On the voltage input to the reader.
2) On the contrast pot wiper
3) On the 5V supply to the arduino.

Then take the reader's enable line and connect it directly to ground. Does the same dimming happen?
Has your bread board got a break in the power tracks that you need to link?
My guess is that there is a wiring fault somewhere.

ColeH

I used my cheap multimeter to test some connections and it said that everything that is supposed to, is getting around 9v.  I know that's not right, but they all got the same reading which means that they probably have 5v.(could you Arduino be getting too much power?)  It does seem like a problem in the wiring, but it's not that complicated, just some wires from the LCD and and the RFID to the Arduino and some power and GND wires.  I don/t know much about breadboards and how they could get messed up, but I doubt that it is, since the LCD and RFID are on opposite sides of the board, so it would have to be one big track break.  I connected the enable line to GND, and then all the LCD's text was a dark gray, instead of just the "please swipe card" bit.

Grumpy_Mike

What was the voltage the 5V line when this happens?
If directly connecting the enable line to ground produces this effect then it has nothing to do with your software and everything to do with the power supply not being able to cope with an enabled reader. I am expecting to see the 5V line drop down when you get the grey display.

ColeH

When I read the voltage on pins 15 and 16 of the LCD and the RFID is not plugged in, I get around 9.3v, when I read it again when it is plugged in, then I get around 8.5v.  So that looks like my problem.  Would you suggest I use a different power supply?  Such as a 9v battery or a AA battery pack?  I am using USB now.

Grumpy_Mike

Quote
When I read the voltage on pins 15 and 16 of the LCD and the RFID is not plugged in, I get around 9.3v,

You are only supposed to run it off 5V. Do you mean the LCD LED backlight pins? Normally these need a series resistor so I would not expect to see 9V. You do not show this in the diagrams you posted earlier.
especially as you said:-
Quote
I am using USB now.

USB will only give you a maximum of 5V so your measurement look a lot wrong.

ColeH

I'm pretty sure my multimeter is off, or i'm using it wrong.  But it does tell me that the the RFID pin is in the Arduino, the LCD's pins 15 and 16 goes down in voltage, which would probably account fir the gray text.

Grumpy_Mike

Yes it would account for the grey text. But I couldn't find a current consumption figure for that reader but typically they take about 100mA or so. With USB power you have up to 500mA so something does not add up. Mind you without a resistor you might be dragging a lot of current down that back light.
Try disconnecting the backlight you should still be able to read the display without it. Then try it with something like a 10 to 20 ohm resistor.

ColeH

I disconnected the back light and I can still see the text, but it still becomes darker when the RFID pin is in.  I then used a 10ohm resistor, but I can't see a real difference between with and without it.

Grumpy_Mike

Well something odd is happening, you need to get some real measurements. It all points to power problems to me.


Go Up