Jump to content
43oh

[Energia Library] Nordic nRF24L01+ library


Recommended Posts

I believe it is genuine nRF24L01+, green board, 10pin connector. Chip markings state NRF 0 24L01+ (1423CC date?).

 

Increasing the delay to any time, or even removing the digitalWrite(_cePin, LOW) does not make a change. Even permanently changing all of the CE writes to HIGH does nothing. So I have investigated further and something strange is going on.

 

Chooring a random pin for CE does not change anything, say PE_2. Setting pin PD_0 to output and HIGH prevents the module to be found.

 

So this part of the problem may have nothing to do with the library as such.

 

Weird.  Check the resistance between CE, CSN, the SPI pins, Vcc, etc with a multimeter?  Wonder if it's a board issue.  But then you said it worked with an MSP430, so I dunno...

Link to post
Share on other sites
  • Replies 352
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi folks... So I'm a little new to Energia, but since I wrote a library for the nRF24L01+ digital transceivers for native C-based apps I figured it'd be a great idea to port this to Energia.   I'm r

Ok, so I ported the Enrf library over so that it works with both MSP430 and Stellaris.  Seems to work great.  I am watching the tx rx demo between msp430g2553 (on the RX side), and the StellarPad doin

Okie doke - https://github.com/spirilis/Enrf24   The examples are the same as the ones I posted... I'll write up the API in a wiki page soon.  Alternately, I put documentation in the Enrf24.h file f

Posted Images

I have eliminated the electrical issues with the following method: Used a brand new, fresh Launchpad Tiva C and NRF24L01+ module. Applied the previously posted sketch. Repeated the procedure with two more Tiva C Launchpads and some more nrf modules. Checked nfr modules win MSP430 launchpads, working as they should with the same library.

 

Only remaining thing that comes to my ming is some buffer owerflow, screwing things up like this. This being only a Stellaris issue though.

Link to post
Share on other sites

I have eliminated the electrical issues with the following method: Used a brand new, fresh Launchpad Tiva C and NRF24L01+ module. Applied the previously posted sketch. Repeated the procedure with two more Tiva C Launchpads and some more nrf modules. Checked nfr modules win MSP430 launchpads, working as they should with the same library.

 

Only remaining thing that comes to my ming is some buffer owerflow, screwing things up like this. This being only a Stellaris issue though.

Gotcha ... Where did you d/l my library btw?  Github, or one of the zipfile links here?

Link to post
Share on other sites

The same setup as described in my previous posts works out-of-the-box with ZIP library http://forum.43oh.com/topic/3237-energia-library-nordic-nrf24l01-library/page-7#entry38488

 

ZIP version is of an older date then github, so there must have been some bugs introduced in the github version.

Hmm... diff of those 2:

diff Enrf24-works/Enrf24.cpp Enrf24/Enrf24.cpp
25c25
< #include <Energia.h>
---
> #include <Arduino.h>
341a342
>     //digitalWrite(_cePin, HIGH);  // Workaround for SI24R1 knockoff chips
343a345
>     //digitalWrite(_cePin, LOW);
353c355
<   delayMicroseconds(30);
---
>   delayMicroseconds(100);
484c486,488
<   pwr = 0x03;
---
>   pwr = 0x06;
>   if (dBm >= 7)
>     pwr = 0x07;
486c490
<     pwr = 0x02;
---
>     pwr = 0x04;
488c492
<     pwr = 0x01;
---
>     pwr = 0x02;
491c495
<   _writeReg(RF24_RF_SETUP, reg | (pwr << 1));
---
>   _writeReg(RF24_RF_SETUP, reg | pwr);
diff Enrf24-works/Enrf24.h Enrf24/Enrf24.h
30c30
< #include <Energia.h>
---
> #include <Arduino.h>
Common subdirectories: Enrf24-works/examples and Enrf24/examples

Can't imagine that changing Energia.h to Arduino.h (which just includes Energia.h) did it... the RF_SETUP stuff looks correct, main thing is the change of delayMicroseconds() time.

Link to post
Share on other sites

As it turns out, this wild goose chase has been created by a series of problems as follows:

- CE on one of the test setups had stray resistance to another pin, due to the error on the PCB

- solving this problem led to small changes in the library which broke the system further

- I have skipped as step of freshly updating the library at some point

 

Both old and GIT versions work with Tiva C Launchpad.

 

I suggest the following fixes.

TX demo suggests

  radio.print(str_on);
  radio.flush();  // Force transmit (don't wait for any more data)
  dump_radio_status_to_serialport(radio.radioState());  // Should report IDLE

However the serial output states:

Sending packet: ON
Enrf24 radio transceiver status: Actively Transmitting
Sending packet: OFF
Enrf24 radio transceiver status: Actively Transmitting

Why the state reported is different from the one suggested in the demo?

 

Following up on this to the library with a possible failure on CE pin will results in TX buffer overflowing and the sketch crashing due to:

  if (reg & BIT5) {  // RF24_TX_FULL #define is BIT0, which is not the correct bit for FIFO_STATUS.
    return;  // Should never happen, but nonetheless a precaution to take.
  }

Before returning this should probably do: txbuf_len = 0;  // Reset TX ring buffer preventing the problem like this.

 

Spirilis, thank you very much for your responses, they lead me to finding the problem, hopefully this run helps improve the library as well.

Link to post
Share on other sites

Great job, thanks!

 

Some debugging advice:

- if TX demo reports Actively transmitting, check CE pin.

- if on the RX side you only see periodic text about received data, but not the castual string, check IRQ pin.

- when using the communication with custom data, mind using print and write, the first converts your data into ASCII

 

I have my use case happily running, will prepare an example for sending a packet with various data in a single packet shortly.

Link to post
Share on other sites

Hi! I've had some trouble trying to configure this. 

 

1) My transreceiver doesn't have an antenna. But the weird thing is that using the "Channel Scanner" from the example of the library when I touch one of the cables it starts receiving information, and when I release it it stops.

 

2) What's the pin configuration?? 

 

I am working on a Quadcopter, and so far I would like to send the GPS coordinates to an LCD using two transreceivers: one flying, the other receiving. Please help!!!!! 

THANKS!

Link to post
Share on other sites

Edit: Probably misunderstood your question. You would like to put two transceivers on a single Launchpad? Then read below :)

 

There are probably two options. Having both transceivers on the same SPI bus and assigning different CSN, CE and IRQ pins to them. To do this, you need to create two radio objects, for example:

Enrf24 radio1(CE_1,CSN_1, IRQ_1);
Enrf24 radio2(CE_2,CSN_2, IRQ_2);

Then you repeat the begin and configuration code for both. I havent tested this yet myseld, but should work in theory.

 

The second option is to use two different SPI buses, for that the Enrf24 library needs to be adapted, to support SPI argument as well. Again, writing this without testing:

 

Enrf24.h must have the constructor fixed and an include added.

#include <SPI.h>

Enrf24(SPIClass *mySPI, uint8_t cePin, uint8_t csnPin, uint8_t irqPin);
SPIClass *_mySPI;

Enrf24.cpp must have the constructor fixed and all instances of "SPI." changed by "_mySPI->"

/* Constructor */
Enrf24::Enrf24(SPIClass *mySPI,uint8_t cePin, uint8_t csnPin, uint8_t irqPin)
{
  _mySPI = mySPI;
  _cePin = cePin;
  _csnPin = csnPin;
  _irqPin = irqPin;

  rf_status = 0;
  rf_addr_width = 5;
  txbuf_len = 0;
  readpending = 0;
}

Then in your main code you call this fixed library by:

//radio
Enrf24 radio(&SPI, ENRF24L_CE, ENRF24L_CSN, ENRF24L_IRQ);

where SPI can be SPI0 for channel 0, SPI1 for channel 1, SPI for channel 2 (default), SPI3 for channel 3.

 

This should work in theory, but needs to be tested. There could be a neater solution though.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...