SPI1.setup({sck:A5, miso:A6, mosi:A7}); // B0, 1 used for other pins.
var nrf1 = require("http://localhost/NRF24L01P.min.js").connect( SPI1, B0, B1, 32);//Arduino library defaults 32 byte packet length.
nrf1.init([0xE7,0xE7,0xE7,0xE7,0xE7], [0xE8,0xE8,0xF0,0xF0,0xE1]);
nrf1.setReg(0x05,76); //The arduino library uses channel 76
var test=[222,173,190,239,222,173,190,239,222,173,190,239,222,173,190,239];
var test2=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32];
My version of the NRF module was modified to change the BASE_CONFIG to use 2-byte CRC, since the arduino library wants that; no other changes.
Code on Arduino side (hacked up from an example)
[#include](https://forum.espruino.com/search/?q=%23include) <SPI.h>
[#include](https://forum.espruino.com/search/?q=%23include) "nRF24L01.h"
[#include](https://forum.espruino.com/search/?q=%23include) "RF24.h"
[#include](https://forum.espruino.com/search/?q=%23include) "printf.h"
//
// Hardware configuration
//
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(9,10);
//
// Topology
//
// Single radio pipe address for the 2 nodes to communicate.
const uint64_t pipe = 0xE8E8F0F0E1LL;
uint8_t payload_data[16];
//
// Setup
//
void setup(void)
{
//
// Role
//
Serial.begin(57600);
printf_begin();
printf("\n\rRF24/examples/led_remote/\n\r");
//
// Setup and configure rf radio
//
radio.begin();
//
// Open pipes to other nodes for communication
//
// This simple sketch opens a single pipes for these two nodes to communicate
// back and forth. One listens on it, the other talks to it.
radio.openReadingPipe(1,pipe);
radio.startListening();
radio.printDetails();
}
//
// Loop
//
void loop(void)
{
// if there is data ready
if ( radio.available() )
{
// Dump the payloads until we've gotten everything
bool done = false;
while (!done)
{
// Fetch the payload, and see if this was the last one.
radio.read( payload_data, 16 );
done=radio.available();
// Spew it
printf("Got payload\n\r");
int i;
for (i = 0; i < 16; i = i + 1) {
Serial.print(payload_data[i]);
}
}
}
}
I remember reading a post by someone else doing this - I can't seem to find it now though. I'm wondering if they ever got it working.... The NRF24 should be a great way to do simple communications between an Espruino and one or more less-capable Arduino-like devices tucked into corners, or located outdoors, etc.
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.
Has anyone managed to make this work?
I'm using the RF24 arduino library from here:
https://github.com/TMRh20/RF24
Espruino:
My version of the NRF module was modified to change the BASE_CONFIG to use 2-byte CRC, since the arduino library wants that; no other changes.
Code on Arduino side (hacked up from an example)
Serial output is this - which all looks right:
On the Espruino, I try to do:
I remember reading a post by someone else doing this - I can't seem to find it now though. I'm wondering if they ever got it working.... The NRF24 should be a great way to do simple communications between an Espruino and one or more less-capable Arduino-like devices tucked into corners, or located outdoors, etc.