rb2468 / tray-a-way

GNU General Public License v3.0
0 stars 0 forks source link

Reading Values #58

Closed hesther224 closed 2 years ago

hesther224 commented 2 years ago

I was able to detect the address of the NFC module. I also followed two tutorials to try and read/test the nfc module (I had to download libnfc to do so). Tutorial 1: adafruit Tutorial 2: setting up PN532. However, when I tried running nfc-poll to detect the tag, there was no response. I screenshotted my terminal after running nfc-poll.

hesther224 commented 2 years ago

Going to follow this tutorial for i2c NFC module w/ Pi as well as Wiki Instructions

hesther224 commented 2 years ago

connections

To connect the NFC module to the Pi, I had the D/T connected to the SDA/GPIO 2 (PPN 3), C/R connected to the SCL/GPIO 3 (PPN 5), GND to GND, and VCC to 5V.

hesther224 commented 2 years ago
Screen Shot 2022-02-23 at 12 53 12 PM

In the Pi terminal, type in sudo raspi-config to enable i2c on the pi.

Screen Shot 2022-02-23 at 12 55 49 PM
hesther224 commented 2 years ago

Next, I installed dependent packages: sudo apt-get update & sudo apt-get install libusb-dev libpcsclite-dev i2c-tools

Screen Shot 2022-02-23 at 12 58 27 PM
hesther224 commented 2 years ago

After, I downloaded and extracted the source code package of libnfc

Screen Shot 2022-02-23 at 1 23 03 PM
hesther224 commented 2 years ago

Next, compile and install: ./configure --prefix=/usr --sysconfdir=/etc

Screen Shot 2022-02-23 at 1 29 29 PM Screen Shot 2022-02-23 at 1 29 45 PM Screen Shot 2022-02-23 at 1 29 57 PM Screen Shot 2022-02-23 at 1 30 11 PM

make

Screen Shot 2022-02-23 at 1 30 26 PM Screen Shot 2022-02-23 at 1 30 40 PM Screen Shot 2022-02-23 at 1 30 52 PM

sudo make install

Screen Shot 2022-02-23 at 1 31 08 PM Screen Shot 2022-02-23 at 1 31 32 PM Screen Shot 2022-02-23 at 1 31 44 PM Screen Shot 2022-02-23 at 1 31 55 PM Screen Shot 2022-02-23 at 1 32 04 PM
hesther224 commented 2 years ago

Next, I edited the libnfc.conf file. First, move into the etc directory (cd /etc) The tutorial said to make a new directory called nfc, but the libnfc that I installed already had it so I worked inside of the pre-existing nfc directory.

Screen Shot 2022-02-23 at 1 35 33 PM

Afterwords, I manually added the device name & device connstring as stated in the tutorial which is: device.name = "_PN532_I2c" device.connstring = "pn532_i2c:/dev/i2c-1"

I also uncommented: allow_autoscan = true allow_intrusive_scan = false log_level = 1

Screen Shot 2022-02-23 at 1 38 54 PM
hesther224 commented 2 years ago

As shown in the previous picture, I have my NFC module toggled to i2c and I wired the device to my Pi to use the i2c instead of UART.

Next, to make sure my device is recognized, I went to the main directory and first typed in "lsmod | grep i2c" and got the expected response which was bcm2835 and dev. Then, I typed in "i2cdetect -y 1" and got the device's address which is 0x24 as shown in the image.

Screen Shot 2022-02-23 at 1 43 08 PM
hesther224 commented 2 years ago

Unfortunately, at the last step, when I typed nfc-list I did not get the expected outcome. I also tried running nfc-poll to see if the tag could be read by the device but the following error messages showed up.

Screen Shot 2022-02-23 at 1 47 58 PM
hesther224 commented 2 years ago

I saw that in libnfc/etc/nfc/devices.d there was only uart devices so I referred to this link No NFC device found since I couldnt detect an nfc device. I typed "./configure --with-drivers=pn532_i2c" in the libnfc folder

Screen Shot 2022-02-23 at 2 07 02 PM

Now, I only have the pn532_i2c driver selected when before I had many other drivers.

Screen Shot 2022-02-23 at 2 07 33 PM

Then I typed in the terminal the following: make sudo make install

hesther224 commented 2 years ago

For some reason, I now can't edit the libnfc.conf file anymore when I was able to before.

Screen Shot 2022-02-23 at 2 17 02 PM
hesther224 commented 2 years ago

I'm able to read the address from the device so I know that my pi can detect the nfc module, however the problem is that my error message keeps telling me I'm detecting using uart and unable to open the i2c device. @ffund Since I can't edit the libnfc.conf, the only solution I can think of is restarting the whole tutorial so that I can edit libnfc.conf since I tried removing the file (rm libnfc.conf) but permission was denied. I'm positive I have my connections correct as well as reading the address, the only issue I keep running into is not being able to read a tag.

hesther224 commented 2 years ago

I'm going to try following a different tutorial since it's a video of someone using the device with the Pi terminal. RFID/NFC reader & writer with PN532 ft. Raspberry Pi

ffund commented 2 years ago

Unfortunately, at the last step, when I typed nfc-list I did not get the expected outcome. I also tried running nfc-poll to see if the tag could be read by the device but the following error messages showed up. Screen Shot 2022-02-23 at 1 47 58 PM

Can you try this command with sudo? Also please show the output of

ls /dev
ffund commented 2 years ago

For some reason, I now can't edit the libnfc.conf file anymore when I was able to before. Screen Shot 2022-02-23 at 2 17 02 PM

What command did you use to open the file for editing? Did you use sudo?

Can you show the output of

ls -als /etc/nfc/libnfc.conf

This will show us the file permissions - with that information, I can tell you what you need to do to make it editable.

hesther224 commented 2 years ago

This is me using sudo with the previous commands as well as the output of ls /dev on my terminal:

Screen Shot 2022-02-23 at 2 36 40 PM

This is ls -als /etc/nfc/libnfc.conf:

Screen Shot 2022-02-23 at 2 37 33 PM
ffund commented 2 years ago

This is me using sudo with the previous commands as well as the output of ls /dev on my terminal: Screen Shot 2022-02-23 at 2 36 40 PM

This shows us that the I2C device i2c-1 is there, so that's good.

This is ls -als /etc/nfc/libnfc.conf: Screen Shot 2022-02-23 at 2 37 33 PM

This shows that the file is owned by root and the owner has permission to write and read it (rw). Everyone else only has read permission (r).

You can "become" the root user with

sudo su

Your terminal prompt will change from a $ to a #. Then, try to open the file for editing.

When you're finished "being root" use exit to go back to your normal prompt with normal user privileges.

hesther224 commented 2 years ago

Thank you! I'm now able to make changes in the libnfc file.

Screen Shot 2022-02-23 at 2 45 10 PM

I'm going to try setting the allowing auto detection and see if that can detect my device since my manual set up isn't working.

Screen Shot 2022-02-23 at 2 46 02 PM
hesther224 commented 2 years ago

Unfortunately, it didn't change anything so to be on the safe side, I'm going to set it to the default setting again.

Screen Shot 2022-02-23 at 2 47 50 PM
ffund commented 2 years ago

Can you try powering off your Pi, the turning it back on, leaving the NFC module connected?

(See https://raspberrypi.stackexchange.com/a/84468)

ffund commented 2 years ago

Have you tried the waveshare demo code? It doesn't seem to have the libnfc dependency.

https://www.waveshare.com/wiki/PN532_NFC_HAT

hesther224 commented 2 years ago

I turned off my Pi and tried turning it back on with the NFC module but I get this error message. I'm unable to connect to the pi. I've also seen that stackexchange solution and tried it before, but my Pi would only connect if I connected the nfc module after. I'm connected to my hotspot both for my pi and my laptop so the issue isn't the connection. I've also tried with the VNC viewer instead of my laptop's terminal but I would get a timed out message.

Screen Shot 2022-02-23 at 2 53 52 PM Screen Shot 2022-02-23 at 2 56 38 PM
hesther224 commented 2 years ago

Have you tried the waveshare demo code? It doesn't seem to have the libnfc dependency.

https://www.waveshare.com/wiki/PN532_NFC_HAT

I haven't tried that before. I was thinking about following this tutorial since they installed a different libnfc This is the link. Should I try this out since it seems to work for them (they also show an example with python). Or should I try the waveshare and forget about the libnfc route since it seems like libnfc is not dependable.

Screen Shot 2022-02-23 at 2 40 07 PM
ffund commented 2 years ago

Let's list all the alternatives:

All reasonable alternatives to try - just document what happens when you try each one.

ffund commented 2 years ago

FYI - if you have a libnfc version installed by compiling source code (as you have done), and another installed from the package manager (as in that video), your system is likely to use the one installed from source with higher priority.

So if you decide to try the libnfc from package manager, you should uninstall the one you installed from source first

ffund commented 2 years ago

After, I downloaded and extracted the source code package of libnfc Screen Shot 2022-02-23 at 1 23 03 PM

This doesn't show you downloading the code - it shows installing libnfc from package manager.

Where did you get the version that you installed from source? Do we know anything about how old that version was?

ffund commented 2 years ago

Looking at the tutorial you followed - I think that was an old-ish version. You could try installing the latest from source:

https://github.com/nfc-tools/libnfc

hesther224 commented 2 years ago

https://github.com/nfc-tools/libnfc

Do I install it by writing "git clone https://github.com/nfc-tools/libnfc.git" in my pi terminal?

ffund commented 2 years ago

Well, that's how you would get the code, not how you would install it.

But first, you would need to pay attention to your starting point - cd to whatever directory you want to download the code to.

If you try to put it in your home directory, it will warn you that there's already a libnfc directory there! Maybe make a subdirectory in your home directory, cd there, then clone the code.

After you get the code, you'll install it in a similar way to how you installed the previous libnfc version you were working with (configure, make, etc with whatever arguments were appropriate).

On Wed, Feb 23, 2022, 3:17 PM hesther224 @.***> wrote:

https://github.com/nfc-tools/libnfc https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nfc-2Dtools_libnfc&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=I9BsLVy0GqfbbCxRCFKVXw&m=T-NlECmhVyZd3ugpQp458CxF07wWznYISuYLfD7vmXt1P_MV9klVVJjBYDHTGaFt&s=y_qjFM_bbVbkBFabwCpymjzMwTdGDpiQ7WAo7927rik&e=

Do I install it by writing "git clone https://github.com/nfc-tools/libnfc.git https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nfc-2Dtools_libnfc.git&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=I9BsLVy0GqfbbCxRCFKVXw&m=T-NlECmhVyZd3ugpQp458CxF07wWznYISuYLfD7vmXt1P_MV9klVVJjBYDHTGaFt&s=t3D2JZUEktdCHglzv5aSpQZQNT_Cqv2ifGSDaSjiQX0&e=" in my pi terminal?

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_rb2468_tray-2Da-2Dway_issues_58-23issuecomment-2D1049176490&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=I9BsLVy0GqfbbCxRCFKVXw&m=T-NlECmhVyZd3ugpQp458CxF07wWznYISuYLfD7vmXt1P_MV9klVVJjBYDHTGaFt&s=_U3sy-K-4erWyTCisKvNqoAFt4Wb5-LLmXfnKbJYtZA&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AARVSCJOO3ZFAYFKGOWYYIDU4U6GTANCNFSM5PDPD4OQ&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=I9BsLVy0GqfbbCxRCFKVXw&m=T-NlECmhVyZd3ugpQp458CxF07wWznYISuYLfD7vmXt1P_MV9klVVJjBYDHTGaFt&s=YuWba9_DcybzpDTLOze_5OOFQp6AUmzSic5w8u2tjN0&e= . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.proofpoint.com/v2/url?u=https-3A__apps.apple.com_app_apple-2Dstore_id1477376905-3Fct-3Dnotification-2Demail-26mt-3D8-26pt-3D524675&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=I9BsLVy0GqfbbCxRCFKVXw&m=T-NlECmhVyZd3ugpQp458CxF07wWznYISuYLfD7vmXt1P_MV9klVVJjBYDHTGaFt&s=g06GNsJoDO53mbXNcpSm7dElJ-bof5Z0vtqtoqU_p4w&e= or Android https://urldefense.proofpoint.com/v2/url?u=https-3A__play.google.com_store_apps_details-3Fid-3Dcom.github.android-26referrer-3Dutm-5Fcampaign-253Dnotification-2Demail-2526utm-5Fmedium-253Demail-2526utm-5Fsource-253Dgithub&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=I9BsLVy0GqfbbCxRCFKVXw&m=T-NlECmhVyZd3ugpQp458CxF07wWznYISuYLfD7vmXt1P_MV9klVVJjBYDHTGaFt&s=GHxufqXuIieQxyzvPOwSibo_GvhXKO9kpnMYuAbD_Yc&e=.

You are receiving this because you were mentioned.Message ID: @.***>

hesther224 commented 2 years ago

After, I downloaded and extracted the source code package of libnfc Screen Shot 2022-02-23 at 1 23 03 PM

This doesn't show you downloading the code - it shows installing libnfc from package manager.

Where did you get the version that you installed from source? Do we know anything about how old that version was?

I forgot to document this step but there was a 502 bad gateway from the link so I followed this link to download the libnfc instead. The revision history says it's from 2017 which is the same one used in the video tutorial I talked about before which was used in 2019.

Screen Shot 2022-02-23 at 3 18 02 PM
hesther224 commented 2 years ago

I'm following the video tutorial that I found previously using the most recent libnfc from this link. The video tutorial was this one. I'll be following the tutorial for installing libnfc using this tutorial & this to know the commands to download the most recent version of libnfc which is 1.8.0.

Note: used the command shown in this link. The commands used were: wget https://github.com/nfc-tools/libnfc/releases/download/libnfc-1.8.0/libnfc-1.8.0.tar.bz2 tar -xvjf libnfc-1.8.0.tar.bz2

hesther224 commented 2 years ago

I made a new directory called libnfc-try2 as my new starting point for this tutorial.

Picture of me downloading libnfc v1.8.0

Screen Shot 2022-02-27 at 8 15 11 PM

Next, used the following commands: ./configure --prefix=/usr --sysconfdir=/etc make sudo make install

Next, I went into /etc/nfc/libnfc.conf file and made edits so that I have a device name and connstring.

Screen Shot 2022-02-27 at 8 28 08 PM Screen Shot 2022-02-27 at 8 28 48 PM

Unfortunately, it was a bust again, even with the newest libnfc version.

Screen Shot 2022-02-27 at 8 31 25 PM

The device is still detected by the Pi, as shown in the picture with i2cdetect -y 1.

Screen Shot 2022-02-27 at 8 32 39 PM
hesther224 commented 2 years ago

I searched for this issue nfc_open failed for pn532_i2c:/dev/i2c-1 since that's what shows up in my terminal and found this link. It says to configure with this command: ./configure --with-drivers=pn532_i2c make sudo make install

Then I ran these commands: sudo sh -c "echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf" sudo ldconfig

And set my device name and connstring in the /etc/nfc/libnfc.conf as: device.name = "PN532 board via I2C" allow_intrusive_scan = true device.connstring = pn532_i2c:/dev/i2c-1

Ran this command: LIBNFC_LOG_LEVEL=3 nfc-scan-device -i -v

Then I tested out reading the tag: nfc-list

tag not present

Screen Shot 2022-02-27 at 8 56 24 PM

tag present

Screen Shot 2022-02-27 at 8 57 02 PM

The only thing is that I don't know why it's mentioning UART when I'm using I2C. But all in all, I got the nfc module to read my tag using libnfc method :) FINALLY

hesther224 commented 2 years ago

This is me testing out the tag with nfc-poll command:

Screen Shot 2022-02-27 at 8 59 04 PM
ffund commented 2 years ago

Remember that you'll have to write up instructions for a "fresh" install (without all the parts that don't work).You might have to ask a team member to help you test that on a fresh system.

hesther224 commented 2 years ago

Tutorial 2: setting up PN532

I'll clean up my tutorial on how to do a fresh install. We would have to meet up to test it on the NFC module so I'll show them how during this week's lab.

bshapero13 commented 2 years ago

Tested out instructions, NFC reader worked