Skip to content

Updated NFC Build Guide #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6188b4e
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
19a57f6
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
b60ccfb
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
2022c7d
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
6729e18
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
3b89002
Update nfc_poll.conf
thepiwizard Sep 22, 2021
fc2839a
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
294f8a6
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
6910269
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
4c0aabf
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
0506bba
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
9c61398
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
ead3ebb
Update DIRECTIONS.md
thepiwizard Sep 22, 2021
dcdbb80
Create Parts-List.md
thepiwizard Sep 22, 2021
6f29ba6
Update Parts-List.md
thepiwizard Sep 22, 2021
78e7661
Update Parts-List.md
thepiwizard Sep 22, 2021
eb9acfc
Update Parts-List.md
thepiwizard Sep 22, 2021
63846e1
Update Parts-List.md
thepiwizard Sep 22, 2021
32978ce
Delete Mini NES Wiring.png
thepiwizard Sep 23, 2021
54913d2
Add files via upload
thepiwizard Sep 23, 2021
445738d
Delete wire-diagram.png
thepiwizard Sep 23, 2021
1abde86
Add files via upload
thepiwizard Sep 23, 2021
f44f1d3
Update Parts-List.md
thepiwizard Sep 23, 2021
883a92d
Update Parts-List.md
thepiwizard Sep 23, 2021
5f02aa9
Update Parts-List.md
thepiwizard Sep 23, 2021
4e03c93
Update Parts-List.md
thepiwizard Sep 23, 2021
3ce0d2b
Update Parts-List.md
thepiwizard Sep 23, 2021
fcb12a2
Update Makefile
thepiwizard Sep 23, 2021
90f5fff
Update Makefile
thepiwizard Sep 23, 2021
a77022b
Update Makefile
thepiwizard Sep 23, 2021
cc26d0c
Delete wire-diagram.png
thepiwizard Sep 27, 2021
0030f2b
Add files via upload
thepiwizard Sep 27, 2021
c0542f6
Delete wire-diagram.png
thepiwizard Sep 27, 2021
c9887f4
Add files via upload
thepiwizard Sep 27, 2021
7539cc4
Update Parts-List.md
thepiwizard Sep 27, 2021
62a5cfa
Update Parts-List.md
thepiwizard Sep 27, 2021
e9f7fe8
Update DIRECTIONS.md
thepiwizard Sep 28, 2021
597e522
Updated Directions
thepiwizard Sep 28, 2021
f215cd4
Update Parts-List.md
thepiwizard Sep 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 109 additions & 93 deletions DIRECTIONS.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,121 @@
# Mini NES Setup

## Prerequisites

1. Ensure Python 2.7 is working correctly and installed in `/usr/bin/python2.7`
2. `sudo apt-get install python-dev python-pip`
3. `sudo pip install python-daemon==2.2.4` (this is necessary to fix an issue with the latest release of python-daemon)

## Enable i2c device
1. `sudo mkdir /etc/nfc`
2. `sudo raspi-config`
3. Select "5 Interfacing"
4. Select "P5 I2C"
# NES NFC Reader Setup

Full Video & Photo guide will be posted at:
http://piwizardgaming.com/nfc

For a premade image with all of the below steps already completed visit:
http://thepiwizard.com > Select Downloads > and locate the NFC Image Download

## Step 1 - Prerequisites

1. Download and flash a copy of RetroPie (https://retropie.org.uk/download/) to your SD card And setup your controller.
2. Open the RetroPie menu and then open Raspi-Config
3. Select option `3 Interface Options`
4. Select `P2 SSH` Then select `Yes` to Enable it. then exit out back to the main menu screen
5. Download Putty On your computer (https://www.putty.org/)
6. Once installed SSH Into your PI : `Hostname = retropie` Click Open and then `username = pi` `password = raspberry` *Note* It will not display the password as you type it.
7. Type `python --version`
- Ensure Python 2.7 is working correctly and installed in `/usr/bin/python2.7`
8. Type `sudo apt update`
- Press `y` when prompted
9. Type `sudo apt upgrade`
- Press `y` when prompted
10. Type `sudo apt install python-dev`
- Press `y` when prompted
11. Type `sudo apt install python-pip`
12. Type `pip --version`
- <i>Ensure pip is installed and working (*pip 18.1 from /usr/lib/python2.7/dist-packages/pip (python 2.7)*)</i>
13. Type `sudo pip install python-daemon==2.2.4`
14. Type `python -m pip install -U pip`
15. Type `pip install watchdog`
16. Type `sudo shutdown -r now`
17. Once your system reboots - Reconnect with SSH and continue to Step 2

## Step 2 - Enable i2c device
1. Type `sudo mkdir /etc/nfc`
2. Type `sudo raspi-config`
3. Select `3 Interfacing`
4. Select `P5 I2C`
5. Select "\<Yes\>"
6. Exit `raspi-config` program
7. `sudo shutdown -r now` to reboot with i2c enabled.
7. Type `sudo shutdown -r now` to reboot with i2c enabled.
8. Once your system reboots - Reconnect with SSH and continue to Step 3

## Install libnfc
## Step 3 - Install libnfc
1. Ensure you are logged in as `pi` and in the `/home/pi` directory.
2. `wget -O libnfc-1.7.1.tar.bz2 https://bintray.com/nfc-tools/sources/download_file?file_path=libnfc-1.7.1.tar.bz2`
3. `tar -xvf libnfc-1.7.1.tar.bz2`
4. `cd libnfc-1.7.1`
5. `./configure --prefix=/usr --sysconfdir=/etc --with-drivers=pn532_i2c`
6. `make`
7. `sudo make install`
8. After reboot, type `lsmod |grep i2c` and ensure that you see an `i2c_dev` in the list.
9. Also, type `ls /dev/i2c*` and ensure that `/dev/i2c-1` is returned.

## Configure libnfc
1. `sudo nano /etc/nfc/libnfc.conf`
2. Cut and paste the following and save the file.
```
# Allow device auto-detection (default: true)
# Note: if this auto-detection is disabled, user has to manually set a device
# configuration using file or environment variable
allow_autoscan = true

# Allow intrusive auto-detection (default: false)
# Warning: intrusive auto-detection can seriously disturb other devices
# This option is not recommended, so user should prefer to add manually his/her device.
allow_intrusive_scan = false

# Set log level (default: error)
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
# Note: if you compiled with --enable-debug option, the default log level is "debug"
log_level = 1

# Manually set default device (no default)
# To set a default device, users must set both name and connstring for their device
# Note: if autoscan is enabled, default device will be the first device available in device list.
device.name = "PN532"
device.connstring = "pn532_i2c:/dev/i2c-1"
```
3. Run `nfc-poll` and ensure you see `NFC reader: pn532_i2c:/dev/i2c-1 opened`
4. Try reading a tag, use Ctrl-C to stop or just wait 30 seconds

## Install nfc_poll
1. Ensure you are logged in as `pi` and in the `/home/pi` directory.
2. `export NFC_HOME=/home/pi/libnfc-1.7.1`
3. `git clone https://github.com/coderkevin/mini-nes.git`
4. `cd mini-nes/nfc`
5. `make`
6. `sudo make install`
7. Run `systemctl status nfc_poll` and ensure you see "Active: active (running)" in the output

## Configure your cartridges
2. Type `wget -O libnfc-1.7.1.tar.bz2 https://piwizardgaming.com/nfc/libnfc-1.7.1.tar.bz2`
3. Type `tar -xvf libnfc-1.7.1.tar.bz2`
4. Type `cd libnfc-1.7.1`
5. Type `./configure --prefix=/usr --sysconfdir=/etc --with-drivers=pn532_i2c`
6. Type `make`
7. Type `sudo make install`
8. Type `sudo shutdown -r now`
9. After reboot, re-open putty and SSH back into the PI and type `lsmod | grep i2c` and ensure that you see an `i2c_dev` in the list.
10. Then type `ls /dev/i2c*` and ensure that `/dev/i2c-1` is returned.

## Step 4 - Configure libnfc
1. Type`cd /etc/nfc`
2. Type`sudo wget http://piwizardgaming.com/nfc/libnfc.conf`
3. Type `nfc-poll` and ensure you see `NFC reader: pn532_i2c:/dev/i2c-1 opened`<br>
![alt text](http://www.piwizardgaming.com/nfc/nfc-poll.png) <br>
4. Try reading a tag, use Ctrl-C to stop or just wait 30 seconds<br>
![alt text](http://www.piwizardgaming.com/nfc/tag-read.png) <br>

## Step 5 - Install nfc_poll
1. Type `cd /home/pi`
2. Type `export NFC_HOME=/home/pi/libnfc-1.7.1`
3. Type `git clone https://github.com/thepiwizard/mini-nes.git`
4. Type `cd mini-nes/nfc`
5. Type `make`
6. Type `sudo make install`
7. Type `systemctl status nfc_poll` and ensure you see "Active: active (running)" in the output<br>
![alt text](http://www.piwizardgaming.com/nfc/status.png) <br>

## Step 6 - Configure your cartridges

In this system, the cartridges don't need to be written to, we configure a mapping to their UIDs, which should already be uniquely pre-programmed to each tag.

### Record your NFC tag UIDs
1. Run `tail -f /dev/shm/nfc_poll.log`
2. Place a cartridge (NFC tag) over the reader, the log should output "Reading NFC UID: 00000000000000" where the zeroes are the UID of the tag.
## Step 7 - Record your NFC tag UIDs
1. Type `tail -f /dev/shm/nfc_poll.log`
2. Place a cartridge (NFC tag) over the reader, the log should output "Reading NFC UID: 00000000000000" where the zeroes are the UID of the tag.<br>
![alt text](http://www.piwizardgaming.com/nfc/tag-uid.png) <br>
3. Copy/paste the UID into a text file.
4. Continue with all tags you wish to use.
5. To exit the log, hit \<Ctrl\>-C

### Record your desired games
1. `cd ~/RetroPie/roms`
2. Start typing `ls <system>/<name of game>` (e.g. `ls nes/Super`) to find the rom you want. Hit tab to complete the file, or hit tab twice to show possible matches. Don't forget to backslash things like spaces and parenthesis as you go.
3. After you finally tab through to the complete file, hit <enter>.
4. Copy the resulting line and put it and put it next to the UID you want to use in your text file. (`e.g. nes/Super Mario Bros. (JU) [!].zip`) Make sure you don't have backslashes here.
5. Repeat this process
5. To exit the log, hit \<Ctrl\>-z

## Step 8 - Game Download Demo - ###
1. `cd ~/RetroPie/roms/nes`
2. `wget http://piwizardgaming.com/nfc/zelda.zip`

### Write your cartridges in the config
## Step 9 - Write your cartridges in the config
1. `sudo nano /etc/nfc_poll/nfc_poll.conf`
2. At the bottom of the file, there's a `[Cartridges]` section.
3. For each cartridge you want, add a line in this format: `<uid> = <game file>` (e.g. `00000000000000 = nes/Super Mario Bros. (JU) [!].zip`)
4. `sudo systemctl restart nfc_poll`
5. Try it out! Place one of your cartridges on the reader and the screen should go black for a couple seconds, then bring up your game. Remove it and it should go back to the dashboard.

## Install nes_buttons
1. Ensure you are logged in as `pi` and in the `/home/pi` directory.
2. (If you haven't already) `git clone https://github.com/coderkevin/mini-nes.git`
3. `cd mini-nes/buttons`
4. `sudo make install`
5. Run `systemctl status nes_buttons` and ensure you see "Active: active (running)" in the output
6. From here, you should be able to depress the power button to release it, and the LED should stay lit until the shutdown completes, then turn off. At this point, your RPi CPU is completely off. Now press the power button to latch it, and the RPi should come back up. A reset will simply send a `shutdown -r now` instead and reboot the system.

## Install screen_manager
1. Ensure you are logged in as `pi` and in the `/home/pi` directory.
2. (If you haven't already) `git clone https://github.com/coderkevin/mini-nes.git`
3. `cd mini-nes/screen`
4. `sudo make install`
5. Restart your Pi (try the reset button!) and if you've done all the steps above, everything should be working!
2. At the bottom of the file, there's a `[Cartridges]` section.<br>
![alt text](http://www.piwizardgaming.com/nfc/configure-cart.png) <br>
3. For each cartridge you want, add a line in this format:<br>
`<uid> = <game file>` (e.g. `00000000000000 = nes/Super Mario Bros. (JU) [!].zip`)<br>
4. If you used the Zelda demo from above simply change the UID in the config file to match yours

## Step 10 - Setup Autostart
1. `sudo nano /etc/rc.local`
2. Scroll down to `exit 0` and press enter twice then copy above the `exit 0` Line
```
sudo systemctl start nfc_poll
sudo systemctl start nes_buttons
```
It should look something like this:<br>
![alt text](http://www.piwizardgaming.com/nfc/rclocal.png)

## Step 11 - Install screen_manager
1. Type `cd /home/pi/mini-nes/screen`
2. Type `sudo make install`

## Step 12 - Install nes_buttons
1. Type `cd /home/pi/mini-nes/buttons`
2. Type `sudo make install`<br>
![alt text](http://www.piwizardgaming.com/nfc/button-install.png)
3. If you have everything wired correctly, your LED should turn on after installing.

## Step 13 - Finish Up ##
1. Type `sudo shutdown -r now`
2. Once RetroPie Reboots - Try placing a cartridge on the reader

Binary file removed Mini NES Wiring.png
Binary file not shown.
18 changes: 18 additions & 0 deletions Parts-List.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# NFC Reader Parts List

1. Raspberry Pi 3 B+ (B Plus) with Premium Clear Case and 2.5A Power Supply - Amazon $79.99 - <br>https://www.amazon.com/CanaKit-Raspberry-Premium-Clear-Supply/dp/B07BC7BMHY/<br>
![alt text](http://piwizardgaming.com/nfc/pi3b-plus.png)<br><br>
2. Optional Upgraded Power Supply 5V 3A - Amazon $9.89 - <br>https://www.amazon.com/gp/product/B01N336XEU/<br>
![alt text](http://piwizardgaming.com/nfc/upgraded-power.png)<br><br>
3. NFC Reader - Amazon $8.69 - <br>https://www.amazon.com/gp/product/B01I1J17LC/<br>
![alt text](http://piwizardgaming.com/nfc/nfc-reader-small.png)<br><br>
4. NFC Tags - Amazon $6.66(12qty) $10.99(30qty) - <br>https://www.amazon.com/gp/product/B08NPYD99G/<br>
![alt text](http://piwizardgaming.com/nfc/nfc-tag.png)<br>
5. Push Buttons for Power & Reset - Amazon $6.88 -<br>
You can remove the small metal pin inside the button to become both the Power & Reset Buttons <br>https://www.amazon.com/QMseller-Through-Self-Locking-Mounting-Switches/dp/B07W887PZV/<br>
![alt text](http://piwizardgaming.com/nfc/buttons-small.png)<br><br>
6. Latching Button for the Cartridge - Amazon $12.99 - <br>https://www.amazon.com/gp/product/B0169B5468/<br>
![alt text](http://piwizardgaming.com/nfc/latch.png)<br>
7. Wire Kit with resistors & LED's - Amazon $13.39 - <br>https://www.amazon.com/gp/product/B01HRR7EBG/</br>
![alt text](http://piwizardgaming.com/nfc/kit.png)<br>
### Work In Progress
Binary file added Wire-Diagram-Updated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion buttons/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ INIT_DIR := /etc/init.d
.PHONY: install

install:
-pip install python-daemon
install -m 0755 *.py -D -t $(VAR_WORK_DIR)
install -m 0755 init/nes_buttons -D -t $(INIT_DIR)
-systemctl enable nes_buttons
Expand Down
1 change: 0 additions & 1 deletion nfc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ test: $(TEST)
LD_LIBRARY_PATH=. ./$(TEST) -v

install: lib
-pip install python-daemon
-pip install psutil
install -m 0755 *.so* -D -t $(INSTALL_PREFIX)/lib
install -m 0755 *.py -D -t $(VAR_WORK_DIR)
Expand Down
6 changes: 2 additions & 4 deletions nfc/etc/nfc_poll.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ ui_period = 1
[Cartridges]

# <nfc uid> = <path relative to roms_home>

04fc3bea794d80 = nes/Super Mario Bros. (JU) [!].zip
044d3cea794d81 = nes/Super Mario Bros 2 (U) (PRG 1).zip
042143ea794d81 = nes/Super Mario Bros 3 (U) (PRG 1).zip
d6422030 = nes/zelda.zip
#04fc3bea794d80 = nes/Super Mario Bros. (JU) [!].zip

1 change: 0 additions & 1 deletion screen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ VAR_WORK_DIR := /var/lib/screen_manager
.PHONY: install

install:
-pip install watchdog
install -m 0755 *.py -D -t $(VAR_WORK_DIR)
-sh ./update_autostart.sh