Hi, I'm new to arduino, first of all, excuse my english...
I have an Arduino UNO connected with an Ethernet Shield + rc522 RFID reader, I would like to get the Tag ID card and send it using GET mounted to a local server with XAMPP.
- the apache server is online (checked)
- WS receives the parameter is at http: //localhost/dir1/obtienevalor.php (checked)
- rc522 reader reads TagId I connected on ethernet shield works! (checked)
- ethernet shield works alone (checked)
I need to read the tag id and send using GET to obtienevalor.php to process,the problem is that the connection to the server fails, and I can not send TagId.
apparently ethernet shield not working with Reader rc522, rc522 reader settings this within my code:
/**
* Read a card using a mfrc522 reader on your SPI interface
* Pin layout should be as follows (on Arduino Uno):
* MOSI: Pin 11 / ICSP-4
* MISO: Pin 12 / ICSP-1
* SCK: Pin 13 / ISCP-3
* SS: Pin 7
* RST: Pin 9
*/
#include <SPI.h>
#include <RFID.h>
#include <Ethernet.h>
#define SS_PIN 7
#define RST_PIN 9
// Mac unica de cada EthernetShield (deben cambiarla)
byte mac[] = { 0x90,0xA2,0xDA,0x0F,0x49,0x90 };
// Descomentar esta linea si se desea un IP fijo
IPAddress ip(192,168,0,50);
// Descomentar esta linea para asignar un DNS fijo
//IPAddress myDns(192,168,1,1);
// Inicializa la instancia client
EthernetClient client;
// Direccion del servidor
char server[] = "http://localhost/dir1/";
RFID rfid(SS_PIN, RST_PIN);
// Setup variables:
int serNum0;
int serNum1;
int serNum2;
int serNum3;
int serNum4;
int finalnumber;
void setup()
{
Serial.begin(9600);
// disable SD SPI
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
// disable w5100 SPI
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
// Espera 1 segundo para que se inicie la tarjeta Ethernet
delay(1000);
// Si deseas usar un ip fijo y un DNS fijo descomentar esta linea y comentar la linea 39
// Ethernet.begin(mac, ip, myDns);
// Inicializa la tarjeta ethernet mediante DHCP
EthernetServer server(80);
Ethernet.begin(mac,ip);
server.begin();
// Imprime la direccion IP de la tarjeta
Serial.print("Direccion IP: ");
Serial.println(Ethernet.localIP());
SPI.begin();
rfid.init();
}
void loop()
{
if (rfid.isCard()) {
if (rfid.readCardSerial()) {
if (rfid.serNum[0] != serNum0
&& rfid.serNum[1] != serNum1
&& rfid.serNum[2] != serNum2
&& rfid.serNum[3] != serNum3
&& rfid.serNum[4] != serNum4
) {
/* With a new cardnumber, show it.*/
Serial.println(" ");
//Serial.println("Card found");
serNum0 = rfid.serNum[0];
serNum1 = rfid.serNum[1];
serNum2 = rfid.serNum[2];
serNum3 = rfid.serNum[3];
serNum4 = rfid.serNum[4];
finalnumber= 1;
delay(1000);
if (client.connect(server,80)) {
// Envia el requerimiento al servidor via GET
Serial.println("Iniciando conexion...");
client.print("GET /obtienevalor.php?idcard=finalnumber");
//client.print(tempC);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("User-Agent: Arduino-Ethernet");
client.println("Connection: close");
client.println();
}
else {
// Si la conexion fallo se desconecta
Serial.println("Error al conectarse al servidor");
Serial.println("Desconectando...");
client.stop();
}
} else {
/* If we have the same ID, just write a dot. */
Serial.print(".");
}
}
}
rfid.halt();
}
someone could give me a hint? attached photo of monitor serial and arduino settings
Thanks in advance






