I am trying to get an LCD screen to work with an rfid reader using the MFRC522 lib with the ST7735 lib on Teensy 3.2.
Here are the LCD and RFID reader:
https://www.aliexpress.com/item/J34...32599685873.html?spm=2114.40010308.4.2.YM6Z0v
https://www.jaycar.co.nz/arduino-compatible-rfid-read-and-write-kit/p/XC4506
I can get each to work independently but when I initialize the LCD the rfid reader fails with this warning:
WARNING: Communication failure, is the MFRC522 properly connected?
I suspect it is a communication problem involving SPI but I am not advanced enough to solved this. Have tried for many hours.
I have assigned the pins so that there is no conflict and both libraries appear to utilize the SPI.beginTransaction() and SPI.endTransaction() functions. (I found a version of ST7735 with this but it did not solve the issue).
Here is the code I am using. If I comment out the line 'tft.initR(INITR_BLACKAB);' then the reader works. Screen works if I un-comment but not both at the same time.
Any help would be most appreciated!
Here are the LCD and RFID reader:
https://www.aliexpress.com/item/J34...32599685873.html?spm=2114.40010308.4.2.YM6Z0v
https://www.jaycar.co.nz/arduino-compatible-rfid-read-and-write-kit/p/XC4506
I can get each to work independently but when I initialize the LCD the rfid reader fails with this warning:
WARNING: Communication failure, is the MFRC522 properly connected?
I suspect it is a communication problem involving SPI but I am not advanced enough to solved this. Have tried for many hours.
I have assigned the pins so that there is no conflict and both libraries appear to utilize the SPI.beginTransaction() and SPI.endTransaction() functions. (I found a version of ST7735 with this but it did not solve the issue).
Here is the code I am using. If I comment out the line 'tft.initR(INITR_BLACKAB);' then the reader works. Screen works if I un-comment but not both at the same time.
Code:
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <MFRC522.h>
#define sclk 14 // SCLK can also use pin 14
#define mosi 7 // MOSI can also use pin 7
#define cs 20 // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define dc 21 // but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define rst 8 // RST can use any pin
#define sdcs 4 // CS for SD card, can use any pin
#define RST_PIN 9 //
#define SS_PIN 10 //
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup(void) {
pinMode(sdcs, INPUT_PULLUP); // don't touch the SD card
pinMode(SS_PIN, OUTPUT);
Serial.begin(115200);
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
tft.initR(INITR_BLACKTAB);
SPI.begin();
mfrc522.PCD_Init(); // Init MFRC522
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
Any help would be most appreciated!
Last edited: