NRF24 questions

Posted on
  • I am starting to use the NRF24... modules I got with the espruino and the master/slave example that I found in the code examples worked really great initially. I then modified the example of the master slightly:

    SPI1.setup({sck:A5, miso:A6, mosi:A7});
    var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
    var counter = 0;
    function onInit() {
      //transmit, receive
      nrf.init([0,0,0,0,2], [0,0,0,0,1]);
      
      setInterval(function() {
        nrf.sendCommand("" + counter++, function(r) { print("=="+r); });
      }, 1000);
    }
    onInit();
    setInterval(function() {
      nrf.masterHandler();
    }, 50);
    

    It sends the counter variable to the slave, then prints the response. So ideally it will print the increasing numbers.

    Two observations:

    • when starting up, and once also just in the middle of runing the master code, I see

      TX not received 30
      TX not received 30
      ==@
      ==
       
      ==!B
      ==A
      ==8
      ==9
      ==
      ==15
      
    • I sometimes get an empty response - the output from teh print is just == in this case. That seems simple to check against, just wondering what the issue is and if it could be fixed.

    • after running this counter till around 600, I disconnected. then connected again and got a massive out of memory error. is this because of the print statement which might queue the output?

    All output is below:

    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    INTERNAL ERROR: Timeout on SPI TX
    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    INTERNAL ERROR: Timeout on SPI TX
    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    INTERNAL ERROR: Timeout on SPI TX
    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    INTERNAL ERROR: Timeout on SPI TX
    INTERNAL ERROR: Timeout on SPI RX
    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    INTERNAL ERROR: Timeout on SPI TX
    INTERNAL ERROR: Timeout on SPI RX
    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    at line 1 col 144
    {this.setReg(7,48);digitalWrite(this.CE,­0);this.setReg(0,10);this.spi.send(225,t­his.CSN);a=a.clone();a.splice(0,0,160);t­his.spi.send(a,this.CSN);digitalWrite(th­is.CE,1);for(a=1E3;a--&&!(this.getReg(7)­&48););0>=a&&print("TX timeout");a=!0;this.getReg(7)&16&&(print­("TX not received "+this.getReg(7)),a=!1);digitalWrite(thi­s.CE,0);this.setReg(0,11);digitalWrite(t­his.CE,1);this.setReg(7,48);return a}
                                                                                                                                                    ^
    in function "send" called from line 2 col 124
    in function "sendString" called from line 1 col 42
    in function "sendCommand" called from line 2 col 67
    in function called from system
    ERROR: Error processing interval - removing it.
    Execution Interrupted during event processing.
    ERROR: Out of Memory!
    ERROR: Out of Me
    
  • Just ran the master/slave next to each other again with a 250ms interval. I experienced this before but reduced the interval as I did not want to wait that long/

    From around 1600 calls, I get a permanent TX not received 30 - any ideas why?

    1671
    ==1672
    ==1673
    ==1674
    ==1675
    ==1676
    ==1677
    TX not received 30
    TX not received 30
    TX not received 30
    ==1678
    ==
    ==1678
    ==1678
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    TX not received 30
    
  • Make sure you're on v59.
    The timer bug fixed in v59 was really nasty, and would cause breakage when things were left running a while - the timer would eventually go berserk.

    I'd expect the master would drown in a flood of out of memory errors if it happened on master first, while if it happened on the slave, the slave would probably just start fumbling every message. So it matches your symptoms - maybe it's that simple?

  • Yes, that could be it...

    The other issue could be if you're powering the receiver from your PC's USB and you're printing text. In this case if no terminal app is connected to Espruino, the PC/Mac won't receive the data printed from Espruino, and Espruino will just sit there waiting once its output buffer is full.

  • how I can clean terminal buffer? I case of big number of error messages from NRF module , if slave doesn't respond, the master stops working because of buffer overflow.

  • Is this when you're connected via USB but there is no terminal app running? If so, just:

    • Always run a terminal app
    • Run off a USB charger instead
    • Explicitly move the terminal to Serial1 with Serial1.setConsole()
  • For anyone else running into this, I discovered you can use multiple chrome profile in order to run multiple copies of the IDE simultaneously (one for each device)

  • That's really cool - thanks for the suggestion!

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

NRF24 questions

Posted by Avatar for hansamann @hansamann

Actions