-
• #2
I'd perhaps try and compare:
https://github.com/maniacbug/RF24/blob/master/RF24.cpp
and
https://github.com/espruino/EspruinoDocs/blob/master/devices/NRF24L01P.js
Espruino uses the default clock rate - so you could either modify the Espruino library, or you could modify the Arduino one to stop it setting the rate away from the default.
First thing I'd try is to set Espruino's payload size to 32 bytes though - Espruino defaults to 16 but the module you link to seems to use 16.
-
• #3
I spent a while after posting this digging through the datasheet looking for the defaults with the assumption that the espruino library doesn't change them. There are still a number of naming convention differences I haven't gotten my head around but I will take another stab at it.
I was hoping someone had done this before but I will probably need to do the hard work myself! -
• #4
I've been struggling with exactly the same setup and libraries. I've ended up dumping out the register contents of the NRF24L01+ from both the Espruino side and the Arduino side and tried to line them up. There were some basic differences like bit rate and channel which I've sorted out but still almost no joy. I've managed to go from silence to maybe one transmit in 30 or 40 being received by the Arduino if the Espruino is sender and similar success rate if I swap them around.
The RF24 Arduino code works perfectly on a mix of Pro Minis, Unos and DigiX but just getting no joy on Espruino. The only thing I can think of at the moment, in lieu of an oscilloscope, is to get a second Espruino and see if they can at least see each other.
Register Dump from Arduino:
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xfefefefefe 0x2222222222
RX_ADDR_P2-5 = 0x02 0x03 0x04 0x05
TX_ADDR = 0xfefefefefe
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x3f
RF_CH = 0x02
RF_SETUP = 0x0f
CONFIG = 0x0b
DYNPD/FEATURE = 0x00 0x00
Data Rate = 2MBPS
Model = nRF24L01+
CRC Length = 8 bits
PA Power = PA_MAXRegister Dump from Espruino:
STATUS = 0xE
RX_DR = 0x0
TX_DS = 0x0
MAX_RT = 0x0
RX_P_NO = 0x7
TX_FULL = 0x0
RX_ADDR_P0 = 0,0,0,0,1
RX_ADDR_P1 = 0,0,0,0,2
RX_ADDR_P2 = 195,195,195,195,195
RX_ADDR_P3 = 196,196,196,196,196
RX_ADDR_P4 = 197,197,197,197,197
RX_ADDR_P5 = 198,198,198,198,198
TX_ADDR = 0,0,0,0,1
RX_PW_P0 = 0x10
RX_PW_P1 = 0x10
RX_PW_P2 = 0x0
RX_PW_P3 = 0x0
RX_PW_P4 = 0x0
RX_PW_P5 = 0x0
RX_PW_P6 = 0xB
EN_AA = 0x3F
EN_RXADDR = 0x3
RF_CH = 0x2
RF_SETUP = 0xF
CONFIG = 0xB
DYNPD = 0x0
FEATURE = 0x0
Data Rate = 2MBPS
CRC Length = 8
PA Power = MAX -
• #5
I tried doing the same thing, I read out the registers and matched up as much as possible but I couldn't get anywhere. I assume the library is good enough to get two espruino's talking but that wasnt what I was interested in.
In the end I switched from using an espruino as the main device in my project to using a spark core. Not quite as nice but it just worked.
-
• #6
I'm aiming for full interoperability between a range of Arduinos, Espruino and RaspberryPi so I'd love to get to the bottom of this.
Oddly, it's reassuring that you are having the same problems as it means I probably don't need to worry about wiring or a dud module any more!
-
• #7
The problem as I see it is the library doesn't expose any of the settings required to use the device, it just relies on the default while the RF24 library used elsewhere intentionally resets every setting to something else.
-
• #8
It looks from the dump above like the RX and TX addresses are different. I guess you've at least set those up correctly first?
The NRF module will talk to other Espruinos just fine - I don't think I was even aware of the RF24 module when I wrote it though so I guess it's not a big surprise that they don't talk.
Can you not modify the Espruino library to go through exactly the same steps for setup? You can just add
var exports={}
at the top of the Web IDE, copy and paste the library in, writevar nrf = exports.connect(...)
rather thanrequire
, and start messing around.It shouldn't take that much work to fix it - it'd be great if you could issue a pull request if you get it working...
-
• #9
Thanks Gordon, I've done a lot of playing with addresses at both ends as per the IC spec without much luck. I've been trying to make Arduino settings more like Espruino, but as you suggest, maybe the other way around might be better. I'll play more this week. Will do pull request if I get to the bottom of it.
-
• #10
Thanks - I guess the ideal outcome would be that Espruino could talk to an Arduino that hadn't had any Espruino-specific changes made to it - but I don't know how hard it'll be to make that happen.
It might be worth changing the 4th 'payload' argument into an object, which could have various other initialisation options which could bring it more in line with Arduino.
-
• #11
@ArthurGuy I finally got back to trying this out again and made some progress. I can now successfully transmit from Arduino to Espruino completely reliably.
On Espruino:
SPI1.setup({ sck: A5, miso: A6, mosi: A7 } ); var nrf = exports.connect( SPI1, B0, B1 ); var counterCheck=0; function onInit() { nrf.init([0xF0,0xF0,0xF0,0xF0,0xF0], [0xF0,0xF0,0xF0,0xF0,0xF0]); } onInit(); dataLine = ""; setInterval(function() { while (nrf.dataReady()) { var data = nrf.getData(); for (var i in data) { var ch = data[i]; if ((ch===0 || ch==0x0A) && dataLine!=="") { console.log(dataLine); dataLine = ""; } else if (ch!==0) { dataLine += String.fromCharCode(ch); } } } }, 50);
On Arduino:
// Set up nRF24L01 radio on SPI pin for CE, CSN RF24 radio(8,9); // Example below using pipe5 for writing const uint64_t pipes[2] = { 0xF0F0F0F0F0LL, 0xF1F1F1F1F1LL }; //radio.enableDynamicPayloads(); radio.setPayloadSize(0x10); radio.setDataRate(RF24_2MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(2); radio.setRetries(15,15); radio.setCRCLength(RF24_CRC_8); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]);
The only change I really made since previously was to set the Payload to 16 on Arduino as suggested by @Gordon. I also tried setting Dynamic Payload in both cases and that seems to work too.
However making the Arduino the receiver and the Espruino the transmitter is proving more difficult. The Arduino says that it has received a payload every time one is sent from the Espruino, but the contents are all zeros. The Espruino also gives a "TX not received 82" after every transmit.
So at least we know there is no fundamental incompatibility here but I'm running out of ideas on the Arduino-RX side of things.
-
• #13
How much does the NRF need? The espruino board can supply 150ma at 3.3v...
People have reported success talking between two espruinos though, so I don't think it's that...
-
• #15
I'm pretty sure it's not power. It may be something very simple that is still configured differently between the two. More investigations required by me!
Hi all,
I am attempting to communicate between an espruino and an arduino using the NRF24L01+ modules.
I have followed the examples on the espruino website and I am using the RF24 library on the other end.
http://maniacbug.github.io/RF24/
The problem I am having is that the two systems seem completely different, I am guess the espruino library doesn't implement many features but even using the ones it does I should be able to get this to work.
Has anyone managed anything like this?
Does anyone know what channel and data rate is used, how do these correspond to the addresses passed into the init function?
Any advice would be much appreciated.