With a newer Onion RFID & NFC Expansion you can now bring contactless access to control things like electromagnetic locks, LEDs, access permissions, etc. It supports reading and writing with several NFC and RFID protocols at 13.56 MHz. The Expansion is based on the popular
PN532 NFC Chip and communicates with the Omega via
You can control the Expansion with Mifare, Jewel and FeliCa RFID/NFC tags. The RFID & NFC Expansion comes with two Mifare Ultralight tags that you can read and write to the tag.Software Installation
Let's install the necessary firmware:
opkg install nfc-exp
opkg install python-light pyOledExp pyRelayExp python-pyserial
This will install the Hardware Setup
nfc-utils package, which contains several command line programs based on the
libnfc library for interacting with NFC devices, Python and necessary python modules.
Let's build the our circuit.
- Plug Omega2 into an Expansion Dock (or any other dock with an expansion header)
- Plug Relay Expansion into the expansion header on the dock.
- Insert RFID & NFC Expansion into the expansion header on the Relay Expansion
- Insert OLED Expansion into the expansion header on the RFID & NFC Expansion
- Connect the negative (ground) terminal (usually the black wire) of the lock to the negative (ground) terminal of the power supply.
- Next, connect the positive terminal of your supply to the IN screw terminal of Channel 0 on the Relay Expansion
- Finally, connect the positive (power) terminal (usually red) to the OUT screw terminal of Channel 0 on the Relay Expansion.
Now we are almost set to go. Writing the Code
On your Omega, clone the RFID Access Control repo to your Let's Rock!
/root directory Please mind the comments inside of the code; make changes accordingly that apply to your own settings. If you need to more information, please refer to the Official Documentation on Relay Expansion Python Module and Using RFID & NFC Expansion
Power up the lock and issue the following command:
# python rfid-access-control.py
The program waits till you tap the card that is specified and opens the lock for 5 seconds if the card is presented, if not, it'll constantly wait till the specified tag is tapped.