NFC stops working after a few minutes?

Posted on
  • I just received my pucks yesterday (love the build quality and feel btw,) and am having some problems with the NFC. Here are my current running details;

     {
      "VERSION": "1v90",
      "BUILD_DATE": "Dec 16 2016",
      "BUILD_TIME": "14:49:15",
      "GIT_COMMIT": "5135ed57fe5f3a23e335896be41f283878087d15",
      "BOARD": "PUCKJS",
      "CHIP": "NRF52832",
      "CHIP_FAMILY": "NRF52",
      "FLASH": 524288, "RAM": 65536,
      "CONSOLE": "Bluetooth"
     }
    

    It's looking like NFC works directly after a hard reset (i.e. taking the battery out, holding down the button, reinserting the battery and holding for 3 seconds.) After a few minutes, however, it stops working. Even resetting/reuploading the code via the IDE does not work.

    Any ideas?

  • The idea is that out of the box, NFC points to puck-js.com to get you started - however if you reset Puck.js with reset() that removes the in-built NFC URL.

    To add your own, just do NRC.nfcURL("http://my.url.com") : http://www.espruino.com/Reference#l_NRF_nfcURL

    Or are you saying that even after a reset you can't get an NFC URL that you defined to work?

  • Basically a combination of the two, I use the following code:

    var isLightOn = false;
    
    NRF.nfcURL("https://www.google.com");
    NRF.on('NFCon', function() { LED1.write(true);});
    NRF.on('NFCoff', function() { LED1.write(false);});
    
    setWatch(function() {
      isLightOn = !isLightOn;
      
      LED2.write(isLightOn);
    }, BTN, { 
      repeat:true, 
      edge:"rising", 
      debounce:50 
    });
    

    And when I first hard reset the device it works on my Nexus 6P. If I wait, say, 15 minutes and try again, it no longer works (although the button press does.)

  • Are you absolutely sure about that? Please could someone else confirm?

    There's nothing inside Puck.js's software that should have that effect - and I've had NFC stay working after days of activity.

  • I have two pucks so I can confirm on a second one when I get home. I've tried on both an Android 6P and an LG g4 and both have the same behavior.

    I'll start running some tests right now to see if I can figure out when exactly the NFC starts giving out. I'll also check my second puck when I get home.

  • Figured out the bug -- or maybe it's as planned and I just missed that part in the docs, but the issue happens when you are disconnected from the web ide. Here are my steps to reproduce:

    1. Upload code above to puck via Web IDE
    2. Try NFC (it should work)
    3. Click the top left button in the Web IDE, disconnecting the puck
    4. Try NFC (it should not work)
    5. Reconnect to the Web IDE
    6. Try NFC (it should now work again)

    Not sure if this is intended or what, but seems odd to me.

  • I tried on my new Puck running 1v88 and the NFC works ok even after disconnecting the Puck from the Web IDE. Copy-pasted the code above and tested on an LG G4 phone.

  • @trezm are you sure it's not just that the phone refuses to acknowledge NFC if you already have that web page open on it?

    Seems strange that we can't reproduce it here.

  • Circling back around on this, after playing with the pucks a few more days it seems like all the problems are resolved. I have no idea what was going on, but I'll update if I figure it out. Thanks for the help guys!

  • I am also having some issues with NFC. I got 2 pucks. On one the NFC URL works just fine. The other stopped working after a few hours of fooling around with it. For example, if write something like:

    NRF.nfcURL('https://www.google.com');
    

    and upload to both pucks, it works fine on one and not on the other. That said, I can not get the following code to work on either of my pucks:

    NRF.on('NFCon', function() {
      digitalPulse(LED1, 1, 250);
    });
    

    I was hoping to use NFC to be able to tap one puck on the other and pass some information. I have tried resetting the troublesome puck, but haven't had any luck. All other functions tested on the pucks have worked fine so far (bluetooth, mag, temp, etc.)

  • Have you tried with an up to date firmware? I just did:

    NRF.nfcURL('https://www.google.com');
    NRF.on('NFCon', function() {
      digitalPulse(LED1, 1, 250);
    });
    

    And the red LED flashes as expected.

    Could you try forcing NFC off on the troublesome one with just a NRF.nfcURL(); without arguments, then turning it back on? Or totally disconnecting the battery then reconnecting with the button held down for ~4 seconds might help.

  • I also just looked into NFC and I had similar observations as @trezm. I configured a NFC url, which worked fine the first time, but then even after closing my android devices browser or using a totally different device, it did not work any more. What works is taking out the battery and configuring the url again.

    I assume the NRF.nfcURL() is not one-shot, eg. it does not clear itself after it has been used. I have the latest firmware 1.91 btw.

    thx
    Sven

  • OK, it's really a bit weird. Things first started working again, but then again did not. I've now written some small interval that changes the URL every 5 seconds, I was able to get the first url transferred to my mobile via NFC, but then nothing else worked. But I still see the log outputs in the espruine web console.

    var url = "https://api.yaas.io/bullseye/"; 
    var counter = 0; 
    setInterval(function() { NRF.nfcURL(url + counter++);   console.log(url + counter); }, 5000);
    
  • What about:

    NRF.on('NFCon', function() {
      digitalPulse(LED1, 1, 250);
    });
    

    This would show if the other device was starting to communicate via NFC. If it is, I would imagine that most likely it's something on the reader that's causing issues.

    Also: changing the NFC URL will reset the NFC - so if you do it every 5 seconds then you may well reset the NFC while the other device is trying to read it.

    You could respond to NFCon/NFCoff events and make sure you don't change the URL while NFC is on

  • thx, I will try this once I have some time. makes total sense.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

NFC stops working after a few minutes?

Posted by Avatar for trezm @trezm

Actions