Introduction: NRF24 Two-Way Radio for Telemetry

About: I'm an Eleventh-Grade student from the Sates living in South America. I love robotics, drones, Arduino, circuits and building things. I hope my Instructables are useful to all of you!

Hi guys, my name is Pedro Castelani and I'm bringing you my first instructable: building a two way radio with arduino for, well, whatever you need it for.

In this project, we will make two seperate circuits which will act as both reciever and transmitter. The most important components are two arduino boards (all of them work) and two nrf24 transciever modules. In my case, I control a servo with a potentiometer from the other arduino and send the voltages of a two cell lipo battery back to the first one.

I intend to use it as an add-one for my drone, which does not possess telemetry nor servo gimbal control. You can, however, use it for other things, such as building your own quadcopter, plane, rc car, etc. From the code supplied you can also make any modifications you want according to your needs. I will also try to explain how to modify it correctly (which took me some time to learn by myself, as I was accustomed to another kind of use for the nrf24 chip).

Step 1: Materials

To begin our project, we need to know all the parts needed. Below is a list of the basic ones needed. I bought most of them at a local electronics shop where I live, so I wont be able to recommend you any place to buy them. You could try Amazon, or any other place. I am not saying you should order them there, but its just a suggestion.

  1. Two Arduino boards (anyone should work. I have two arduino pro mini, which I like a lot because they have 13 digital pins and 8 analog, while the Uno only has 6 analog ones).
  2. Two Nrf24 modules. There are some with external antennas which have greater transmission range. Choose the ones you most like.
  3. Female-Female and Female-Male jumper cables.
  4. Prototyping board.
  5. Arduino Programmer (for arduino pro mini, if you have one with usb connection you wont need it).
  6. Arduino IDE (Software). Download from here.
  7. In my case, I also used:
  • Servo. Anyone you can get. I like the SG90, a small one designed for arduino.
  • Potentiometer (between 10k and 20k ohms). Can be bought at a local electronics shop or you can use the joystick made for arduino. There are a few images of the ones I have. I also got one from a broken drone rc controller, just to give you a few ideas
  • 4 equal normal resistors. I used 10k ones I got from my grandfather's house. I am using them as voltage dividers.
  • Small copper pad perfboard (which I also got from my grandpa) for soldering the resistors together.
  • Pins. Used to connect the jumper cables from the arduino to the resistors easily.
  • 2s lipo battery. I use it to power one of my arduinos. The resistors are connected to it and read its voltages. I intend my arduino to be connected to my drone's 2s battery, since it wont need an external power source and at the same time tell me how much battery is remaining.
  • Soldering Iron and solder. Needed to solder the resistors, the perfboard and the pins together.

Step 2: Function and Code

Once all the materials have been mentioned, let's start talking about the function of the modules.

  • How it works: Lets call one arduino "A" and the other one "B". In my case, after programming both, I connected them to their corresponding radio chip and added the potentiometer to arduino A and the resistors and servo to arduino B. Module A sends values to B and moves the Servo. B reads the voltages of the 2s battery and sends them back to A. Then the whole circle begins again. Since A recieves values that are not expressed mechanicaly, it is connected to the programmer, through which we can read them with a serial monitor (included in the Arduino IDE).
  • Code: I call the sketch for arduino A (connected with the programmer and the potentiometer) TwoWayRadio_1, and the sketch for arduino B TwoWayRadio_2WithServo.

TwoWayRadio_1 and TwoWayRadio_2WithServo can be found just below this paragraph. There is an explanation inside each code just to make everything easier to understand.

Step 3: Soldering Modules: Voltage Divider and Potentiometer

This step is optional, since you might just want to use the potentiometer-joystick designed specifically for arduino and use another module instead of the voltage divider. I, however, planned everything (codes included) for these modules.

  1. Potentiometer:
  • This part is just about the easiest one in the soldering step. You will just have to solder some jumper cables to your potentiometer. If you want, you can first solder the potentiometer to the perfboard and then solder some of the pins. When you need to use it, just connect the jumper cables to the arduino and then to the pins on the perfboard. When not in use, you may remove the cables and use them for another project. If, however, you do as I did, you can leave the potentiometer soldered directly to the cables.
  • If you are doing as I did, get three female-female jumper cables, cut of one of the tips and remove the insulation there, leaving a small piece of copper wiring on each wire.
  • Heat up your soldering iron and solder the modified jumpers to you potentiometers pins. If you can, try to get different colors so that you can remeber which one is vcc, gnd and the "signal" one (the middle one). Connect these cables to the corresponding analog pins on the arduino. There are some images at the beginning of the step on how it ended looking. The potentiometer is not a regular one, it is actually a small wheel which had five pins. Took me some time to find out which was which. Try to do it easier and use a regular potentiometer as shown in the MATERIALS step.
  • If you are soldering it to a perfboard, get the potentiometer and the perfboard and solder them together with your soldering iron.
  • Get the pins (three) and place them in the most convenient way. Use solder to make a connection between each pin and the potentiometer pins. Do not make a connection between more than two pins or it will not work (it will act as a short circuit).
  • Get some female-female or female-male jumper wires and connect them from your arduino to your new potentiometer module (remember which is which).

2. Voltage Divider:

  • This part is a bit more complicated. You will need to get the four resistors, five pins and the perfboard. I designed the code to be used for a 2s battery (two cell), but you could also use it for a 1s by changing the arduino sketch a bit and the hardware. I included pictures of two voltage dividers I made, one with only 2 resistors (for 1s batteries) and one with four (you guessed it: 2s batteries).
  • Let's start with the 2s one. I do not have images of the building process since I started witing this instructable a good while after having finished soldering it. I do include images of the final result, so I will try to be as clear as possible.
  • Start by getting the perfboard and 5 pins. Solder them close to the side and do not let them touch each other.
  • Solder the resistors as shown in the last image at the start of the step (the small circuit diagram). The connections between each resistor and pin is made with solder. Try to occupy the least space possible.
  • When you are done, it should look something like the pictures of the finished voltage divider I posted above.
  • The 1s Voltage divider is basically the same, with the exception that you only use three pins and two resistors. I included images of how it looks when finished. Just look at the diagram for the 2s one and imagine it without the signal wire 1, the middle wire, and resistors r2 and r3 and there, you have it!
  • So, if you want a 1s voltage divider, it might just be a little more complicated than just using a 2s one.

Step 4: Programming Your Arduino

  1. We are almost finished!
  2. After having downloaded the Arduino IDE software from the site linked in the MATERIALS step, download the sketches from the FUNCTION AND CODE step.
  3. Next, open them in the Arduino IDE.
  4. Open "Tools" in any of both tabs and click "Boards". Choose your board from the list. Click "Processor" and then "Programmer", selecting each one according to your board. Then return to the sketch. It is quite convenient to look the information of your board on the Internet. Just look up the name and see the specs.
  5. Click on "sketch" (up top), then "include library", then "manage libraries". A small window should open at the center of the screen. Enter in the search option "rf24". Download the library you want. It will be necessary to be able to upload the code to the arduino board.
  6. Just to make sure, click on the "Tick" symbol (up left) to verify it does not have any mistakes. Then proceed to upload it by pressing the arrow pointing to the right, beside the "Tick" symbol.
  7. If your board is a Pro Mini, I will explain in a while how to connect everything. If it is not, just upload it and, when finished programming both arduinos, pass to the next step, after reading the warning below.
  8. Since you have two boards, REMEMBER which code each was programmed with, to avoid any future problems.
  9. So, if you have a Pro Mini, you will need a programmer. There are two kinds of programmers: 5 pin and 6 pin ones. I will focus on 5 pin ones since they are the ones I have. The connections are as followed (first pin is from programmer, then arduino): Gnd--Gnd; 5v-Vcc (except if your Pro Mini is a 3.3v, in which case it is 3.3v--Vcc); Rxd--Txo; Txd--Rxi. I included an image of both board and programmer, just in case you need to check.
  10. Connect your arduino to the programmer and the programmer to your computer. Open the IDE and click the upload button. If you look at the left bottom of the screen, you will see a message that says "compiling". The moment this message turns into "uploading", press the reset button on the arduino Pro Mini. After a while, the sketch will finish and a message will appear saying "Done uploading". Once this happens, you are done and ready to pass to the next step.

Step 5: Connecting Everything

  1. After having programmed both arduinos, we need to connect everything to get it work. Here we are going to need everything mentioned before: the arduinos, nrf24 modules, cables, servo, programmer, voltage divider, potentiometer, etc.
  2. We are first going to connect the arduino which works with the programmer. At the beginning of the step are the images of the connections of the nrf24. The irq pin, which is said to go to pin 8 on the arduino, is not connected at all. The rest is just as in the image for both arduinos (you can read the notes inside the images for more info)
  3. The Vcc for the radio may be connected to 3.3 or 5v. Sometimes it only works with one of them. Try with 3.3 and then 5 if it wont work. For 3.3, use the 3.3v pin o the programmer. I had to do this, as you will see in the images of the finished product.
  4. Connect the programmer to the arduino as said in the previous step.
  5. Connect the potentiometer's "signal" cable to analog pin A0.
  6. Connect the potentiometer's "Positive" to Vcc (only 5v, not 3.3) and "Negative" to Gnd.
  7. Pass to the other arduino.
  8. Connect the radio as said before, according to the images.
  9. Connect the servo's signal cable (orange-yellow-white. Check the specifications for the servo) to digital pin 2, and its gnd to the arduino's Gnd, and its positive to the arduino's Vcc.
  10. Connect signal cable 1 from the voltage divider to pin A0 and signal wire 2 to pin A1.
  11. Connect, using the protoboard, the voltage divider's negative cable, the arduino's gnd and the battery's gnd (black cable on the jst plug).
  12. Connect the "middle cable" from the voltage divider to the battery's middle one, between the red and black cables of the jst plug (white color).
  13. Connect the 'positive" cable from the voltage divider to the battery's positive terminal and to the arduino's Raw. Do not connect directly to Vcc, since this pin is specifically for 5v. Raw pin uses any voltage above 3.3 or 5v to 12v and regulates it. Vcc pins then become outputs with 5v.

Your almost done! Your finished products should look as the images above. Recheck every connection to avoid short circuits.

Step 6: Power Up Your Project

  • Your arduino with the servo got powered the last step when you connected the battery to the whole circuit. So, you just need to connect the other arduino to an usb port and you are finished!
  • Move the potentiometer and you should see how the servo also moves. In my case, the servo is attached to a 1 axis camera gimbal, which limited the angle, so I had to adjust the parameters. You will find that in the code, anyway.
  • To see the voltages, once you have connected the programmer to the computer, open the arduino software and press "Ctrl+Shift+m". A window which says "Serial Monitor" will open. At the bottom of this window is an option which reads "(number) baud". Click on it and select "9600". Close the monitor and open it again by pressing the same keys and you should start seeing a lot of values coming in. You will not be able to see what these values are because of the speed at which they are coming, but if you disconnect the programmer they will stop and you can read them. I am trying to get something with which to automatically graph them to view the voltages or represent them with leds, but that is still in process.
  • Even though you might not see the values clearly, since they are passing so quickly, just know that it finally works and that you can modify it to accommodate your needs!

Step 7: Demo

Well, this is the video of me powering it up and using it just a bit to show you how it should work.

Step 8: More Ideas on How to Use This Project

Here are some ideas which you can build using this as the base. Tell me if you make one of them or if you try and cannot so I can help!

  • Instead of reading voltages, modify the code so that it sends back the temperature, pressure, height, etc. I found the BMP180 chip quite useful for this.
  • Measure distances with the HC-SR04 module and send them back to the first arduino. Use the servo to point the sensor anywhere you want.
  • Add another servo channel to move a camera up and sideways; for example, on an rc car.
  • Add three other servo channels (or more!) and make your own rc transmitter and receiver for a quadcopter, airplane, helicopter, rc car, etc!
  • Change the servo for a searchlight and add it to your drone! You will also be able to control the intensity of the light (might need some transistors and some code changing)
  • Instead of reading the voltages on a computer, get creative and add an lcd module, or you can make a 6-led board (two green, two yellow and two red) which will turn them off one by one as the battery gets lower and will start flashing when the battery level drops below your chosen voltage. I made this small board and posted an image at the beginning of the step.

Just to make everything clear, if you are going to make one of these projects, have in mind that you are going to have to modify both codes and maybe some connections. Please try to remember not to fry your board doing something stupid.

If you have anymore ideas or need help carrying one of these projects out, please post in the question section!

Step 9: Troubleshooting

To say the truth, most of the problems I have encountered so far were related to the sketch part, which you already have solved. I will try to tell you as many problems as I can in order to help you the most.

  • First, if you are trying to upload the sketch and you cannot, try this:

Make sure you downloaded the necessary libraries (and the correct ones!).

Make sure you have chosen the correct board, processor and programmer.

Make sure the connection between the pc and the programmer and the programmer and the arduino is good.

If you are using a pro mini, try pressing the reset button as soon as you can after the "uploading" message appears.

All these things are spoken of in the PROGRAMING YOUR ARDUINO step.

  • Second, check all the connections between everything:

If your arduino does not power up, it is clearly a voltage problem. Check if the cables are not connected properly and if there is a short circuit.

If it does power up but does not function, make sure all the connections are where they should be, that the arduino programmed to be connected to the servo and voltage divider is really connected the them (in other words, make sure you did not mix them up), try pressing the reset button on both of them and see what happens. In extremely rare cases, the whole blame can be on the NRF24 module. I found one of mine that only works on 5 volts and another that works only on 3.3v. Check if this solves anything. It also happened to me that only one arduino worked with the 3.3v radio and the other one only worked with the 5v one. Surprising, isn't it?

  • Third, if you can move the servo but the voltages are wrong, check the connections to the voltage divider are as in the diagram in step 3, and the connection to the arduino. If, on the other hand, you get the voltages but you cannot move the servo correctly, check the potentiometer and its connections, the servo's connection to the digital pin and to the Vcc and Gnd, and if the servo is stuck, broken or in a short circuit. Try changing it with another servo. Make sure the digital pin is the same as the one specified in the code.

Well, those are just about all the things that could come to my mind about the problems you might encounter. Hope they never happen and Happy Projects!

Thank you for reading my Instructable! Please share and vote it for the FIRST TIME AUTHOR Contest!

First Time Author

Participated in the
First Time Author