nRF24L01 - 2.4GHz Radio integration

Post Reply
DedeHai
Posts: 2
Joined: Sun Apr 08, 2012 9:07 am

nRF24L01 - 2.4GHz Radio integration

Post by DedeHai »

Hey everyone

Could not find any info in the forum about the nRF24L01(+) 2.4GHz Radio receiver/transmitter module. Did nobody ever use it or just nobody bothered to write it up?

I will change that. Here is me, announcing the (future) integration of the nRF24L01 into the code, if possible without too many modifications to the original code. Just started programming so I cannot yet say if it will be easy to integrate or not.


The nRF24L01 is a 2.4GHz fully integrated radio IC that communicates over SPI. Modules can be pretty small, see here:
http://arduino-info.wikispaces.com/Nrf2 ... 4GHz-HowTo

The good thing about the IC is, that it handles all the communication after it got the data from the arduino. It does:
-Transmit the data (including CRC check and all)
-Re-transmit if it failed (up to 15 times)
-Generates an interrupt when done

There are two arduino libraries for it (as described in the link). I found that the Mirf library has very limited functionality, so I chose the more elaborate RF24 library. Did some tests, seems to work well.
The code for SPI plus the library are pretty big, like 5-6kB so it will probably not be possible to integrate it on a ATmega168. Tests will be done on a proMini with an ATmega328.

The goal in the end is to have a Wii Classic controller equipped with another proMini and of course the transmitter, to control the multicopter. I plan this for an indoor copter, the range of the radio (without additional antenna) is limited to about 100m.
It can also be used to transmit data back if necessary.

I will post some code as soon as I get it up and running (or run into a dead end).

msev
Posts: 186
Joined: Thu Apr 14, 2011 11:49 am

Re: nRF24L01 - 2.4GHz Radio integration

Post by msev »

Whats the power equivalent in mW to compare to our usual transmitters?

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: nRF24L01 - 2.4GHz Radio integration

Post by Hamburger »

depending on the sensors (gyro, acc, baro, mag, gps) the 328p already is too small for the current feature set. This is before adding any additional code. So please be aware you may run into 'out of memory' problems of some kind sooner than you wish.
I do not comment on the matters of SPI nor the RF module in question - I have no experience with either one.
Good luck.

DedeHai
Posts: 2
Joined: Sun Apr 08, 2012 9:07 am

Re: nRF24L01 - 2.4GHz Radio integration

Post by DedeHai »

Output power is stated to be about 1mW, so not enough for outdoor flying.

@Hamburger:
I was not aware that the baro, mag and gps use up so much flash memory, never compiled with these options.
As this is intended for an indoor multicopter, a gyro and an acc should suffice.

I completed code integration, the GUI still spits out the data as usual. The compiled code with a gyro (ITG3200) and accelerometer (ADCACC) is 16850 bytes instead of 14554 bytes when compiling without the new code.

Unfortunately I killed one of the two modules while testing the code, so no more debugging possible at the moment. I still do not know if the SPI interrupts do any damage to the overall code but I doubt it since the normal Rx code also uses (lots of) interrupts. If there is a problem with the current implementation, it can be modified to be well synchronised with the rest (i.e. putting it into the annex-code section).

nguoihn
Posts: 9
Joined: Sat May 31, 2014 12:11 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by nguoihn »

Hello everyone,

I wanted to start a project like your, I would like to know why you stopped it? Is it impossible? I wanted to do only a functional quadcopter with homemade radio.

e_lm_70
Posts: 297
Joined: Fri Aug 09, 2013 8:35 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by e_lm_70 »

nguoihn wrote:Hello everyone,

I wanted to start a project like your, I would like to know why you stopped it? Is it impossible? I wanted to do only a functional quadcopter with homemade radio.


I made a TX and RX with NRF24L ... TX module cost 8$ , RX module 5$ .. simple DIY by just putting together two ready module (no soldering at all) and update the firmware.

The only issue is that I get just 200m signal range ... a bit too little for my taste ... and I use n the TX the NRF24L with PA ...

If you want to get better range, you should use Si4432 modules, or CC2500 .. the Si4432 module are cheap and already integrated as OpenLRS into MultiWii code.

daedae
Posts: 3
Joined: Sun Jan 08, 2012 4:13 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by daedae »

I stopped the project bacause I could not get the quad to fly properly (not enough power) and did not have time to investigate why it would not fly. It is still all sitting on my shelf waiting to be completed. The transmitter part worked just fine, but limited to like 100m.
I even made a 3D printed part that can be sort of clipped to the classic controller and carries an arduino nano and the transmitter plus a battery to power it all (nintendo DS battery).
Sorry for not continuing to write it all up here but I just did not have the time to finish the project as I changed my project focus from quadcopters to digital LEDs:(off topic led demo: https://www.youtube.com/watch?v=F7fd7MILKFU )

If there is interest, I can maybe attach the modified software for the transmitter to this post, it is not too well coded (not using standard #define) but it should be readable and is in the style of the original code, all parts should be in the right places.

nguoihn
Posts: 9
Joined: Sat May 31, 2014 12:11 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by nguoihn »

Thanks for reply.

I bought about 10 module of nRF24L01, so I want to continue with it, I apreciate alot if you could share me the code, I wanted to make a simple indoor brushed quad the cheapest possible.

I didnt know about Si4432, i'll buy some for testing. Thanks alot.

e_lm_70
Posts: 297
Joined: Fri Aug 09, 2013 8:35 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by e_lm_70 »

nguoihn wrote:Thanks for reply.

I bought about 10 module of nRF24L01, so I want to continue with it, I apreciate alot if you could share me the code, I wanted to make a simple indoor brushed quad the cheapest possible.

I didnt know about Si4432, i'll buy some for testing. Thanks alot.


Related to the NRF24L ... I would suggest to check this: http://playground.arduino.cc/Interfacin ... e/Nrf24L01

I did use the MIRF library as the basic for implement my TX-RX code ... PPM and PWM conversion is quite simple ... between TX and RX these NRF24L speak digital ... so you can decide to send like 8bytes , 1 byte for channel ... 256 servo position is more then enough in most of cases ... actually MultiWii in 328 board is not more precise then 256 steps when control the ESC.

My own TX-RX code is still a bit messed up ... I did not really clean up my project ... so I'm not going to share it soon

Else .. you can check the Deviation code .. there you can see some NRF24 protocol supported (NRF24 is used by some old NineEagle toys and other WLtoys as well) ... I'm not sure which range you may expect if you use NRF24 without the PA ... that means the ultra cheap NRF24 module with the little integrated antenna .. I guess with these you possibly don't even get 50m range ... still should be good enough for indoor or for small RC

nguoihn
Posts: 9
Joined: Sat May 31, 2014 12:11 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by nguoihn »

Hello,

Thanks for your reply. I'm new to multiwii, and the code is huge, I dont know where to start to make multiwii work with this module. Can you show me please?

e_lm_70
Posts: 297
Joined: Fri Aug 09, 2013 8:35 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by e_lm_70 »

nguoihn wrote:Hello,

Thanks for your reply. I'm new to multiwii, and the code is huge, I dont know where to start to make multiwii work with this module. Can you show me please?


I would suggest you start making some test between two NRF24L module using two Arduino boards, just use the Server and Client Ping example.

Then you need a PPM decoder and a NRF24L MIRF based 8ch sender ... the PPM decoded you have already from MultiWii code ... or maybe you don't even need a PPM signal at all .. if you have your own DIY radio ...

Integrated MIRF inside MultiWii it is not a trivial task, and possibly will need a Mega board ... or just ACRO MultiWii with a 328 board.

It is a lot of work, for get a "short" range.

Using Si4432 modules you get off shelf support with OpenLRS integrated on MultiWii

nguoihn
Posts: 9
Joined: Sat May 31, 2014 12:11 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by nguoihn »

I think i'm being too naive to start this project, I wanted to do my own radio, radio and receiver, and I think I can just intercept in the multiwii code when the information of "throttle rudder ..." channel go to the computational block and replace it by the command from the module. But I thinks these command is encrypted somewhere and I can't find it explicitly.

Why is the nrf2401 can't work like Si4432? We can code the protocol, right?

But you guy are succeeded to make it work, right?

e_lm_70
Posts: 297
Joined: Fri Aug 09, 2013 8:35 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by e_lm_70 »

nguoihn wrote:I think i'm being too naive to start this project, I wanted to do my own radio, radio and receiver, and I think I can just intercept in the multiwii code when the information of "throttle rudder ..." channel go to the computational block and replace it by the command from the module. But I thinks these command is encrypted somewhere and I can't find it explicitly.

Why is the nrf2401 can't work like Si4432? We can code the protocol, right?

But you guy are succeeded to make it work, right?


NRF24 is 2.4G
Si4432 is 433MHz

They don't speak the same dialect ... neither in the air waves ... nor at code level.

I have DIY TX and RX module, doing PPM and PWM in/out using Si4432 and NRF24L ... based on Arduino Pro Mini board ... ups actually for NRF24 I did use a Atmega48 board that is Plug & Play over NRF24 modules.

But, no I have not try to integrated these inside MultiWii for now ... but I know Si4432 is supported natively by MultiWii code (using OpenLRS ... but I did test on OpenLRSng my DIY modules) , plus some people in RCG did hack into MultiWii the FlySky modules and FrSky module (using A7105 modules and CC2500 modules respectively)

In RCG you can find people doing their own Radio in DIY mode too ... there is a nice open source code with Nokia 5110 LCD support and 6ch ...

There are tons of opportunities ... but so far nobody did integrate NRF24 into MultiWii ... it is feasible ... but the range will be very disappointing ... so nobody did care much about it.

nguoihn
Posts: 9
Joined: Sat May 31, 2014 12:11 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by nguoihn »

Ok, i understand, thanks you.

But there are one thing I didn't understand: the final purpose of these communication is passing the "throttle, rudder, yaw, aileron" from the transmitter to the the multiwii code, there must be somewhere the part of code that read these information, right? If it is true, why implement new ways of communication is that complicated? Why don't we just make a function like "read_radio(throttle, rudder, yaw, aileron)" and we can do whatever ways of communication we want?

I did succeeded of making 2 arduino pro mini talk to each other, now I need a computation code, with pid, data processing from MPU6050, and I chose multiwii, but the code is huge, i thinks it's a bit overkill for me then... Do you know a simpler ways to archive that?

Btw, a bit off topic, I want to ask if you know how to remove the resort from the joystick module to make a diy tx? I don't want a throttle that come back to center each time.

Thanks for listening.

e_lm_70
Posts: 297
Joined: Fri Aug 09, 2013 8:35 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by e_lm_70 »

On multiwii .. all you need to do for integrate your own RX system is:
- Been able to run your RX code without stopping (for too long) the interrupts ... else serial communication will not work anymore.
- Been able to run your RX code without causing a big change in the cycle time of multiwii ... else the IMU stabilization may not work well
- Finally ... you just need to feed the array -> rcValue ... with your RX code .. and disable anything around from the original MultiWii PWM/PPM RX code ...

Very simple to say ... but does need quite some work

I did hack my own RX in MultiWii ... but never for NRF24 integration ... so ... I know it quite some work to be done ... a work that I have no interest on spending my time.

Other thing .. you need to check that the PIN involved for handle NRF24 are not used by basic function of multiwii ... else you need to remap these functions to new pin ... I know already this "pain" ... since I did move MultiWii 2.3 over KK2.x .. doing a total pin remapping ...

About resort ... normally there is a spring that force a joystick to go back in the center .. but if there is a different mechanical force for place back in the center ... it could be more hard to find a solution to it ...

I'm not trying to demotivate you .. but you have a lot of work , and you need to be a pioneer too on it ... but tallest is the mountain to climb .. and highest is the reword that you get once you are on top of it ...

nguoihn
Posts: 9
Joined: Sat May 31, 2014 12:11 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by nguoihn »

OK I understand,

I'll try to just take the codes of reading gyro and make my own code for the computation PID.

Thanks you for your help.

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by humblehacker »

I was just thinking about doing something very similar! I really want to try the original Multiwii config with Wii Motion Plus and Arduino but would rather leave out the proprietary Spektrum RX/TX I'm using on my NanoWii.

Concerning the NRF24 - Have you ever looked into the Crazyradio (http://wiki.bitcraze.se/projects:crazyradio:index)? It was created for use with the Crazyflie Nano Quad and uses an NRF24 variant that connects straight to a USB Port allowing the miniquad to be controlled from a Desktop GUI and gamepad controller. Its even possible to connect it to a Raspberry Pi or Android! I was thinking about that the other day since my phone now has a Crazyflie AND Multiwii GUI and I was wondering how easy it would be to combine the two.
Both the CF and Crazyradio are open source and the Devs have done a good job documenting how to hack the firmware at http://wiki.bitcraze.se/projects:crazyradio:protocol. Unless one is planning to reflash the Crazyflie itself with Multiwii (and I can't imagine why one would want to) then the real question is whether or not the Crazyradio can communicate with a standard NRF24 Transceiver. If that works then I don't see any reason why you couldn't use a standard Gamepad with the MW GUI in a similar manner to the current CFClient. Especially if you use the Processing version, it should be considerably easier to modify then the current CFClient which uses QT I think.

mirots
Posts: 1
Joined: Tue Aug 12, 2014 8:17 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by mirots »

Hi guys,

I am interested in this kind of integration as well, I have pretty decent background, but not so much time.
Here is an interesting database of off-the-shelf models and quads, part of which are already using NRF24 for control - https://docs.google.com/spreadsheet/ccc ... ring#gid=0

I think it might be a good idea to reuse V2X2 protocol, which is used on WLtoys V262 quad for our purpose. This way we would be able to make use of existing cheap TX modules - http://www.banggood.com/WLtoys-V222-2_4 ... 78480.html

This should not be hard, I already wrote an Arduino library for RC TX module based on a7105 which is SPI as well (and very similar to NRF24), http://www.cloud-rocket.com/2014/07/fly ... uadrotors/ (my blog). I reused some code from http://deviationtx.com/ project (Devo open source Transmitter). Devo is supporting NRF24 as well (for controlling WLtoys), so we might reuse their code as well.

What do you think?
Meir Tseitlin

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by humblehacker »

Very interesting! I see the Crazyflie is indeed listed as using NRF24L01 as I suspected. Again, the CFlie could come in very handy if even just for comparison purposes since the code, including the deviation protocol is all open source. If anybody's interested, I have a CFlie and a dedicated Virtual Machine they provide for developers if there are any tests I can run.

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by humblehacker »

See this guys project on Youtube-http://youtu.be/2X9AdNUApqw

iforce2d
Posts: 3
Joined: Tue Nov 18, 2014 8:32 am

Re: nRF24L01 - 2.4GHz Radio integration

Post by iforce2d »

Hello! That's my video there. I thought I should just point out that I have not changed any Multiwii code to do that, so it's probably not really what the original intent of this thread is about.
I use a second arduino (pro mini) to talk to the nRF24L01 and give PPM output to the flight controller. This lets me use it with multiple quads with different flight controllers, eg. CC3D which was what I originally started with.
It also gives you another controller to do stuff like retracts, lights, gimbal control etc, without interfering with the already very busy Multiwii code.
Recently I got a Multiwii board and tested running the nRF24 with it directly using software SPI. The radio connection seemed to work alright but was a bit slow, and I did not try putting it together with the Multiwii code - as mentioned above it most likely would not fit in flash memory of a 328p, and it's not as convenient as the PPM-via-second-arduino method.

Some other points I can add that might help, are that you will definitely need a PA version of the nRF24 for the transmitter, and powering it properly can be a nuisance. I tested the PA version with a whip and a cloverleaf antenna, and each seemed to get roughly the same range, pretty good up to about 350m with line-of-sight, with the receiver being a PCB antenna. However, since then there have been some strange cut-outs where it seems the signal does not get through even at short range, and I don't feel I can completely trust it, especially after today. I just spent 1.5 hours sitting in a dense bamboo thicket, waiting to hear my low battery alarm go off, if you know what I mean. I don't really know what the problem is, but I have noticed that attaching the antenna often causes the connection to become very poor - I'm guessing that having the antenna pushes the power requirements up to a point where... uh... something... cannot cope. I also have an RX antenna to match the cloverleaf, so sometime when I get another nRF24 with an antenna attachment, I'll see how good the range is between those. For now though, I'm keeping to within about 80m distance.

I am part-way through making a series of videos showing a budget DIY build, using the same radio methods that I did for that video, but with a Multiwii board this time. I'll post here again when I upload the videos.

iforce2d
Posts: 3
Joined: Tue Nov 18, 2014 8:32 am

Re: nRF24L01 - 2.4GHz Radio integration

Post by iforce2d »

First video is up: https://www.youtube.com/watch?v=YPtxHw3DWrg
Others will be uploaded sometime in the next couple of weeks :)

iforce2d
Posts: 3
Joined: Tue Nov 18, 2014 8:32 am

Re: nRF24L01 - 2.4GHz Radio integration

Post by iforce2d »

okay, a couple of months have passed, and this time I can say I have actually modified the MultiWii source code to do this.
You can find the details and link to source code at this video: https://www.youtube.com/watch?v=bxlJckevIEk

There are of course some limitations (four motors only etc) that limit the use of this, but it's great to have real-time telemetry of all data that the MultiWii code knows about.

humblehacker
Posts: 46
Joined: Thu Aug 07, 2014 6:40 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by humblehacker »

iforce2d wrote:okay, a couple of months have passed, and this time I can say I have actually modified the MultiWii source code to do this.
You can find the details and link to source code at this video: https://www.youtube.com/watch?v=bxlJckevIEk

There are of course some limitations (four motors only etc) that limit the use of this, but it's great to have real-time telemetry of all data that the MultiWii code knows about.


Wow! Great Work! I can't believe I missed this until now! This could potentially open up a lot of fun connections with other projects. The first thought I had was whether or not this would work with the Hobbyking "Pocketquad", which is basically an ATMega32u4 circuit board with mini brushed motors attached. It currently uses a small Spektrum Satellite RX but it would be a great candidate for an NRF24. It even has the SPI pins broken out for programming the bootloader (though I'm not sure if it would match up perfectly...) The other advantage is you could use a standard transceiver module since it likely won't require long range reception. It is 3,3v however and it isnt a 328 so some modification might be needed.

My next thought is something I have mentioned earlier in this thread... The Crazyflie Nanocopter is another tiny copter about the same size as the Pocketquad. It uses an NRF24 RX/TX by default and the included "Crazyradio" TX is actually an NRF24 with a PA antenna and USB input. This allows it to be controlled from a Python GUI on a Desktop or an Android App via a connected gamepad in lieu of a dedicated Radio Transmitter. NR24 in MultiWii would allow the Crazyflie to be controlled from the MultiWii GUI or the Pocketquad to be controlled from the Crazyflie GUI.

Lastly, OpenLRSng has been getting a lot of attention lately and there's a DIY build making the rounds that can use the NRF modules. Again, testing it with a pocketquad first would allow for fine tuning without worrying about range/power issues...

I'm going to give your code a shot on the Pocketquad... I'll let you knnow how it turns out!

c128
Posts: 17
Joined: Tue Apr 07, 2015 2:34 pm

Re: nRF24L01 - 2.4GHz Radio integration

Post by c128 »

i make new pcb schield for arduino uno with nrf24l01 + standard usb host shield and joystick logitech pro

is working with arduino mega and multiwii

https://www.youtube.com/watch?v=OpTypWmU9sY

Post Reply