• In case anyone wants it, here is my code for multiple TX with one RX:

    RX:

    SPI1.setup({sck:A5, miso:A6, mosi:A7});
    
    var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
    
    var recvData, lastData, lastUpdated;
    
    function onInit() {
      recvData = [];
      lastData = [];
      lastUpdated = [];
      lastUploaded = getTime();
      
      nrf.init([0,0,0,0,1]/* rx addr 1*/, [0,0,0,0,2] /* tx addr */);
      nrf.setDataRate(250000);
      // set receive addresses
      nrf.setRXAddr([1,0,0,0,1], 2);
      nrf.setRXAddr([2,0,0,0,1], 3);
      nrf.setRXAddr([3,0,0,0,1], 4);
      nrf.setRXAddr([4,0,0,0,1], 5);
    
       setInterval(checkNRF, 50);
    }
    
    function checkNRF() {
      var pipe;
      while ((pipe=nrf.getDataPipe())!==undefined) {
        nrf.getData().map(function(ch) {
          if (recvData[pipe]===undefined) recvData[pipe]="";
          if (ch===0 && recvData[pipe]!=="") {
            var d = JSON.parse(recvData[pipe]);
            if (d) {
              lastData[pipe] = d;
              lastUpdated[pipe] = getTime();
            }
            recvData[pipe] = "";
          } else if (ch!==0) {
            recvData[pipe] += String.fromCharCode(ch);
          }
        });
      }
    }
    

    TX 1:

    SPI1.setup({sck:A5, miso:A6, mosi:A7});
    var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
    function onInit() {
      nrf.init([0,0,0,0,2]/* rx addr */, [0,0,0,0,1]/*tx must match receiver's RX*/);
      nrf.setDataRate(250000);
    }
    function sendData() {
      var data = { temp : E.getTemperature().toFixed(2), bat : E.getAnalogVRef().toFixed(2) };
      nrf.setEnabled(true);
      nrf.sendString(JSON.stringify(data));
      nrf.setEnabled(false);
    }
    onInit();
    setInterval(sendData, 20000);
    setDeepSleep(1);
    

    TX2:

    SPI1.setup({sck:A5, miso:A6, mosi:A7});
    var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
    function onInit() {
      nrf.init([0,0,0,0,2]/* rx addr */, [1,0,0,0,1]/*tx must match receiver's RX*/);
      nrf.setDataRate(250000);
    }
    function sendData() {
      var data = { temp : E.getTemperature().toFixed(2), bat : E.getAnalogVRef().toFixed(2) };
      nrf.setEnabled(true);
      nrf.sendString(JSON.stringify(data));
      nrf.setEnabled(false);
    }
    onInit();
    setInterval(sendData, 20000);
    setDeepSleep(1);
    

    and so on... All that changes is the TX address.

About

Avatar for Gordon @Gordon started