I'm doing a project on Arduino Uno and it requires me to connect 3 different sensors together: Waveshare 2.9 E-paper, MFRC522 RFID Reader and a ESP8266 wifi module. problem is, The e-paper and RFID uses the same multiple digital pins. How can I connect all of them together in a beardboard?
Edit: The E-Paper uses:
e-paper 3V3 -> Arduino 3V3
e-paper GND -> Arduino GND
e-paper DIN -> Arduino D11
e-paper CLK -> Arduino D13
e-paper CS -> Arduino D10
e-paper DC -> Arduino D9
e-paper RST -> Arduino D8
e-paper BUSY -> Arduino D7
The rfid uses:
SDA --> Digital 10
SCK --> Digital 13
MOSI --> Digital 11
MISO --> Digital 12
IRQ --> unconnected
GND --> GND
RST --> Digital 9
3.3V -->3.3V
The wifi uses:
GND --> GND
VIN --> 3.3v
Enable --> 3.3V
TX --> RX
RX --> TX
I'm very new to electronics so i'm sorry if something does not make sense
I'm using library, code and instructions from this 3 websites:
E-paper ( Waveshare 2.9 E-paper): https://www.instructables.com/id/Getting-Started-With-E-Paper-Display-Modules/
RFID (MFRC522 RFID Reader): https://randomnerdtutorials.com/security-access-using-mfrc522-rfid-reader-with-arduino/
Wi-Fi (ESP8266 wifi module): https://www.hackster.io/jeffpar0721/add-wifi-to-arduino-uno-663b9e
Thanks!
1 Answer 1
You are lucky, the two devices creating the conflict both use the same pins because they both use the same interface, SPI to be precise, which allows to have multiple devices connected using different Chip Select
pins, abbreviated as CS
.
Of the two libraries, one allows to define the CS
pin (RFID module), the other has it hardcoded (ePaper). So, when declaring your RFID library, you should use the constructor that allows to define the chip select pin:
void PCD_Init(byte chipSelectPin, byte resetPowerDownPin);
This means in your code you should use:
PCD_Init(6,8) rfid;
The above also implies one of your RFID connections must be changed: what was previously SDA --> Digital 10
is now going to be SDA --> Digital 6
. Please note I picked pin 6 randomly among the pins that seem unused by your code, but any other unused pin will be a good choice, including analog pins.
BTW, the web page about the RFID module uses a pin naming which causes a lot of confusion because it mixes up SDA
with MISO
and MOSI
: those names are used in two different types of interface, the former is called I2C or TWI, the latter SPI. On Arduino the two interfaces share a couple of pins, but they are very different in many different ways.
In your case both modules use SPI
, which is good for you.
{}
code tags to format as in my tidy-up. I didn't fix your "beardboard" as it looks interesting.