Puck.js for asset tracking

Posted on
  • I'm looking for hardware for a little project and trying to find out if puck.js is a right fit. What I want to do s track if something(generic BLE tag) is not leaving the room. I was thinking about placing 2-3 puck.js in the room. A generic BLE tag would just need to advertise with set interval his ID. Every puck.js will need to listen to ID and forward/advertise its own id, the id of generic BLE tag and the signal strength of generic BLE tag. Now I will need some gateway that will get this info and based on it analyze if generic BLE tag is in the room or not.
    Do you think puck.js can do this?


  • Most likely yes. Of course depends on how accurate and secure this must be: you can cover it with something, so it disappears. Clone BLE tag. Or might still have enough signal strength just on the other side of the door.

    For the gateway, take a look at EspruinoHub

  • Hi, thanks for your comment. Sure, if I cover it with something it will disappear. To work around something blocking the signal I was hoping that 2-3 pucks should pick it up unless I put an iron pot on it or something. To check if it is inside our outside the room I was thinking to analyze signal strength collected from all of the pucks with the hope that I can determine its outside... What do u mean by "Clone BLE tag" ?

  • Hello! For me, if it was a specific room and I was not trying to track movement internally, I'd use a single puck outside the room - sort of like an alarm - especially if there's a defined route in/out.

  • Hi, thanks for your comment, unfortunately, there is no defined route and I can't put it outside.
    I was hoping to play with signal strength. The main question is can pucks "listen" to advertisements and advertise: own ID, BLE tag ID, signal strength of BLE tag.

    Or maybe there is another better way. I'm new here so any help welcome

  • Re: Clone: If someone knows that you are doing this, and maybe finds this forum :) can figure out how you are doing.
    For example someone can go there, listen to BLE advertisements, and set up the same BLE advertisement with a separate device, and remove your BLE tag (or the item it's attached to).
    Depends on how secure this must be. For example, LOGITacker uses nRF52840 dongles (kind of "bigger brother" of the nRF52832 in the Puck, but still just an easily available 10-15$ device) to attack Logitech wireless devices. And even take over a computer with taking over a keyboard / mouse.

    Of course I don't know your circumstances. If you don't expect such "high-tech" attack, just listening to BLE advertisement & checking signal strength is probably good enough.

  • The main question is can pucks "listen" to advertisements and advertise: own ID, BLE tag ID, signal strength of BLE tag.

    Yes, absolutely! You can use NRF.requestDevice to scan for a device matching certain criteria (eg. advertising type) and get its RSSI, then you can use NRF.setAdvertising to update your Puck's advertising to contain the relevant data.

    Links to the two functions with examples:

    I'd be happy to post up some full example code for you if needed.

  • Hi, thanks, I see. Right now I don't care about "high-tech" attacks :)

  • Hi Gordon,
    thanks for your comment. A code example would be great if you can find time for that. :)
    What can you recommend for getaway hardware? These look good
    but are not available until at least November or something (not sure product links are allowed here, please remove if not)

    And the last question where do I buy puck.js ? I'm in Germany and the only german shop listed here http://www.espruino.com/Order#puckjs does not have it anymore.

  • The code would look something like this. Just tested and it works fine - you'd just want to choose how you filter out the beacon you're interested in (name, manufacturer data, etc):

    function updateAdvertising(device) {
      var data = new Uint8Array(7);
      // our data - all 0 for nothing, 
      // or RSSI + 6 bytes address
      if (device) {
        data[0] = device.rssi;
        var addrAsBytes = device.id.substr(0,17).split(":").map(x=­>parseInt(x,16));
        data.set(addrAsBytes, 1);
        manufacturer: 0x0590,
        manufacturerData: data
    function scanForDevice() {
        filters: [{ name: 'Puck.js 5a47' }], 
        timeout: 2000}).then(function(device) {
        updateAdvertising(device); // found
      }).catch(function(err) {
        updateAdvertising(undefined); // not found
    setInterval(scanForDevice, 60*1000); // scan once a minute

    In terms of gateways, I'd suggest just using something like a Raspberry Pi 3 as a start, and then you're totally flexible (you could move to any Linux-based gateway later on if you wanted). What did you want to bridge it to? WiFi, Ethernet, GSM?

    I believe Rigado do some good professional Gateway hardware if you wanted something that 'just worked' though: https://www.rigado.com/cascade-gateway/

    It's also possible to use a Pixl.js (http://www.espruino.com/Pixl.js) with a shield for ethernet/wifi/gsm if you want to stick with Espruino for everything.

    To buy Pucks I'd just order them direct from me at https://shop.espruino.com/puckjs - you should usually get them in Germany in 3-5 days.

  • Hi Gordon,
    thanks a lot for the code sample, I ordered the pucks and am eager to try it out.

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

Puck.js for asset tracking

Posted by Avatar for alexk @alexk