Hanrun ehternet Module + MFRC522 can't get website reponse

I’m trying to use Hanrun ehternet HR911105A Module + MFRC522 “RFID” to get the card number and send to my website and then get the reply from the website thats all, the RFID works fine when its alone and the ethernet also works fine when its alone , but when i put them both together and when i scan the RFID tag i get a response from the website once then no response then response then no response and so on…, and i noticed that each time i set the CS for the RFID High and the CS for the Ethernet LOW it toggles back right away like there is something forcing the RFID’s CS to be always LOW and the Ethernet’s CS always HIGH

My wiring as the following :

for both RFID and Ethernet :
MOSI > PIN11
MISO > PIN12
SCLK > PIN13
RST > PIN9

For RFID :
CS > PIN7

For Ethernet Module
CS > PIN8

INPUT Button > PIN2 which i use to try to send a request to the server manually without scanning the RFID TAG

My website works just fine, and i tried to get response from google.com and its the same so its not a server problem.

here is my code and it works and i have also attached it :

#include <SPI.h>
#include <MFRC522.h>
#include <EtherCard.h>

#define RST_PIN 9
#define RFID_CS_PIN 7
#define ETHER_CS_PIN 8
#define INTERRUPT_PIN 2

byte mymac = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const char website PROGMEM = “promedianz.com”;
static byte session;
Stash stash;
const char* reply;
byte Ethernet::buffer[700];

boolean lastBtnState = LOW;

MFRC522 mfrc522(RFID_CS_PIN, RST_PIN);

void setup () {
Serial.begin(57600);
pinMode(ETHER_CS_PIN,OUTPUT);
pinMode(RFID_CS_PIN,OUTPUT);
pinMode(INTERRUPT_PIN,INPUT);

digitalWrite(ETHER_CS_PIN,HIGH);
digitalWrite(RFID_CS_PIN,LOW);
SPI.begin();
mfrc522.PCD_Init();
ShowReaderDetails();
Serial.println(F(“Scan PICC to see UID, type, and data blocks…”));

digitalWrite(ETHER_CS_PIN,LOW);
digitalWrite(RFID_CS_PIN,HIGH);

if (ether.begin(sizeof Ethernet::buffer, mymac,ETHER_CS_PIN) == 0)
Serial.println(F(“Failed to access Ethernet controller”));
if (!ether.dhcpSetup())
Serial.println(F(“DHCP failed”));

ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);

if (!ether.dnsLookup(website))
Serial.println(F(“DNS failed”));

ether.printIp("SRV: ", ether.hisip);
}

void loop () {

if ( mfrc522.PICC_IsNewCardPresent()) {
if(mfrc522.PICC_ReadCardSerial()){
String readCard = “”;
for (int i = 0; i < mfrc522.uid.size; i++) {
if(mfrc522.uid.uidByte*==0){readCard += “00”;}*
_ else{readCard += String(mfrc522.uid.uidByte*,HEX);}_
_
}_
_
if(readCard != “”){_
_
Serial.println("CardID to be Sent : " + readCard);_
_
requesFromServer(readCard);*_

* } *
* }*
* }*
boolean pin2 = debounce(lastBtnState,INTERRUPT_PIN);
if(pin2 == HIGH){
* Serial.println(“Interrpt Btn Click !!”);*
* requesFromServer(“interrupt CardID”);*
* }*
}
void requesFromServer(String cardID){
* Serial.println("Sending CardID : " + cardID);*

* byte sd = stash.create();*
* stash.print(“cardid=”);*
* stash.print(cardID);*
* stash.save();*
* int stash_size = stash.size();
_
// Compose the http POST request, taking the headers below and appending*_
* // previously created stash in the sd holder.*
* Stash::prepare(PSTR(“POST http://$F/trials/arduino/ HTTP/1.0” “\r\n”*
* “Host: $F” “\r\n”*
* “Content-Length: $D” “\r\n”*
* “Content-Type: application/x-www-form-urlencoded” “\r\n”*
* “\r\n”*
* “$H”),*
* website, website, stash_size, sd);
_
// send the packet - this also releases all stash buffers once done*_
* // Save the session ID so we can watch for it in the main loop.*
* session = ether.tcpSend();*

* unsigned long LastTime = millis();*
* reply = 0;*
while (!reply){
digitalWrite(ETHER_CS_PIN,LOW);
* digitalWrite(RFID_CS_PIN,HIGH);
ether.packetLoop(ether.packetReceive());
_
reply = ether.tcpReply(session);_
_
if (reply != 0) {_
_
Serial.println(“Got a response!”);_
_
Serial.println(reply);*_

}

* if((millis() - LastTime) > 1000){*
* Serial.println(“Request Timed Out !!”);*
* break;*
* }*
}
}
boolean debounce(boolean last,int inputButton){

* boolean current = digitalRead(inputButton);*
* if(current != last){*
* delay(50);*
* current = digitalRead(inputButton);*
* }else{*
* current = LOW ;*
* }*
* return current;*

}
void ShowReaderDetails() {
* // Get the MFRC522 software version*
* byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
_
Serial.print(F(“MFRC522 Software Version: 0x”));_
_
Serial.print(v, HEX);_
_
if (v == 0x91)_
_
Serial.print(F(" = v1.0"));_
_
else if (v == 0x92)_
_
Serial.print(F(" = v2.0"));_
_
else*_
* Serial.print(F(" (unknown)"));*
* Serial.println("");*
* // When 0x00 or 0xFF is returned, communication probably failed*
* if ((v == 0x00) || (v == 0xFF)) {*
* Serial.println(F(“WARNING: Communication failure, is the MFRC522 properly connected?”));*
* }*
}
NOtWOrking.ino (3.8 KB)

Its possible that the libraries are driving the CS pin.

According to the docs you can choose a different pin for ether CS - is it possible you can try that?

Otherwise you can try to narrow the problem down:-

Do you see any connection attempt at the webserver end when the connection fails?

Does the program print the debug strings even when the connection fails?

Have you tried extending the timeout? Increase from 1000 to 10000 perhaps?

Does the connection fail the same way even if you press the button rather than swipe the card?

If you add code to your main loop that sends a request at a set interval (as well as waiting for events) does every second one fail?

I changed the cs for the ether a lot , but it didn't resolve the problem , I think the RFID lib is forcing the CS in a certain state and I don't know how to stop it ?

If you tried different pins for ether CS and it didnt change then I dont think it is the RFID library- its possible RFID is driving one pin, but unlikely it is driving many other pins. I guess you could comment out the ether code then monitor pin 8 to see if it changes during RFID read.

Did you try some of my other suggestions?