Getting started with Adafruit NFC Shield


#1

Hi any NFC parties.
I’m starting on a project using a Photon and the Adafruit PN532 RFID/NFC Shield.

The very first thing I’ve tried is to simply include the Library using in the IDE using the command “#include <Adafruit_NFCShield_I2C.h>” and then simply verifying the code in the IDE.
A whole slew of errors are then generated as below

lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:248:62: conflicting declaration 'typedef int int32_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:65:19: 'int32_t' has a previous declaration as 'typedef __int32_t int32_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:249:65: conflicting declaration 'typedef unsigned int uint32_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:66:20: 'uint32_t' has a previous declaration as 'typedef __uint32_t uint32_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:265:17: conflicting declaration 'typedef int16_t intptr_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:190:20: 'intptr_t' has a previous declaration as 'typedef __intptr_t intptr_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:270:18: conflicting declaration 'typedef uint16_t uintptr_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:191:21: 'uintptr_t' has a previous declaration as 'typedef __uintptr_t uintptr_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:336:16: conflicting declaration 'typedef int8_t int_fast8_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:95:30: 'int_fast8_t' has a previous declaration as 'typedef int int_fast8_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:341:17: conflicting declaration 'typedef uint8_t uint_fast8_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:96:31: 'uint_fast8_t' has a previous declaration as 'typedef unsigned int uint_fast8_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:346:17: conflicting declaration 'typedef int16_t int_fast16_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:105:31: 'int_fast16_t' has a previous declaration as 'typedef int int_fast16_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:351:18: conflicting declaration 'typedef uint16_t uint_fast16_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:106:32: 'uint_fast16_t' has a previous declaration as 'typedef unsigned int uint_fast16_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:356:17: conflicting declaration 'typedef int32_t int_fast32_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:115:31: 'int_fast32_t' has a previous declaration as 'typedef int int_fast32_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:361:18: conflicting declaration 'typedef uint32_t uint_fast32_t'
error
/usr/local/gcc-arm-embedded/arm-none-eabi/include/stdint.h:116:32: 'uint_fast32_t' has a previous declaration as 'typedef unsigned int uint_fast32_t'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:3743:7: redefinition of 'class Printable'
error
../wiring/inc/spark_wiring_printable.h:40:7: previous definition of 'class Printable'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:3757:7: redefinition of 'class Print'
error
../wiring/inc/spark_wiring_print.h:44:7: previous definition of 'class Print'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:3820:7: redefinition of 'class Stream'
error
../wiring/inc/spark_wiring_stream.h:44:7: previous definition of 'class Stream'
error
lib/Adafruit_NFCShield_I2C/Adafruit_NFCShield_I2C.h:3900:7: redefinition of 'class TwoWire'
error
../wiring/inc/spark_wiring_i2c.h:35:7: previous definition of 'class TwoWire'
error
../wiring/inc/spark_wiring_i2c.h:88:34: new declaration 'TwoWire __fetch_global_Wire()'
error
../wiring/inc/spark_wiring_i2c.h:89:10: ambiguates old declaration 'TwoWire& __fetch_global_Wire()'

Which is before I even write any code of my own!

Has anyone had experience of this issue or with the Adafruit shield in general?

Many thanks

Chris


#3

maybe because you are using the old adafruit nfc library., it’s been deprecated. use the one peekay123 mentioned found at


#4

@dkryder, I erased my post because I realize the PN532 library uses SPI only, not I2C. Perhaps a newer library that supports both is available for porting.


#5

@peekay123 the github description mentions SPI & I2C as well as the notes on the older library which point to the new one so if it is only SPI that’s confusing. but, i have never used it so i’m not exactly positive. unless, I2C is not supported with the Photon. but those errors should still disappear seems to me.


#6

@dkryder, you are correct! Worse, I PORTED THAT LIBRARY! HAHAHA! I should know better.

@chris-particle, use the Adafruit_PN532 library as it supports both SPI and I2C modes AND it compiles.


#7

@peekay123, however i just noticed that the notes on github page state STM32F2 has not been tested if that matters.


#8

@dkryder, the STM32F205 powers the Photon and Electron. However, I don’t believe there is anything in the code that prevents running on mesh devices as well (it compiles without errors).


#9

Wow guys, many thanks for the pointers there. using the Adafruit_PN532 library compiled first time.

I can get on with writing some code now!

I’ll update on progress as I’m looking at eventually plugging this into the Electron to provide cellular connection. Just get reading the NFC devices first.

Many thanks again

Chris