Open Nights now on Tuesdays!

Open Nights at the HubCityLabs Hackerspace will now be on Tuesdays!

Read More »
snowed-out

Open Night Cancelled for Tonight, Feb 9

Due to the blizzard, HubCityLabs will not be open tonight, Feb 9. We’ll be back next week!

Read More »
HubCityLabs Open Night

Open Night Saturday Jan 26 @ 6PM

Visit us tonight at the HubCityLabs Open Night, as we hack on our RaspberryPIs, continue our 3D printer build, code on our Web Apps and tidy up the lab!

This event is free and open to the public!

Read More »
HubCityLabs Open Night

Open Night Saturday Jan 19 @ 6PM

Visit us tonight at the HubCityLabs Open Night, as we hack on our RaspberryPIs, continue our 3D printer build, improve our automated garden and code on Web Apps!

This event is open to the public!

Read More »
HubCityLabs Open Night

Open Night Saturday Jan 12 @ 6PM

Visit us tonight at the HubCityLabs Open Night, as we hack on our RaspberryPIs, continue our 3D printer build, improve our automated garden and code on Web Apps!

Open to members, prospective members and guests!

Read More »
HubCityLabs Open Night

Open Night Saturday Dec 8 @ 6PM

Visit us tonight at the HubCityLabs Open Night, as we hack on our RaspberryPIs, continue our 3D printer build and code on Web Apps!

Open to members, prospective members and guests!

Read More »
RaspberryPI

NFC on RaspberryPi with PN532, py532lib and i2c

Over the past few weeks, we at HubCityLabs have been busy! We’ve started work on a project will let us control access to our facilities with NFC cards, and later on, bio-metrics. Since for each access point, there will be multiple readers (NFC, fingerprint, retina scanners…) for each host (a RaspberryPi), we settled on using I2C as a standard for communication between the host and the peripherals. Our chosen language was Python, since it seems to be the de-facto language on the RaspberryPi.

py532lib

Out of the requirements above was born the need for a PN532/i2c package in Python3, so I created a project called py532lib. I chose to use Quick2Wire‘s Python API for Linux as it provides clean access to I2C, SPI, and for GPIO (on RaspberryPI). Currently, only I2C is supported in py532lib, however, in the long run we should be able to add SPI and UART communication capabilities to the PN532 under a single, seamless API.

Please be gentle, as this is my first ever attempt at coding anything in Python! I’ve done my best to make it easy to use, and respect as many PEP8 rules as possible. Forks and pull-requests will be welcomed with open arms.

Wiring

First you’ll need to follow the instructions from my earlier post, about enabling I2C for your RaspberryPi.

Second, you’ll need to make sure that the jumpers on the Adafruit NFC Breakout Board are set for I2C communications.

PN532 Wiring I2C RPi

The wiring schematic above is easy as pie. From the RaspberryPi, simply connect 3.3V and GND to the Breakout Board on JP4, then connect the SDA and SCL signals. As noted in NXP’s PN532 Application Note, 3.3k pull-up resistors should be used. If everything is connected properly, you should be able to see the PN532 on the I2C bus at the RaspberryPI’s shell.

sudo 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Note: If you have an older RaspberryPI, you will need to do “sudo i2cdetect -y 0″ instead.

Software

Now that py532lib are installed and available to your Python’s PATH, you should be able to write the following:

from py532lib.i2c import *
from py532lib.frame import *
from py532lib.constants import *

pn532 = Pn532_i2c()
pn532.SAMconfigure()

card_data = pn532.read_mifare().get_data()

print(card_data)

Now that py532lib is in polling mode, put an NFC card in the Breakout Board’s field, and it will return the card’s data.

Hopefully someone will find this useful! Cheers!

Related Links

Read More »
4000 CMOS Clock

Congrats to Open7400 Winner of the HubCityLabs Prize

Congratulations to Easton Elliott from British Columbia, for his winning entry to the Open7400 contest 2012! Easton built a simple 4000 series CMOS 24 hour clock with an elegant design!

We’ll be shipping his prize today; a new RaspberryPI 512MB Model B.

Read More »
hubcitylabs_birthday

Come Celebrate HubCityLab’s 1st Birtday Tonight!

Join us on Tonight (Saturday November 17th) for HubCityLab’s Birthday Bash! Potluck at 5h30, followed by an evening of console gaming and geekery!

BONUS: We’ll be running a LAN game of Counter Strike: Source!

It’s going to be a blast, see you there!

Read More »
hubcitylabs_birthday

Come Celebrate HubCityLab’s 1st Year!

Join us on Saturday November 17th for HubCityLab’s Birthday Bash! Potluck at 5h30, followed by an evening of console gaming and geekery!

BONUS: We’ll be running a LAN game of Counter Strike: Source!

It’s going to be a blast, see you there!

Read More »
1 2 3 5