Jump to content
43oh

[Energia Library] Nordic nRF24L01+ library


Recommended Posts

  • 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

  • 3 weeks later...

Good day everyone, my name is Chao. I am a new user to the Nordic nrf24l01, msp430 and energia. I am working on a school project, and I am tying to setup RF communications between two MSP430f5529 launchpad suing Nordic chips. I downloaded the library for the Nordic chip, and changed pins on the TX and RX demo to fit the pin configuration for the MSP430f5529. Then upload and run the demo, but I am having problems. I could not get the text  "on" and "off" to show up on my receiver side, and the LED doesn't turn on and off. All I got is the text below:

Text on TX:

Sending packet: ON
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: OFF
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: ON
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: OFF
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: ON
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: OFF
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: ON
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: OFF
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: ON
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: OFF
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
Sending packet: ON
Enrf24 radio transceiver status: IDLE module powered up w/ oscillators running
 
Text on RX:
Enrf24 radio transceiver status: DEEP SLEEP <1uA power consumption
Enrf24 radio transceiver status: Receive Mode
 
I only change one line on the code which is:
 Enrf24 radio(P3_5, P3_6, P3_7);  // P2.0=CE, P2.1=CSN, P2.2=IRQ
 
The connection on the pins are:
 
Nordic                 Msp430f5529 luanchpad
1. GND               GND
2. VCC               3.3V
3. CE                  P3_5 ( digitalRead() and dititalWrite())
4. CS                  P3_6  ( digitalRead() and dititalWrite())
5. SCK               P3_2 (SCK)
6. MOSI              P3_0 (MOSI)
7. MISO              P3_1 (MISO)
8. IRQ                P3_7 ( digitalRead() and dititalWrite())
 
I am wondering if anybody here can help me to figure out a way to solve the problems. Thank you very much.
 
Link to post
Share on other sites
  • 2 weeks later...

Hi @@spirilis! Thanks for the library, it is working great out of the box.

 

Is there a way for the receiver to see the source address of the data? Which transmitter sent the data?

 

I'm eventually going to have several nodes sending data back to a central receiver connected to a computer for logging, and I will need to differentiate where the data comes from. I can, of course, embed a node ID in the data being sent, but if that is already part of the overhead sent by the library or the Nordic chip itself...

 

Thanks!

 

-Pete

Link to post
Share on other sites
  • 3 weeks later...

Hi, thanks for the library, it's so useful.

 

I am trying to make sensor nodes with nrf+msp430g2553 pairs. I'm aiming to use interrupts and make all the system low power as possible. I mean sleep both nrf and msp till an external stimulation comes and fire the interrupt flag, is it possible?

For example, I have a PIR sensor on node1 and I want to stimulate node2  when there exist motion on node1. I have looked on your first demo code, and make it works for 3 nodes as blinking led every second. But when I m trying to use the example code structure on PIR with LPMs and interrupts it doesn't work. Maybe you can help me ? I'm not sure where to put on LPM and how to call interrupts to work. 

Here is my arrangement on your code;

 

 
#include <Enrf24.h>
#include <nRF24L01.h>
#include <string.h>
#include <SPI.h>
 
Enrf24 radio(P2_0, P2_1, P2_2);  // P2.0=CE, P2.1=CSN, P2.2=IRQ
const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
 
const char *str_on = "ON_A"; // send when motion dedected

const int SENS = P1_1; // PIR pin, input 3.3V when motion dedected  

 
void setup() {
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(1); // MSB-first
 
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power
  radio.setTXaddress((void*)txaddr);
  
  pinMode(SENS, INPUT_PULLUP);
  attachInterrupt(SENS, pir, RISING);
}
 
void loop() {
 
LPM4;

}

void pir(){
  
radio.print(str_on);
radio.flush();  // Force transmit (don't wait for any more data)
delay(1000);
} 
Link to post
Share on other sites

My code doesn't use interrupts natively at all, however there's no reason you can't add it yourself.  Create a function that wakes the CPU up out of LPM, then make that the interrupt function for the nRF24's IRQ pin.

 

This should only be necessary on the receive-side nodes BTW.

Are you having trouble with the transmitter side or receiver side?

Link to post
Share on other sites

The code above was for the transmitter one, and the receiver is ready all the time for any data, there is no need to sleep the receiver node actually.

But my code above, doesn't work. While waiting, the mcu is in LPM4, and I defined an interrupt when the PIR sensor stimullate P1_1 pin. So, it should wake up and process the codes inside void pir() I gues but it doesn't. 

 

Another question, in the void setup() we have radio.begin(). What exactly do this code? I mean, before radio.begin, is nrf sleeping or something like that? If it's, maybe I should use it inside the void pir() and awake nrf only when interrupt occurs.

Link to post
Share on other sites

The code above was for the transmitter one, and the receiver is ready all the time for any data, there is no need to sleep the receiver node actually.

But my code above, doesn't work. While waiting, the mcu is in LPM4, and I defined an interrupt when the PIR sensor stimullate P1_1 pin. So, it should wake up and process the codes inside void pir() I gues but it doesn't. 

 

Another question, in the void setup() we have radio.begin(). What exactly do this code? I mean, before radio.begin, is nrf sleeping or something like that? If it's, maybe I should use it inside the void pir() and awake nrf only when interrupt occurs.

 

Before begin() is run, the nRF is uninitialized, in powerdown/sleep mode with a default set of addresses and no radio configured.  FIFOs are clear.  Other settings might be off (e.g. whether interrupts expose themselves to the IRQ pin, etc).

 

In general, I do not recommend doing any I/O inside an interrupt routine like what you're doing here.  However I'm not certain that it shouldn't work, either.  But it's generally a better idea to use the interrupt routine to set a volatile global flag and then exit LPM; then in your loop(), check that flag and do the work as needed, then re-enter LPM.

 

Also, sleeping a whole second inside an interrupt service routine is a generally bad idea.

 

Lastly, are you sure your PIR code works at all?  Is the PIR sensor actually triggering the interrupt routine (e.g. have you tried just blinking an LED on the node1 board in response to the PIR sensor?)

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...