Jump to content


Photo

[Energia Library] Nordic nRF24L01+ library


  • Please log in to reply
318 replies to this topic

#301 spirilis

spirilis

    Level 5

  • Members
  • 2,996 posts


Posted 10 April 2015 - 01:28 PM

Awesome, thanks for the reply and the example code.  My only thought on this would be in any type of ISR handler you should only be doing the bare minimum.  I would hope no libraries would do a SPI transaction from inside an interrupt routine.  

I believe the CC3100 (WiFi) library does this unfortunately.... something I caught and was like "uh WTF" but knock on wood it's worked well enough.  I could see an argument for doing this with something that's fairly timing sensitive.  Absolutely *have* to have something like that SPI Transaction support though.


I made some 43oh Store gadgets

Also see my Tindie store


#302 Fmilburn

Fmilburn

    Level 3

  • Members
  • 497 posts
  • LocationSeattle

Posted 08 May 2015 - 08:58 PM

Hi,

 

I'm having a problem getting the MSP-EXP430F5529LP to work with this library.  Has anyone been successful using the nRF24 with the 430F5529?

 

My hardware is:

MSP-EXP430F5529LP

cheap nRF24L01 transceivers

 

I am using the library examples and the following pins:

/*
nrf24l01          MSP430F5529
Signal            LaunchPad
-----------       -----------
  VCC               3V3
  GND               GND
  SCK               P3.2
  CE                P2.7
  CSN               P1.2
  IRQ               P1.3
  MISO              P3.1
  MOSI              P3.0
*/
Enrf24 radio(P2_7, P1_2, P1_3);    // CE, CSN, IRQ pins     MSP430F5529

 

The serial monitor makes it appear that things are working.  For example, with the transmit example I get the following serial output repeatedly:

 

Enrf24 radio transceiver status: DEEP SLEEP <1uA power consumption
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
 

For the receiver I get:

 

Enrf24 radio transceiver status: DEEP SLEEP <1uA power consumption
Enrf24 radio transceiver status: Receive Mode
 

The problem is that the LED does not blink correctly and I don't get regularly serial messages about receiving a packet.  Rarely, it will recieve one packet, normally right after initializing.  The receiver and transmitter are located a few feet apart.  The channel scanning sketch shows some activity.

 

I've tried the following without success:

* set clock divider at 6 and 8, e.g. SPI.setClockDivider(6);

* set radio.begin(250000);

* checked wiring

 

Am I doing something wrong or would the library need modification to work with the 430F5529?



#303 spirilis

spirilis

    Level 5

  • Members
  • 2,996 posts


Posted 08 May 2015 - 11:03 PM

No I have used it with F5529LP many times.

Channels and bitrate the same?
Tried moving the two further away from one another?

Sent from my Galaxy Note II with Tapatalk 4
  • Fmilburn likes this

I made some 43oh Store gadgets

Also see my Tindie store


#304 Fmilburn

Fmilburn

    Level 3

  • Members
  • 497 posts
  • LocationSeattle

Posted 09 May 2015 - 04:53 AM

Thanks for the quick response...

 

Channels and bitrate/datarate are the same.  I tried moving one radio into the next room and the rate of capturing the first packet quickly is higher now. 

 

I've been working on it and here are a couple of new observations...

 

* it sometimes will receive one or even two "on" transmissions and then the "off".  Of course at times it receives the "off" first.  Regardless, it doesn't seem to receive any more packets after the first "off"

* If I reset the receiver, it will work again until it gets an "off"

* I tried putting one in transmit mode on a quiet channel with only a 10 millis delay and then using the channel scanning on the other to see how strong it was and it barely registered. 

* I tried swapping the transceivers in transmission and reception, sitll no luck

* I went back and did a new install of the library - it got worse.  I made SPI.setClockDivider(8) and it seemed to get better again but kept stopping after receipt of the first "off" packet

* Changed bit rate to 250000.  It still stops after the first "off" packet.

* Changed bit rate back to 1000000 and changed to different channel that seemed quieter.  It still stops after the first "off" packet received.

 

I'm out of ideas, only changing SPI clock divider and moving the radio away seemed to help.  I don't understand why it would successfully receive one or two transmissions and then stop.  Maybe one of the nRFs is bad, but I only have the two so can't swap one out right now.  Unfortunately I will be away for a few days and unable to work on my project but appreciate any other thoughts, especially if there is anything different you do for the F5529LP - i.e. change the SPI.setClockDivider since the MCU is running at 25MHz.



#305 Fmilburn

Fmilburn

    Level 3

  • Members
  • 497 posts
  • LocationSeattle

Posted 20 May 2015 - 11:48 PM

Quick note on the problems I was having above - one of my boards was bad. Replacement is working fine on F5529 with no change to clock or the example in the library.
  • spirilis likes this

#306 Oldnotdead

Oldnotdead

    Member

  • Members
  • PipPip
  • 19 posts

Posted 08 June 2015 - 08:39 PM

I am trying without luck to understand the flow of the Enrf demo programs and  libraries. I have set up a pair of Transceivers and

they work okay with the demo programs.

The libraries and demo programs are an excellent tool for Further development.

 

I am an amateur at “C” programming and I am having trouble understanding the following lines in the TX demo program

 

Enrf24 radio(P2_0, P2_1, P2_2);

 

I am not sure what the purpose of the “Enrf24” statement is.

Is the “radio(P2_0, P2_1, P2_2);” setting the pins for the transceiver? 

 

if (radio.read(inbuf))

 

I don’t understand this statement. Where is the radio.read function? I looked in the libraries and could not find it. When the (inbuf) is read, what parameter is the if statement using?

 

Please excuse the very basic nature of these questions. I appreciate any help that may

Be offered.

 

Larry



#307 Fmilburn

Fmilburn

    Level 3

  • Members
  • 497 posts
  • LocationSeattle

Posted 09 June 2015 - 06:37 AM

Hello Larry,

 

I find C a bit cryptic myself.

 

"Enrf24 radio(P2_0, P2_1, P2_2);" passes the LaunchPad pins that are connected to CE, CSN, and IRQ on your transceiver.  You could change these pins if needed.

 

The second question regards a statement in the TX example that is checking to see if anything has been received.  The contents, if any, are in the array inbuf defined by the statement "char inbuf[33];" which is higher up in the program.

 

Hope this helps.


  • spirilis likes this

#308 spirilis

spirilis

    Level 5

  • Members
  • 2,996 posts


Posted 09 June 2015 - 01:15 PM

I am trying without luck to understand the flow of the Enrf demo programs and  libraries. I have set up a pair of Transceivers and

they work okay with the demo programs.

The libraries and demo programs are an excellent tool for Further development.

 

I am an amateur at “C” programming and I am having trouble understanding the following lines in the TX demo program

 

Enrf24 radio(P2_0, P2_1, P2_2);

 

I am not sure what the purpose of the “Enrf24” statement is.

Is the “radio(P2_0, P2_1, P2_2);” setting the pins for the transceiver? 

 

if (radio.read(inbuf))

 

I don’t understand this statement. Where is the radio.read function? I looked in the libraries and could not find it. When the (inbuf) is read, what parameter is the if statement using?

 

Please excuse the very basic nature of these questions. I appreciate any help that may

Be offered.

 

Larry

I recommend diving into some real basic type of tutorials first so you can comprehend the basic C/C++ concepts of buffers/arrays, objects and instantiation, etc.

 

Check this- http://energia.nu/guide/#tutorials

 

Additionally, the Arduino tutorial on making libraries should illuminate some concepts for you - http://www.arduino.c...LibraryTutorial


I made some 43oh Store gadgets

Also see my Tindie store


#309 Oldnotdead

Oldnotdead

    Member

  • Members
  • PipPip
  • 19 posts

Posted 09 June 2015 - 05:18 PM

Thank you for the responses, I have been using an old version of the “C for Dummies” book, It has been helpful, but it is limited. The Arduino tutorial (http://www.arduino.cc/en/Hacking/LibraryTutorial) looks like what I need.

 

I think I understand the “if (radio.read(inbuf))” statement. The literal statement would

Be, “if the inbuf is not empty”, the statement is true. Please correct me if I am wrong.  

 

Larry



#310 Rickta59

Rickta59

    Level 4

  • Global Moderators
  • 992 posts
  • LocationEastern NC


Posted 09 June 2015 - 07:52 PM

... I have been using an old version of the “C for Dummies” book, It has been helpful, but it is limited ...

You might want to upgrade to C++ for dummies, Arduino code is C++.
 

I think I understand the “if (radio.read(inbuf))” statement.


radio is an object of type Enrf24
radio.read is a method returning a value
inbuf is an argument to the read * memory where the results are placed

the if statement is checking the return value from the read.

* Enrf24 read method
https://github.com/s...er/Enrf24.h#L91

-rick

#311 TheMehDude

TheMehDude

    Noob Class

  • Members
  • 2 posts

Posted 18 June 2015 - 04:46 PM

Greetings..

 

I was intending to use this library for a project involving sending of data between 2 systems.. but unfortunately i can't even seem to be able to open energia after copying all the contents to the libraries folder in my sketchbook..

 

I am using Ubuntu 14.04 and energia 15

 

Any ideas why??

 

Thanks



#312 spirilis

spirilis

    Level 5

  • Members
  • 2,996 posts


Posted 18 June 2015 - 05:29 PM

Greetings..

 

I was intending to use this library for a project involving sending of data between 2 systems.. but unfortunately i can't even seem to be able to open energia after copying all the contents to the libraries folder in my sketchbook..

 

I am using Ubuntu 14.04 and energia 15

 

Any ideas why??

 

Thanks

I encountered that.  Weird glitch with Arduino and Energia.  Using a larger screen will help, alternately, find your Energia preferences file (~/.energia/preferences.txt I think) and switch the default to a different architecture, e.g.-

 

target=lm4f

board=lptm4c1230c3pm

(remove the existing target= and board= lines from that file)

 

Energia should start up OK, then you can switch back over to MSP430 or whatever.  I've only see this issue when choosing an MSP430-based board, closing Energia and then re-opening it.  It's a weird visual/GUI glitch in the Java code from what I gathered but it's based on the total # of libraries available for the arch (which determines the GUI size of the Examples menu where I think the glitch lives), which is why switching arch's before startup seems to work.


  • TheMehDude likes this

I made some 43oh Store gadgets

Also see my Tindie store


#313 TheMehDude

TheMehDude

    Noob Class

  • Members
  • 2 posts

Posted 19 June 2015 - 06:29 AM

@spirilis Thanks a lot!!



#314 L.R.A

L.R.A

    Level 3

  • Members
  • 380 posts
  • LocationPortugal

Posted 06 September 2015 - 03:59 AM

Hi @spirilis, I am considering using a NRF24 with the new educational boosterpack,the problem is, it uses to many pins! (the boosterpack).

I wanted to use a TM4C123 but it simply has not enough pins. The TM4C1294 would do but I only have one and I need it for something else (if possible), so I was considering the MSP432 since it has those bottom pins. Problem is it would require bit-banged SPI for that. Did you ever implement that?
If not, any advises in how to do that easily? (like is there a functions always used to push the SPI data on your library that I can simply change and just use the shiftIn and shiftOut functions)

Also considering using different CS pins though I have never done that, not quite sure how that works if data is received from the nordic



#315 spirilis

spirilis

    Level 5

  • Members
  • 2,996 posts


Posted 06 September 2015 - 05:01 AM

You can choose whatever CS, CE and IRQ pins you like so long as the transceiver is wired to them and the library knows which pins they are.

I made some 43oh Store gadgets

Also see my Tindie store


#316 spirilis

spirilis

    Level 5

  • Members
  • 2,996 posts


Posted 09 October 2015 - 02:03 AM

Well that's pretty strange.  On a quick side note, I have now written a C++ library for Linux for the BeagleBone Black using libsoc (soon to change to something faster) which enables me .... much quicker turnaround with nRF24L01+, SI24R1 etc. development.  Just so much easier running this kind of stuff from an embedded Linux host.  My interrupt routines can do fprintf(stderr, "IRQ\n"); type of crap with impunity.

 

I discovered an odd quirk-

 

Packets coming from a node "just barely out of range" can sometimes trigger the RX_DR IRQ, and cause the IRQ line to trigger low, but with the RX FIFO still empty.

 

Witness:

IRQ
Weird; FIFO_STATUS was 11; rf_status was 4E
WR: 07 40

A proper packet from a closer node:

IRQ
FIFO_STATUS was 10; rf_status was 00
RX event-
WR: 07 40
Pipe = 0, length = 13
10 06 07 17 00 17 00 00 
FE 03 07 09 3A 

Expect a patch to Enrf24 to be forthcoming.

 

edit:

Looks like Enrf24 actually handles this somewhat gracefully, but there's no good reason for me to go through the routine of reading the payload width and flush_rx et al if rf_status already has the info I need.  So the patch is pretty simple.

edit2:

This might be the nature behind the occasional "rogue" 0-byte packet I see from time to time.  Looks like my msprf24 and Enrf24 libs basically take care of this right.


  • veryalive likes this

I made some 43oh Store gadgets

Also see my Tindie store


#317 AlanW

AlanW

    Noob Class

  • Members
  • 2 posts
  • LocationNE

Posted 14 November 2015 - 12:29 AM

Thank you.
 
 


#318 angel d

angel d

    Noob Class

  • Members
  • 8 posts

Posted 10 January 2017 - 05:51 AM

Hi

i have a tiva lauchpad and msp430FR6989, how can i do to comunicate them, with the RF module RF24L01?

thanks¡¡



#319 Fmilburn

Fmilburn

    Level 3

  • Members
  • 497 posts
  • LocationSeattle

Posted 11 January 2017 - 05:30 AM

 

Hi

i have a tiva lauchpad and msp430FR6989, how can i do to comunicate them, with the RF module RF24L01?

thanks¡¡

If you do a search of the site there is a post on using the Tiva with the nRF24L01.  This thread is about using it with Energia and the MSP430 family.  I haven't used it with the MSP430FR6989 but try it and report back on how it works out...






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users