Native NFC Support


#13

Thanks @kennethlimcp. I’ll try it out.


#14

The red bear NFC antenna isn’t available for purchase. I found SeeedStudio antenna that appears to be compatible. I ordered it from Amazon.


#16

I’m using Taoglas NFC antennas for our prototypes. I chose them as Particle use the same brand for the Boron 3G antennas.


#17

So if I’m understanding this correctly, the Particle Mesh series of boards have support for NFC-A transmission and reception, in an active mode, instead of just a normal 13.56 MHz tag? And software and antenna support is currently in the works? Additionally, where will the NFC antenna need to be connected to, because I only see a WiFi connector and Thread/BLE connector in the spec sheet.

Thank you for your help.


#18

The uFL connector for the NFC antenna is situated on the flip side of the board directly opposite the microUSB receptacle.


#19

I could successfully make the branch at commit 5105417 and send the example blink LED application to a Xenon, however, the make failed when I tried to send the example app in the NFC Wiring API Test. The cpp file generated from the Workbench:

#include "application.h"
#line 1 "/Users/aaronroller/dev/projects/particle/nfc-test/src/nfc-demo.ino"
void nfc_event_handler(nfc_event_type_t type, nfc_event_t *event, void* ctx);
void setup();
void loop();
#line 1 "/Users/aaronroller/dev/projects/particle/nfc-test/src/nfc-demo.ino"
void nfc_event_handler(nfc_event_type_t type, nfc_event_t *event, void* ctx) {
    switch (type) {
        case NFC_EVENT_FIELD_ON:  digitalWrite(D7, 1); break;
        case NFC_EVENT_FIELD_OFF: digitalWrite(D7, 0); break;
        case NFC_EVENT_READ:      digitalWrite(D7, 0); break;
        default: break;
    }
}

void setup() {
    pinMode(D7, OUTPUT);
    digitalWrite(D7, 0);

    System.on(button_click, [](system_event_t ev, int clicks)->void {
        NFC.getNdefMessage()[0] = std::make_shared<TextRecord>("Update record - 1!", "en");
        NFC.getNdefMessage()[1] = std::make_shared<TextRecord>("Update record - 2!", "en");
        NFC.getNdefMessage()[2] = std::make_shared<TextRecord>("Update record - 3!", "en");
        NFC.getNdefMessage().addTextRecord("New record!", "en");

        NFC.stop();
        NFC.start(nfc_event_handler);
    });

    NFC.getNdefMessage().addTextRecord("Hello Particle!", "en");
    NFC.getNdefMessage().addUriRecord("particle.io", UriRecord::NFC_URI_HTTPS_WWW);
    NFC.getNdefMessage().addLauchAppRecord("no.nordicsemi.android.nrftoolbox");

    NFC.start(nfc_event_handler);
}

void loop() {

}

make clean all PLATFORM=xenon APPDIR=../../nfc-test/src/ -s program-dfu

...
Downloading to address = 0x00030000, size = 616144
Download	[=========================] 100%       616144 bytes
Download done.
File downloaded successfully
Creating module_user_memory.ld ...
../../../build/target/wiring/platform-14-m//libwiring.a(spark_wiring_nfc.o): In function `particle::NfcTagType2::stop()':
/device-os/wiring/src/spark_wiring_nfc.cpp:206: undefined reference to `hal_nfc_type2_stop_emulation()'
../../../build/target/wiring/platform-14-m//libwiring.a(spark_wiring_nfc.o): In function `particle::NfcTagType2::start(void (*)(nfc_event_type_t, nfc_event_t*, void*))':
/device-os/wiring/src/spark_wiring_nfc.cpp:188: undefined reference to `hal_nfc_type2_init()'
/device-os/wiring/src/spark_wiring_nfc.cpp:197: undefined reference to `hal_nfc_type2_set_payload(void const*, unsigned int)'
/device-os/wiring/src/spark_wiring_nfc.cpp:198: undefined reference to `hal_nfc_type2_set_callback(void (*)(nfc_event_type_t, nfc_event_t*, void*))'
/device-os/wiring/src/spark_wiring_nfc.cpp:199: undefined reference to `hal_nfc_type2_start_emulation()'
collect2: error: ld returned 1 exit status
make[1]: *** [/nfc-test/src//target/.elf] Error 1
make: *** [/device-os/modules/xenon/user-part/makefile] Error 2

I’m on a Macbook 10.13.3 if that matters.

The Xenon I flashed.

My story is to have the Xenon scan a Passive tag that has a URI with the UID as a parameter already encoded. I plan to read the URI that has the UID as a parameter which is handy because per the README the UID won’t be available from the NFC API.

If I can get basic NFC capabilities working, I will be an enthusiastic real world tester with 30 Argons and Xenons ready to go. I can deploy the branch code since my app is also Beta.

Thanks! Aaron


#20

Particle is now offering NFC antennas on their store. I’ve ordered a couple to try in addition to the SeeedStudio anntenna that I already have.


#21

@schooltag Thanks for reporting the issue, it has been fixed in the latest commit, please try again, if you got any issue or suggestions, feel free to let me know.


#22

@eugene0501 Thanks for the fix which got me past my compile issues and I was able to deploy the NFC example app for testing. Unfortunately, I was not able to cause an NFC event using my Google Pixel 2 Android + NXP Tag Writer App.

I did add some debug statements to confirm my app was working. Notice the button press is working, but the NFC triggered event is never published.

The code I used with the feature/hal/nfc device os branch.

#include "application.h"
#line 1 "/Users/aaronroller/dev/projects/particle/nfc-test/src/nfc-demo.ino"

void nfc_event_handler(nfc_event_type_t type, nfc_event_t *event, void* ctx);
void setup();
void loop();
#line 2 "/Users/aaronroller/dev/projects/particle/nfc-test/src/nfc-demo.ino"

bool nfc_event_received = false;

void nfc_event_handler(nfc_event_type_t type, nfc_event_t *event, void* ctx) {
    switch (type) {
        case NFC_EVENT_FIELD_ON:  digitalWrite(D7, 1); break;
        case NFC_EVENT_FIELD_OFF: digitalWrite(D7, 0); break;
        case NFC_EVENT_READ:      digitalWrite(D7, 0); break;
        default: break;
    }
    nfc_event_received = true;
}
bool button_pressed = false;

void setup() {
    pinMode(BATT, INPUT);
    pinMode(D7, OUTPUT);
    digitalWrite(D7, 0);

    System.on(button_click, [](system_event_t ev, int clicks)->void {
        NFC.getNdefMessage()[0] = std::make_shared<TextRecord>("Update record - 1!", "en");
        NFC.getNdefMessage()[1] = std::make_shared<TextRecord>("Update record - 2!", "en");
        NFC.getNdefMessage()[2] = std::make_shared<TextRecord>("Update record - 3!", "en");
        NFC.getNdefMessage().addTextRecord("New record!", "en");

        NFC.stop();
        NFC.start(nfc_event_handler);
        button_pressed = true;
    });

    NFC.getNdefMessage().addTextRecord("Hello Particle!", "en");
    NFC.getNdefMessage().addUriRecord("particle.io", UriRecord::NFC_URI_HTTPS_WWW);
    NFC.getNdefMessage().addLauchAppRecord("no.nordicsemi.android.nrftoolbox");

    NFC.start(nfc_event_handler);
}

unsigned long time_voltage_last_sent = 0;

void loop() {
    if(millis() - time_voltage_last_sent > 60000) {
        float voltage = analogRead(BATT) * 0.0011224;
        
        Particle.publish("voltage", String::format("%.2f",voltage), PRIVATE);
        time_voltage_last_sent = millis();
    }

    if(button_pressed){
        button_pressed = false;
        Particle.publish("NFC", "button pressed...NFC records updated", PRIVATE);
    }

    if(nfc_event_received){
        nfc_event_received = false;
        Particle.publish("NFC", "NFC Event Received", PRIVATE);
    }
}

I’m using a seeedstudio.com NFC antenna hooked up to the only connector on the Xenon. I’ve already some Particle Antennas so I can try a different antenna.

Any other suggestions to try?

Thanks.


#23

@schooltag Please try to change to Particle Antenna, the connector is on the back of the Xenon board, I tested NFC by using NFC Reader application on Android.


#24

Yay! Same antenna, but I previously had it connected to the BT connector. Moving it to the back worked! I’m super excited to dig in.


#25

@eugene0501 Now that the code is working with an active NFC tag, is it possible to read a passive NFC tag?

I have several types of passive NFC tags like stickers, key fobs, transportation card, etc. One I know is an NXP ntag213, for example.

Such would require the Antenna to power the non-powered passive tag so the tag can emit the data back to the antenna, just as the Android phone does when reading these tags.

Testing the tags and looking at the Device OS NFC code I do not see an NFC_EVENT_WRITE event that would receive data from another tag, the opposite of the READ event that transferred data from the Xenon to the mobile phone.

The story I’m trying to implement is to have the Xenon read a passive NFC tag.

Thanks! Aaron


#26

I’m afraid we can’t, we only support emulating a NFC type2 tag, you can’t use it to read any tag. ¯(°_o)/¯


#27

Gotcha. I would suggest updating the feature specifications to explain the limitation you can’t use it to read any tag. Right now it just says NFC-A radio, but I would suggest Acts as a passive NFC tag that can transfer data to a mobile app or something like that. I realize that is a different department so the note is for others listening.

Still very useful to allow a device administrator to the read the state of sensors with a mobile phone, etc. It just isn’t possible to know if anyone has visited the device…like security guards or students walking to school in my case.

I will be pursuing integrating an active NFC tag reader into the mesh products that can read a passive NFC Type 2 tag. Something like Solo Mifare for RFID. Any suggestions would be appreciated.

It’s worth noting I have clarified my use case with Particle engineers multiple times since last summer which led me here to continue the investigation since nobody could give an exact answer. Thanks @eugene0501 for flushing out the reality so I can focus on a solution that will work.

Thanks,

Aaron


Successfully Scanned NFC Tag with Argon and MFRC522
#28

Thanks for the clarification @eugene0501

I was wondering if reading or writing tags is a limitation of the nRF52840 chip or whether the lack of support is more of a software choice?

Thanks!


#30

It’s a software choice, the NFC driver of SDK15.0 which is used in device OS is a beta version, it has changed a lot in the new SDK 15.3. We Implemented basic NFC function (Passive Tag, read-only mode) for the first phase.


#31

Please could you give me an update on the status of NFC support for Argon – any idea when this will be released as part of the standard Particle software (which I guess is “Wiring” as mentioned above) ?


#32

@Pertspider, both BLE and NFC are being Alpha tested as we speak. I suspect a release candidate will be released very soon.


#33

OK that’s great news, thanks for the update !


#34

Awesome news !