Ahoj,
snažím se rozchodit ESP8266 s RFID-RC522 čtečkou karet a I2c displejem.
Bohužel mi nefunguje obojí zároveň.
Buď můžu inicializovat čtečku, kartu přečíst a poslat výstup alespoň na terminál nebo inicializovat display a zobrazovat text.
Obojí zároveň nefunguje.
Vůbec netuším proč.
Čtečka a displej používají stejný SDA port na ESP8266.
Port SDA je na desce jenom jeden.
Netuším jestli potřebuji dva SDA porty?
https://i2.wp.com/randomnerdtutorials.com/wp-content/uploads/2019/05/ESP8266-NodeMCU-kit-12-E-pinout-gpio-pin.png?quality=100&strip=all&ssl=1
testovací kód
#include <SPI.h>
#include <MFRC522.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
#define SS_PIN D2
#define RST_PIN D3 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN,RST_PIN); // Create MFRC522 instance
const char* host = "script.google.com";
const int httpsPort = 443;
const char* fingerprint = "AB AB CD CD"; // for https
//***********Things to change*******************
const char* ssid = "";
const char* password = "";
String GOOGLE_SCRIPT_ID = ""; // Replace by your GAS service id
const String unitName = "headquarter"; // any name without spaces and special characters
//***********Things to change*******************
uint64_t openGateMillis = 0;
void LcdClearAndPrint(String text)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(text);
}
void setup() {
Serial.begin(9200);
//lcd.init(); // Init with pin default ESP8266 or ARDUINO
// lcd.begin(0, 2); //ESP8266-01 I2C with pin 0-SDA 2-SCL
// Turn on the blacklight and print a message.
//lcd.backlight();
//LcdClearAndPrint("Loading");
// Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
delay(900);
mfrc522.PCD_Init(); // Init MFRC522
delay(900); // 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
delay(900);
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
//LcdClearAndPrint("Ready");
}
byte readCard[4];
void loop() {
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
//LcdClearAndPrint("Please wait...");
Serial.println(F("Scanned PICC's UID:"));
String uid = "";
for (uint8_t i = 0; i < 4; i++) { //
readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX);
uid += String(readCard[i],HEX);
}
Serial.println("");
//LcdClearAndPrint("Dummy");
mfrc522.PICC_HaltA();
}