nancy
Posts: 12
Joined: Thu Jun 12, 2014 5:31 am

py532 with i2c

Wed Jul 09, 2014 9:39 am

Hi

I am connecting adafruit pn532 nfc reader with the raspberry pi. I want to read the tag data using python script. I am using the example http://hubcitylabs.org/nfc-on-raspberry ... b-and-i2c/

i have enabled i2c on pi and with sudo i2cdetect -y 1 it is giving:

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


I have already installed pn532lib, python3 but now when i am executing sudo python reader.py, it is giving following error:
File "reader.py", line 5, in <module>
from py532lib.i2c import *
ImportError: No module named i2c

Can anyone help me with this?

Regards
Nancy

sosorry
Authorised Reseller
Authorised Reseller
Posts: 4
Joined: Sun Jul 07, 2013 8:04 pm

Re: py532 with i2c

Sun Jul 27, 2014 3:18 pm

You have to set PYTHONPATH environment variable.

For example,
1. Add PYTHONPATH in your ~/.bashrc file

Code: Select all

PYTHONPATH="${PYTHONPATH}:/path/to/pn532lib"
2. Add PYTHONPATH in your code

Code: Select all

import sys
sys.path.append("/path/to/py532lib")
good luck for your project : )

Ariel84
Posts: 1
Joined: Mon Jul 28, 2014 11:30 am

Re: py532 with i2c

Mon Jul 28, 2014 11:32 am


sosorry
Authorised Reseller
Authorised Reseller
Posts: 4
Joined: Sun Jul 07, 2013 8:04 pm

Re: py532 with i2c

Tue Jul 29, 2014 6:37 pm


Return to “General discussion”