This is an old revision of the document!
Projekt RFID Read-Write
| Project owner: | Overdrive |
| Interested: | |
| Related: | [Project Dvere] |
| References: | [Dioda pro lamy - ENG] – [GPIO explanations] – [BananaPi GPIO manual] |
| Materials: | BananaPi, RFID-RC522, nepajive pole, kabely samec-samice s jumper konci, 5V napajeni, pajecka, pocitac s SSH |
| License: | Uveďte původ-Zachovejte licenci; CC BY-SA |
RC522 vs BananaPi Pinout
| RFID-RC522 Pin | Banana Pi Pin | Banana PI Pin Name | Cable color |
| 3.3V | 1 | +3.3V | Red |
| GND | 6 | GND | Black |
| MOSI | 19 | GPIO10/MOSI | brown |
| MISO | 21 | GPIO09/MSO | blue |
| CLOCK | 23 | GPIO11/SCLK | yellow |
| SS | 24 | COE0#/GPIO07 | green |
Reference:
- SCLK : Serial Clock (output from master).
- MOSI : Master Output, Slave Input (output from master).
- MISO : Master Input, Slave Output (output from slave).
- SS : Slave Select (active low, output from master).
SPI Pins kernel module [Specific for BananaPI]
[root@picka ~]# echo "spi-sun7i" >> /etc/modules [root@picka ~]# shutdown -r now "SPI module load, test after restart" [root@picka ~]# lsmod Module Size Used by spidev 6177 0 spi_sun7i 17962 0 8192cu 453603 0 mali_drm 2608 0 drm 209014 1 mali_drm mali 111136 0 ump 51819 1 mali lcd 3778 0
Python to control GPI
[root@picka ~]# aptitude install python-dev
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
[root@picka ~]# git clone https://github.com/lthiery/SPI-Py.git
Cloning into 'SPI-Py'...
remote: Counting objects: 77, done.
remote: Total 77 (delta 0), reused 0 (delta 0), pack-reused 77
Unpacking objects: 100% (77/77), done.
Checking connectivity... done.
[root@picka ~]# cd SPI-Py
[root@picka SPI-Py]# python setup.py install
running install
running build
running build_ext
building 'spi' extension
creating build
creating build/temp.linux-armv7l-2.7
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c spi.c -o build/temp.linux-armv7l-2.7/spi.o
creating build/lib.linux-armv7l-2.7
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/spi.o -o build/lib.linux-armv7l-2.7/spi.so
running install_lib
copying build/lib.linux-armv7l-2.7/spi.so -> /usr/local/lib/python2.7/dist-packages
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/SPI_Py-1.0.egg-info
[root@picka SPI-Py]# cd ..
[root@picka ~]# git clone https://github.com/mxgxw/MFRC522-python.git
Cloning into 'MFRC522-python'...
remote: Counting objects: 60, done.
remote: Total 60 (delta 0), reused 0 (delta 0), pack-reused 60
Unpacking objects: 100% (60/60), done.
Checking connectivity... done.
[root@picka ~]# cd MFRC522-python
[root@picka MFRC522-python]# python Read.py
BAPI: Banana Pi!!
BAPI: Banana Pi!!
BAPI: Banana Pi!!
BAPI: Banana Pi!!
BAPI: revision(3)
Welcome to the MFRC522 data read example
Press Ctrl-C to stop.
Card read UID: 100,83,136,50
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 100,83,136,50
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 100,83,136,50
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 100,83,136,50
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
READ NFC522 by node-red
[root@picka ~]# node -v
v0.10.29
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
# version can be switched by: sudo n 0.8.21
[root@picka ~]# node -v
v6.2.0
[root@picka ~]# npm install node-pre-gyp
npm WARN package.json node-red-node-bananapi@0.0.2 No README data
npm WARN engine deep-extend@0.4.1: wanted: {"node":">=0.12.0","iojs":">=1.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine hawk@3.1.3: wanted: {"node":">=0.10.32"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine cryptiles@2.0.5: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine hoek@2.16.3: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine boom@2.10.1: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
node-pre-gyp@0.6.28 node_modules/node-pre-gyp
├── semver@5.1.0
├── nopt@3.0.6 (abbrev@1.0.7)
├── rc@1.1.6 (ini@1.3.4, strip-json-comments@1.0.4, deep-extend@0.4.1, minimist@1.2.0)
├── mkdirp@0.5.1 (minimist@0.0.8)
├── rimraf@2.5.2 (glob@7.0.3)
├── npmlog@2.0.4 (ansi@0.3.1, gauge@1.2.7, are-we-there-yet@1.1.2)
├── tar-pack@3.1.3 (uid-number@0.0.6, once@1.3.3, debug@2.2.0, fstream-ignore@1.0.5, readable-stream@2.0.6, fstream@1.0.9)
├── request@2.72.0 (is-typedarray@1.0.0, oauth-sign@0.8.2, aws-sign2@0.6.0, forever-agent@0.6.1, tunnel-agent@0.4.3, caseless@0.11.0, stringstream@0.0.5, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, aws4@1.4.1, combined-stream@1.0.5, node-uuid@1.4.7, qs@6.1.0, tough-cookie@2.2.2, mime-types@2.1.11, form-data@1.0.0-rc4, bl@1.1.2, http-signature@1.1.1, har-validator@2.0.6, hawk@3.1.3)
└── tar@2.2.1 (inherits@2.0.1, block-stream@0.0.9, fstream@1.0.9)
[root@picka ~]# npm install node-red-contrib-gpio
....
[root@picka ~]# npm install raspi-io