CM3-Panel technical documentation Buy on-line
PANEL EXP1 | NFC MODULE |
---|---|
GND | GND |
3V3 | VCC |
I2C_SDA1 | SDA |
I2C_SCL1 | SCL |
Set the dip switch o NFC module on teh I2C interface
Enable I2C interface on the Pi with
raspi-config
Install I2C utility binaries
sudo apt update
sudo apt install i2c-tools
Probe for I2C devices:
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
The NFC module is replying at the address 0x24
Install the NFC tools:
sudo apt install libnfc5 libnfc-bin libnfc-examples
Configure the NFC tool editing this file:
sudo nano /etc/nfc/libnfc.conf
and adding on it these two lines:
device.name = "PN532 over I2C"
device.connstring = "pn532_i2c:/dev/i2c-1"
List connected NFC readers:
fc-scan-device -v
nfc-scan-device uses libnfc 1.7.1
1 NFC device(s) found:
- pn532_i2c:/dev/i2c-1:
pn532_i2c:/dev/i2c-1
chip: PN532 v1.6
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
Read a card or tag by first starting nfc-poll then physically holding a NFC/RFID tag or card in front of the reader:
nfc-poll
nfc-poll uses libnfc 1.7.1
NFC reader: pn532_i2c:/dev/i2c-1 opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): 77 d3 d1 ad
SAK (SEL_RES): 08
nfc_initiator_target_is_present: Target Released
Waiting for card removing...done.
Install git on your CM3-Panel:
sudo apt install git
Then clode this Python library:
git clone https://github.com/HubCityLabs/py532lib.git
move inside the directory:
cd py532lib
and edit this Python3 program in a file called readcard.py:
from py532lib.i2c import *
from time import sleep
pn532=Pn532_i2c()
pn532.SAMconfigure()
while True:
data=pn532.read_mifare().get_data()
if len(data)==11:
uid="%02X%02X%02X%02X" % (data[7],data[8],data[9],data[10])
print(uid)
sleep(1)
else:
sleep(1)
run it by typing:
python3 readcard.py