I am having problem with the ESP8266 and RC522 on Arduino uno
IF the Arduino reset pin connect to the ground, the ESP work fine but RC522 not.
IF the reset pin doesn't connect, the RC522 work but the ESP not
Is the circuit connection wrong or the code need some change?
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <SPI.h>
#include <MFRC522.h>
#define RESET 9
#define SS 10
MFRC522 mfrc522(SS, RESET);
/* Set these to your desired credentials. */
const char *ssid = "tai"; //ENTER YOUR WIFI SETTINGS
const char *password = "264395361";
String day;
String time2;
String time1;
int pos;
String hour;
String linkurl;
String linkurl2;
//Link to read data from https://jsonplaceholder.typicode.com/comments?postId=7
//Web/Server address to read/write from
const char *host = "test3-xxxxx.firebaseio.com";
const int httpsPort = 443; //HTTPS= 443 and HTTP = 80
//SHA1 finger print of certificate use web browser to view and copy
const char fingerprint[] PROGMEM = "x";
//=======================================================================
// Power on setup
//=======================================================================
int rfid(){
int stid=0;
if (mfrc522.PICC_IsNewCardPresent()) {
if (mfrc522.PICC_ReadCardSerial()){
byte *id = mfrc522.uid.uidByte;
byte idSize = mfrc522.uid.size;
for (byte i = 0; i < idSize; i++) {
Serial.print("0x");
Serial.print(id[i]);
Serial.print(" ");
}
stid=int(id[0])+int(id[1])+int(id[2])+int(id[3]);
Serial.println();
Serial.print(stid);
return stid;
Serial.println();
}
mfrc522.PICC_HaltA();
}
}
String GETTIME() {
String payload;
HTTPClient http; //Declare an object of class HTTPClient
http.begin("http://worldtimeapi.org/api/ip"); //Specify request destination
int httpCode = http.GET(); //Send the request
if (httpCode > 0) { //Check the returning code
payload = http.getString(); //Get the request response payload
Serial.println(payload); //Print the response payload
}
http.end(); //Close connection
return payload;
}
void setup() {
delay(1000);
Serial.begin(115200);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
delay(4); // Optional delay. Some board do need more time after init to be ready, see Readme
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)
delay(1000);
WiFi.mode(WIFI_STA); //Only Station No AP, This line hides the viewing of ESP as wifi hotspot
WiFi.begin(ssid, password); //Connect to your WiFi router
Serial.println("");
Serial.print("Connecting");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
//If connection successful show IP address in serial monitor
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //IP address assigned to your ESP
}
//=======================================================================
// Main Program Loop
//=======================================================================
void loop() {
time1 = GETTIME();
int sum=rfid();
Serial.println(sum);
//PATCH();
delay(2000); //POST Data at every 2 seconds
}