RoadTest: Integrating NFC with the NXP PN7150
Author: cjsieh
Creation date:
Evaluation Type: Development Boards & Tools
Did you receive all parts the manufacturer stated would be included in the package?: True
What other parts do you consider comparable to this product?:
What were the biggest problems encountered?: The version of the FRDM-K41Z board provided uses the IRQ and VEN Arduino pinout also for the SWD Debug interface. This makes the pn7150 Arduino board incompatible with the FRDM-K41Z unless jumper wires are used instead of mounting in on top. Software changes were then needed to indicate what CPU pin the IRQ and VEN pins moved to.
Detailed Review:
In my proposal for this review I suggested replacing the RFID RC522 Reader with the PN7150 from a previously built RFID scanner. This RFID scanner reads MiFare Tags and publishes the UID data from the tag to a MQTT Broker via a WiFi connected ESP32. A Google AIY Voice Kit(Raspberry Pi based) subscribed to the MQTT UID data and would "SAY" the UID data.
I also proposed that I research the use of the PN7150 with a Raspberry Pi.
I was able to replace the 522 RFID reader with the PN7150. This required the software provided in SW4325 as described in PN7150 Application Note 11990 MCUXpresso Examples be ported to the ESP32. The basis was the bare metal version intended for the OM13058 LPC11U68 as described in Section 2.3 . In Section 6.1 and 6.2 it describes how I2C and GPIO is used . I provided equivalent Arduino IDE ESP32 functions to all of the calls to I2C and GPIO code as used in the TML as described in section 5.3 . I provided replacement headers files for the hardware definitions of the IRQ and VEN GPIO locations . The following functions were replaced with code for ESP32. All of these were calls to the Hardware of the LPC11U68 originally.
Thus I did not have to change any of the NXP code.
Since I was learning about NFC I wanted to know more about NTAG's . My research showed that it was very easy to add "data" to a NTAG as NDEF records using the NXP TagWriter Android App. The NFC Data Exchange Format (NDEF) is a standardized data format that can be used to exchange information between any compatible NFC device and another NFC device or tag . I decided to add NDEF Text records to my NTAG's and send this to the MQTT Broker. Google AIY Voice Kit would then "SAY" the NDEF Text that it received via MQTT.
MQTT is a publish-subscribe messaging protocol. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited. It is very popular in the IOT community.
To implement MQTT with the PN7150 I had to add a call to my "MQTT code" after the NXP code had determined that the NDEF record was of type Text. All other NDEF records were just printed to the serial port as the original NXP code did.
The following video shows a PN7150 reading NTAG216, NTAG215 and NXP LPC8N04 M0/NTAG chip and sending the NDEF Text record to a MQTT Broker via a ESP32. A Google AIY Voice Kit then uses text to voice technology to "SAY" the Text.
I am very impressed with the LPC8N04 , it is a M0 Microprocessor and a NTAG on the same chip. I obtained it at a "NXP Technology Days" exhibit from Future Electronics. Since it is just a NTAG the PN7150 can read the data on it just fine.
One thing that the PN7150 did that was better than the 522 was that the distance that was needed for a good scan was farther away than the 522. The 522 you had to touch the tag to the 522. With the PN7150 i could be much farther away.
I got the PN7150 to work with the ESP32 and a Raspberry Pi Zero W and send NDEF Text data to a MQTT Broker where a Google AIY Voice Kit would "SAY" the NDEF Text.
I sure learned a lot about NTAG's and NDEF Text records and how easy they are to to write. The Linux Demo App can also write NTAG's NDEF Records.
I did not know that there are Dynamic NTAG's where a Micro can change the contents of the NTAG on the fly. I see this as a very powerful technology.
I started this research with getting the work with the software described in OM5578 Application Note 11841 . To do this I needed one of the supported development boards. Choices from Section 3 show OM13071, OM13074 or OM13058 or FRDM-K64F. I already had a FRDM-K64F so used that first.
Pin Name | OM5578 Pin from Schematic | OM5578 Arduino Pin from Schematic | KW41Z REV A3 From pinout diagram Software port/pin and Physical pin | KW41Z Jumper Wire Version | Notes | Source Code Change |
---|---|---|---|---|---|---|
5V | TB2 Pin 2 | J1 Pin 5 | 5V | 5V | No change | |
3.3V | TB2 Pin 1 | J1 Pin 4 | 3.3V | 3.3V | No change | |
GND | TB2B Pin 2 | J1 Pin 6 | GND | GND | No change | |
I2C SCL | TB3 Pin 1 | J2 Pin 1/D15 | PTC2/D15 | PTC2/D15 | No change | |
I2C SDA | TB3 Pin 2 | J2 Pin 2/D14 | PTC3/D14 | PTC3/D14 | No change | |
IRQ/GPIO_0 | TB2B Pin 3 | J2 Pin 10/D8 | D8 | PTC18/D6
New software pin will be PortC.18 | Moving to PortC.18
| Comment out Line 14 in Nfc/TML/src/tml.c From: #define RIGADO To: //#define RIGADO |
VEN/GPIO_1 | TB2B Pin 4 | J4 Pin 1/D7 | D7 | PTC17/D5
New software pin will be PortC.17 | Moving to PortC.17
Which is on D5 | See above |
Pin Name | OM5578 Pin | OM5578 Arduino Pin | Raspberry Pi Pin Center 2 rows of Raspberry Pi Pinout Diagram | GPIO Pin |
---|---|---|---|---|
5V | TB2 Pin 2 | J1 Pin 5 | 2 | |
3.3V | TB2 Pin 1 | J1 Pin 4 | 1 | |
GND | TB2B Pin 2 | J1 Pin 6 | Any "Ground" , I used 6 | |
I2C SCL | TB3 Pin 1 | J2 Pin 1 | 5 | 2 |
I2C SDA | TB3 Pin 2 | J2 Pin 2 | 3 | 3 |
IRQ/GPIO_0 | TB2B Pin 3 | J2 Pin 10 | 16 | 23 |
VEN/GPIO_1 | TB2B Pin 4 | J4 Pin 1 | 18 | 24 |
I used the PN71xx Linux Software Stack Integration Guidelines AN11697 on how to use the Raspberry Pi with the PN7150. There were 3 options for building the software
I used option "alt" for building the software. I picked the "easiest" choice as I did not want to rebuild a kernel and there was not much documentation on how to use LPCUSBSIO. I had to enable the I2C option in /boot/config using " sudo raspi-config" .
This software worked just fine.
I added MQTT support to the Demo App provided at https://github.com/NXPNFCLinux/linux_libnfc-nci/tree/master/demoapp
There is also a Raspberry Pi "image" which I did not try. I wanted to find out how hard it was to build the PN7150 library and Demo App. The documentation in AN11697 provide enough detail. You just have to read it very carefully as they clearly added changes later that might seem out of place.
Pin Name | OM5578 Arduino Pinout | ESP32 Lolin D32 Pinout | Notes |
---|---|---|---|
5v | J1 Pin 5 | USB | USB provides 5v |
3.3V | J1 Pin 4 | 3.3V | |
GND | J1 Pin 6 | GND | |
I2C SCL | J2 Pin 1 | 22 | |
I2C SDA | J2 Pin 2 | 21 | |
IRQ/GPIO_0 | J2 Pin 10 | 32 | |
VEN/GPIO_1 | J4 Pin 1 | 33 |
I ported the MCUXpresso PN7150 Example software for the LPC11U68 over to the ESP32 Arduino IDE. I added replacement functions for the I2C and GPIO routines used in the MCUXpresso PN7150 Example code. See above for more details. I added my MQTT code from my original 522 RFID Scanner.