NRF24L01 fails on sendCommand

Posted on
  • Hey Espruinos!

    I tried to follow this example: https://github.com/espruino/EspruinoDocs/blob/master/devices/NRF24L01P.md

    As I have already the display connected to the middle pins, I like to use the side Pins A0, A1 and B3 to B5 to connect the NRF24L01. So here is my setup:

    SPI3.setup({sck:B3, miso:B4, mosi:B5}); 
    var nrf = require("NRF24L01P").connect( SPI3, A0, A1 );
    

    My 2nd one (the slave) is set up like described in the example. When I try to send a command like (or also something similar):

    nrf.sendCommand("1+2", function(r) { print("=="+r); });
    

    I get this issue:

    ERROR: Field or method does not already exist, and can't create it on a non-object at line 2 col 74
    0;c<=a.length;c+=this.PAYLOAD){for(var d=...
    

    Does anyone knows what that means? I'm using VERSION 1v61

    Thanks & best regards, Andreas

  • Hi Andreas,

    Sorry about this. Something got broken in the NRF24's module. I've just fixed it, so if you click 'send to Espruino' again now, it should be fixed!

  • Hi Gordon,

    Thanks a lot for your fast & great support! It works perfektly now.

    Best Regards, Andreas

  • Hi Gordon,

    I still have one more question:
    Let's say on the slave there is a function like

    function do_measurement () {
    return analogRead(C0, 0.05);
    }
    

    How can I get the return value on the master? I'm looking for a thing like

    measurement_value = nrf.sendCommand("do_measurement()");
    

    Would be great if you (or someone else) have any example how to do this.

    Thanks & Regards, Andreas

  • Hi,

    You should be able to do:

    nrf.sendCommand("do_measurement()", function (myValue) {
      console.log(myValue);
    });
    

    You need the callback because the value won't be returned immediately - it'll only happen after a fraction of a second...

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

NRF24L01 fails on sendCommand

Posted by Avatar for Andreas @Andreas

Actions