SPI1.setup({sck:B3, miso:B4, mosi:B5});
var nrf = require("NRF24L01P").connect( SPI1, C5, C4 );
function onInit() {
nrf.init([0,0,0,0,2], [0,0,0,0,1]);
}
onInit();
dataLine = "";
setInterval(function() {
while (nrf.dataReady()) {
var data = nrf.getData();
for (var i in data) {
var ch = data[i];
if (ch===0 && dataLine!=="") {
console.log(dataLine);
// we could even save it onto an SD card using require('fs').appendFile("log.txt", dataLine+"\n");
dataLine = "";
} else if (ch!==0) {
dataLine += String.fromCharCode(ch);
}
}
}
}, 50);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
If it helps here is the code: