PN7160 MINI V1 -- I2C
Software development guide
Use the official ELECHOUSE PN7160 software library for Arduino and ESP32. Configure the MINI's pins and supply, then build on the standard tag-reading examples.
1. Software resources
The MINI uses the same ELECHOUSE Arduino library linked from the standard PN7160 product. No separate MINI-specific library is required. Use the wiring in this documentation for the MINI board.
| Platform | Software path | Integration note |
|---|---|---|
| ESP32 / ESP32-S3 / ESP32-C3 | ELECHOUSE Arduino library and Arduino-ESP32 | Set the GPIOs explicitly; this guide uses an ESP32-S3 with SDA8, SCL9, IRQ4 and VEN5. |
| Other Arduino-compatible hosts | ELECHOUSE Arduino library | Verify RAM capacity, I2C support and GPIO behavior on the selected board. Use 3.3 V logic or suitable level translation. |
| Raspberry Pi / Linux | NXP linux_libnfc-nci | Separate middleware installation and board-specific configuration are required; Arduino macros do not configure the Linux stack. |
For Linux middleware installation background, use the ELECHOUSE PN7160 I2C Linux guide. Its physical wiring describes a different module; use this MINI's six-pin pinout instead and confirm a power configuration appropriate to your middleware and module supply before enabling RF.
2. Install and select an example
- Install the board package for your host in Arduino IDE.
- Download the ELECHOUSE library 3.1.3 ZIP and install it with Sketch → Include Library → Add .ZIP Library.
- Open DetectTags for the first NFC-A check.
- Apply the MINI pin, power and clock settings, then select the board and upload.
The download above is fixed to source revision a9c0f71, library version 3.1.3. Check the installed version in library.properties and review changes in the main repository before updating a production application.
3. Configure the pins and power
3.1 Standard library examples
Define the following before the library's shared example-transport header. These are ESP32-S3 GPIO numbers, not module connector pin numbers.
#define PN71XX_USE_SPI 0
#define PN71XX_I2C_SDA 8
#define PN71XX_I2C_SCL 9
#define PN71XX_I2C_IRQ 4
#define PN71XX_I2C_VEN 5
#define PN71XX_I2C_ADDR 0x28
#define PN71XX_I2C_CHIP_MODEL PN7160
#define PN71XX_FIXED_VBAT_3V3 1 // Module VCC = 3.3 V
#include <Electroniccats_PN7150.h>
#include <Electroniccats_PN71xx_ExampleTransport.h>
Keep the example's pn71xxConfigureExampleTransport(nfc) call. It applies these choices before initialization. Leave ADR0 and ADR1 open for address 0x28; change the address macro if you solder the address pads for another address.
3.2 Power presets
| Module VCC | Shared example macro | Direct API |
|---|---|---|
| 3.3 V | PN71XX_FIXED_VBAT_3V3 1 | nfc.setPn7160FixedVbat3V3(true) |
| 5.0 V | PN71XX_FIXED_VBAT_3V3 0 | nfc.setPn7160FixedVbat3V3(false) |
configureSettings(). When using begin(), select the preset before calling begin(), because that method applies the settings internally. Power down before changing the supply or configuration.The specified input range is 3.3–5.5 V at VCC, including tolerance and ripple. The examples above cover nominal 3.3 V and 5.0 V designs. This is independent of the 3.3 V signal interface: do not connect 5 V to SDA, SCL, IRQ or VEN.
3.3 Custom applications
Electroniccats_PN7150 nfc(4, 5, 0x28, PN7160);
// IRQ, VEN, address, device
nfc.setI2CPins(8, 9); // SDA, SCL
The library retains the header and class name Electroniccats_PN7150. Explicitly pass PN7160 in the constructor; the shorter three-argument constructor selects a different controller path.
4. Initialization and I2C clock
Use 400 kHz for normal operation. A 100 kHz bus is also supported. The library initializes Wire inside connectNCI(); set the operating clock after the connection succeeds.
nfc.setI2CPins(8, 9);
nfc.setPn7160FixedVbat3V3(true); // VCC = 3.3 V; false for 5.0 V
if (nfc.connectNCI()) {
// Stop here and report the connection error.
return;
}
Wire.setClock(400000UL);
if (nfc.configureSettings()) return;
if (nfc.configMode()) return;
if (nfc.startDiscovery()) return;
// Initialization is now complete.
This is an initialization fragment; include Wire.h and the library header, define the controller instance, and prevent the application loop from accessing NFC after an initialization failure. The API summary includes a complete basic sketch.
When using the existing DetectTags helper, add Wire.setClock(400000UL) after its initialization error-check block. If recovery code closes and restarts Wire, set the clock again after the new connection.
5. Choose the example for your task
| Repository example | Purpose | Application consideration |
|---|---|---|
| DetectTags | Discover tags and report identifiers. | Start with NFC-A; see identifier length handling for NFC-V. |
| NDEFReadMessage | Read an NDEF message. | Use a supported tag containing valid NDEF data. |
| NDEFSendMessage | Write an NDEF message. | Use a writable test tag; writing replaces existing content. |
| MifareClassic_read_block | Read a MIFARE Classic block. | Valid sector authentication keys are required. |
| ISO15693_read_block | Read ISO15693 memory blocks. | Check the card's block layout and supported commands. |
Other examples are listed in the repository examples directory. Apply the same MINI transport and supply settings to each example. Example availability does not replace testing with the intended card and application.
6. Application handling and recovery
- Use a finite
isTagDetected(timeoutMs)timeout if your application must service other tasks. - Read
remoteDeviceonly after successful detection, and use the identifier accessor for the detected technology. waitForTagRemoval()blocks while checking tag presence. Plan for this behavior in applications with timing or user-interface requirements.- Check
reset(): it returnstruewhen discovery restarts successfully, unlike the initialization methods that use zero for success. - If recovery fails, stop tag operations, verify power and wiring, then reset the controller through VEN and repeat initialization with bounded retries.
- Use the no-argument
configureSettings()call; see the library 3.1.3 compatibility note.
Before deploying an application, check cold startup, repeated card presentation and removal, and recovery using the final supply, antenna, cable routing and enclosure. For support, record the library version, host board, GPIO mapping, VCC, preset and the first reported error.