{"id":23127694,"url":"https://github.com/hlfshell/golang-nfc-test","last_synced_at":"2025-09-20T07:23:41.567Z","repository":{"id":146170433,"uuid":"320952286","full_name":"hlfshell/golang-nfc-test","owner":"hlfshell","description":"A with instructions to setup and run the PN532 NFC Chip on Raspberry Pi w/ Golang.","archived":false,"fork":false,"pushed_at":"2020-12-13T23:12:45.000Z","size":2512,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T17:14:52.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hlfshell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-13T00:24:01.000Z","updated_at":"2025-01-01T20:30:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"8f7f931a-f737-461d-a5e4-dce42088d60e","html_url":"https://github.com/hlfshell/golang-nfc-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fgolang-nfc-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fgolang-nfc-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fgolang-nfc-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fgolang-nfc-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hlfshell","download_url":"https://codeload.github.com/hlfshell/golang-nfc-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128739,"owners_count":20888234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T09:14:30.260Z","updated_at":"2025-09-20T07:23:36.525Z","avatar_url":"https://github.com/hlfshell.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build](doc/build.jpg)\n\n# golang NFC Tests\n\nThese were tests to get the `PN532` chip found on a lot of low cost NFC readers out there working with the Raspberry Pi - and then getting it to work with GoLang. There are two tests within. These mini-projects are to see overall feasability for a future project - an NFC controller music and podcast player.\n\n* `simple-nfc-test` - just a test NFC app that will detect an NFC card read its UID off of it.\n* `music-player` - specify an mp3 location at startup. When the NFC card is present, it will play the music. It will pause as soon as the NFC card is removed.\n\nThe rest of this documentation has links and a general explanation for how I got various libraries installed and working.\n\n# Installation\n\n## Enable serial port on Raspberry Pi \n\n```\nsudo raspi-config\n```\n\nThen go to `Interface Options` -\u003e `Serial Port`\nDisable login shell and enable serial port hardware.\n\n## Install nfclib-1.8.0\n\n```\nwget https://github.com/nfc-tools/libnfc/releases/download/libnfc-1.8.0/libnfc-1.8.0.tar.bz2\ntar -xvjf libnfc-1.8.0.tar.bz2\ncd libnfc-1.8.0.tar.bz2\nsudo mkdir /etc/nfc\nsudo mkdir /etc/nfc/devices.d\nsudo vim /etc/nfc/devices.d/pn532_uart_on_rpi.conf\n```\n\nFor the `pn532_uart_on_rpi.conf` set the following:\n\n```\nname = \"PN532 board via UART\"\nconnstring = pn532_uart:/dev/ttyS0\nallow_intrusive_scan = true\n```\n\n**Important Note**: The serial port `/dev/ttyS0` would be `/dev/ttyAMA0` on Raspberry Pi's older than the 3 or with Zero's - on the 3+ `/dev/ttyAMA0` is used by the Bluetooth hardware, meaning a lot of documentation and default examples will fail as its pointing to a different serial port. \n\nThe rest follows the Adafruit installation guide [here](https://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/building-libnfc):\n\n```\nsudo apt-get install autoconf\nsudo apt-get install libtool\nsudo apt-get install libpcsclite-dev libusb-dev\nautoreconf -vis\n./configure --with-drivers=pn532_uart --sysconfdir=/etc --prefix=/usr\nsudo make clean\nsudo make install all\n```\n\nYou can test if it's working (and if your hardware is connected) via `nfc-list` or `nfc-poll`. `nfc-list --version` will tell you what version of nfc-lib you are currently using. Ensure that it's `1.8.0`.\n\n## Connecting the hardware\nThe `PN532` board I had needed 5V for its power so I used a level shifter in order to facilitate communication between the Pi and the NFC Chip. See the quick ugly diagram below for wiring:\n\n![Wiring](doc/wiring.jpg)\n\n## Go Example\nI utilized [clausecker's nfc module](https://github.com/clausecker/nfc) for go. The example code for a quick nfc scan is in `main.go`\n\n## Specifying Connection String\nI eventually started including the connection string, `pn532_uart:/dev/ttyS0`, when opening a connection instead of relying on `libnfc`'s auto scan feature. Somehow after a reboot autoscan stopped working, despite specifying the reader's location working flawlesly.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlfshell%2Fgolang-nfc-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhlfshell%2Fgolang-nfc-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlfshell%2Fgolang-nfc-test/lists"}