Hi
I'm trying to interface an enc28j60 ethernet module and a mfrc522 rfid reader, I'm using the ethercard library and this library for the rfid module: GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522 the objective is to send the card ID to a server.
The code doesnt work together, the only thing that work correctly is the rfid reader, the ethernet module doesnt send anything, they have different CS pins and the hardware is correctly connected. If I remove the all the code relative to the rfid, the ethernet module starts working, I think the libraries dont play nice together, where should I start looking?
Other thing, I'm saving the card ID in a String variable, but the function to send it only allows const char type, whats the best way to convert it?
The code I'm using:
#include <SPI.h>
#include <MFRC522.h>
#include <EtherCard.h>
MFRC522 mfrc522(10, 14);
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,2,2 };
static byte gwip[] = { 192,168,2,1 };
static byte hisip[] = { 192,168,2,1 };
char website[] PROGMEM = "192.168.2.1";
byte Ethernet::buffer[500];
String id, lastId;
void setup()
{
Serial.begin(57600);
ether.begin(sizeof Ethernet::buffer, mymac, 8);
ether.staticSetup(myip, gwip);
ether.copyIp(ether.hisip, hisip);
SPI.begin();
mfrc522.PCD_Init();
}
void loop()
{
ether.packetLoop(ether.packetReceive());
id = "";
if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial())
{
for (int i = 0; i < 4; i++)
{
if (mfrc522.uid.uidByte[i] < 0x10) //adds a leading zero
id += "0";
id += String(mfrc522.uid.uidByte[i], HEX);
}
if (id != lastId)
{
Serial.println(id);
ether.browseUrl(PSTR("/?id="), "card id here", website, reply);
tone(9, 2300, 500);
lastId = id;
}
else
{
tone(9, 2300, 100);
delay(200);
tone(9, 2300, 100);
}
mfrc522.PICC_HaltA();
delay(1000);
}
}
static void reply (byte status, word off, word len)
{
Serial.println((const char*) Ethernet::buffer + off);
}







