Introduction: Personal One Way Radio Using Arduino Transmitter and Receiver Modules

Human communication ability has been one of the greatest human achievements in recent human history. To be able to interact with people around the instantaneously has changed and revolutionized the way the world operates. Not only has human interaction been changed drastically, but the way we now see technology has changed because of advances in communication.

Today we all have the ability to instantly access GPS services by communicating with satellites in space. This gives each us how access to get to anywhere around the planet if as long as we have the address or relative location of where we are going.

Leaning objectives:

This is going to be geared toward improving the Standard of Technical Literacy of High School students.

This lesson is going to teach you how to get two different Arduino modules to communicate with each other over a short distance using 433mhz radio transmitter and receiver modules.

Supplies

All prices listed below are based on the average cost per unit.

2 Arduino Uno REV3 - $23.00

2 LEDs - $0.60

1 Push-button - $0.23

3 220 k omh resistors - $0.87

Packet of male to ale jumper wires - $3.95

(note: Wires can come at different lengths and can be used interchangeable based on personal preference)

433 mhz transmitter module - $4.95

433 mhz receiver module - free

(note: receiver will come with transmitter)

USB 2.0 cable Type A/B - $6.28

External power source - $10.99

(note: optional if preferred or needed)

Step 1: Breadboards Explained

Be sure to pay close attention to the pictures above when going through this lesson as they will contain a lot of visual information that will make the process a lot easier. Knowing how to work with breadboards is going to be critical in understanding how to wire the transmitter and receiver modules to the Arduino.

The breadboards that we will be working with essentially have two main components, power rails and component rails. Power rails do exactly what the name implies that they do. They deliver power up down the breadboard using the two vertical rails on the outside of the breadboard. The rail that is marked with a "+" symbol is meant to deliver a positive charge of any kind to the board. For the project that we are working on we will only be using a positive 5 voltage charge, more commonly written as 5V. The rail that is marked with a "-" symbol is meant to deliver a negative or ground charge to the breadboard. I won't be using this rail in this demonstration, but to use it a wire simply needs to be connected from the ground (GND) header on the Arduino to this rail.

The component rails are where most of the hardware will actually be connected to. Because these rails run horizontally down the board they are usually referred to by column number. When electricity is flowing through a wire and it enters one of these component rails, anything else touching that rail will also receive the same electric charge that flowed into the rail. That means that if we want to connect to components together, we just need to attach them to the same column on the breadboard.

Step 2: Wiring Reciver LED

This LED is designed with one wire longer than the other wire that is coming out of it. This is an indicator that lets us know which side is the anode (positive) and which side is the cathode (negative). My LEDs are set with the longer side acting as the anode and the shorter side acting and the cathode.

I'm going to start by inserting the LED into the breadboard first with the anode side in column 2 and the cathode side in column 4. Now because we are running 5V through this LED, we will need to include a 220 ohm resistor to make sure that we don't damage the LED. If we didn't then the voltage would be too high for the resistor inside of the LED to handle and the LED would not be able to function properly. I'm going to connect the resistor to the cathode of the LED in column 4. From there, I'm just going to finish the end of the circuit by connecting the other end of the resistor to column 7 and run a wire from column 7 to the ground (GND) header pin on the Arduino.

Now in order for the LED to be turned on only when we want it on, we need to plug it into one of the numbered ping headers that is on the Arduino board. It doesn't really matter which one you plug it into, for this example I am going to connect the anode side of my LED in column 2 to pin header 7 on my Arduino board. This way when we are programming the Arduino we will be able to turn on pin header 7 to supply %V to the LED and then turn it off when we want.

Step 3: Wireing Reciver Module

Still working with the same breadboard and Arduino, we are going to now install the receiver module onto the breadboard. You can start by inserting the breadboard into the bread with each of the four pins in a different column. I chose to use columns 17 through 20 on the side not being used by the LED. There is not a specific reason for this; you only need to make sure that you are using columns that are not already in use by something else.

On the back of the module you notice that there are 3 main parts to the receiver. On one side is the VCC pin that is responsible for delivering power to the module. In contrast, the ground (GND) pin on the opposite side is responsible for closing the circuit to and will be connected to the GND header pin on the Arduino board. The two pins in the middle are the data pins that will send the received signals back to the Arduino.

Starting with the power for the receiver, I'm going to connect the VCC pin to the 5V header pin on the Arduino using my yellow wire in column 20. I'm going to use my blue wire to connect with the GND pin in column 17 and connect to any of the GND header pins on my Arduino. Now, I don't know exactly why, but even though there are two data pins on the receiver, they should be treated as if they were on an individual pin. This means that you can connect the Arduino to either of them and have no problem getting the message from the receiver . I choose to connect my green wire to the data pin in column 19 and run it back to pin header 12 on my Arduino board.

Step 4: Transmitter Wiring Overview

Before we get started on the transmitter I wanted to show what the final result of what this Arduino and breadboard connection will look like when we are finished working on it. It will take more wiring than it did to set up the Arduino because we will be adding a button to this side so that we can control when the transmitter will be sending a signal.

Step 5: Wireing Transmitter LED

Start by going ahead and getting your second breadboard and Arduino out so that we can begin wiring them.

We will first wire the LED because it will be the exact same steps that used to wire the LED for the receiver side of the Arduino. Starting the same way we will place the longer Anode in column 22 of the bread board and the shorter cathode in column 21 on the breadboard. I'm going to connect the Anode in column 22 to pin header number 7 on the breadboard (I accidentally placed it in the wrong position when I was taking the picture). I'm again going to include a 220 ohm resistor to the cathode side of the LED in column 21 and put the other side of the resistor in column 17. From the column I'm running my yellow wire to the GND header ping on the Arduino to complete the circuit.

I also want to use this moment to talk about an orange looking wire that is linking the positive power rail to the 5V pin header on the Arduino board. What this is doing is basically I am allowing a 5V charge to go into the power rail so that anything else that gets connected to that rail will receive 5V. For example if you take the purple wire that is connected to the anode side of the breadboard and plug it into the positive power rail at this point the LED will turn on if it doesn't that might mean that you have the LED facing the wrong way and need to turn it around.

Also it doesn't have to be done in this step but I went ahead and put the button on the breadboard as well so you can start to see what it will look like when it is finished.

Step 6: Wireing Transmitter Button

Now there are different ways to attach a button to the breadboard, but I have found that the most reliable is to split the button over the two sides of the breadboard to reduce the chance of noise and electrical interference occurring. If you don't know which orientation the button needs to be in when you put it on the breadboard you can either a multimeter to measure which way the current is flowing when the button is pressed and if you don't have multimeter then generally the side of the button that looks a little longer is meant to reach over the median on the breadboard.

With the button in place the wiring is very slimier to the LED. Start by connecting the right side of the button to a 5V power supply. Lucky for us we charged the positive power rail with 5V in the last step so we will just use a short wire and attach it to that. On the other side of the button I am going to attach a resistor that is equal or greater 220 ohms to one of the spaces in column 27 that I am working in. the other end on that resistor will be attached to column 22 with a wire that is run to the GND header pin on the Arduino board. The purpose of this part of the circuit is to ensure that the Arduino is not reading a floating charge while the button is not being pressed, but is in fact reading a voltage of 0. finally, to ensure that the Arduino will be able to tell the button is pushed. We are going to attach a wire from column 27 to pin header 8 on the Arduino board.

Step 7: Wireing Transmittiter Module

The last thing that we are going to wire is going to be the actual transmitter module that will be sending the signals to the receiver that was made earlier.

Similar to the receiver module the transmitter module also has three main pins. When looking at the front of the transmitter the left most pin is the data pin written as ATAD which is data written backwards. The middle pin is the VCC pin that will receive power for the module and on the left in the GND pin that will be connected to the GND header pin on the Arduino. First I will connect the data pin to pin header number 12 on the Arduino. Next I'm going to connect the VCC pin to the positive power rail that already has 5V running through it. Finally, I'm going to connect the ground GND pin of the transmitter module to the last remaining GND header pin on the Arduino board.

Note here that if we had to add some other type of circuit to the breadboard we would need to connect the GND header pin on the Arduino board to the negative (-) blue power rail rather than attaching the the GND pins directly to the Arduino board.

With this we have fished setting up all of the hardware that we will be using and will now move into the programming phase of this project.

Step 8: Downloading Radiohead Library

If you don't already have the Arduino programming software on your computer you can get it straight from the Arduino software website and download the zip file for free.

In order for us to be able to use these Arduino modules and to help us save a lot of time we are going to first download a library that will contain some of the code that we will be using so we won't have to write it. The easiest way to accomplish this would be to use the manage libraries tab that can be found under the sketch tab and by going to the include library pull out menu. Once you click on manage libraries, another screen will come up that will allow you to see what different libraries are available to install. We will be using the radiohead library so we will search for it using the search menu in the top right corner of the screen. As you can see on my screen though, nothing comes up from the search that I did meaning that radiohead is not available for me to download from this source.

To get around this I am just going to do a google search for radiohead that is associated with Arduino. Once I open the link that google found, I am taken straight to the radiohead website that has a bunch of information about how this library operates. you can read more if you are interested in the software, but we will be using the first link that is on the website to download the zip file that we need.

Step 9: Installing Radiohead Library

Once the radiohead library has been downloaded onto my computer, we will be able to use the software that comes with the Arduino software to unzip and move the folder into our library folder.

Again, we are going to open the sketch tab and then go to the include library pull out menu. Once that is open click on the include Add .ZIP Library link to open a search browser for your computer. using this browser go to wherever you downloaded the radiohead zip folder and open it.

At this point the, the radio head library should now be in your library for use. To check this go back to the include library pull out menu and scroll down until your see the radiohead library in this menu.

Step 10: Writing Transmitter Code

We are going to start the coding process by working on the transmitter code first.

Lines 1 and 2 are there just so that we can call the radiohead library to let the Arduino program know that we will be using that. Next we are going to create a global constant variable, meaning variables that can only be one thing, based off of the pin headers that we used to wire the pin header. This may be different from your wiring, but my LED runs to pin header 7, my button runs to pin header 8, and my transmitter module runs to pin header 12. In line 8 we are going to start the driver and the transmitter using the four conditions separated by commas. The first is to set the transmission rate to 2000, next we are going to set the receiver condition to 12, then we're going to assign the transmitter condition to tx_pin, and finally we need to include a value 10 at the end even though we will not be using this condition. The reason that we set the receiver condition in the driver to be 12 is because we aren't using a receiver on this Arduino since we are only doing one way communications. When this happens we are allowed to set both the transmitter condition and the receiver condition to the same pin header so that we can save a pin later if we need it.

After this we are going to move into the main setup of our function where we start calling most of the things we will use. The first is to start the serial monitor so that we will have an easier time debugging the code after we upload it. We are going to set the speed of the serial monitor to 9600 which is just a standard speed that doesn't put too much extra pressure on the Arduino. Next we are going to program the pin header for the LED and set it to be an input so the Arduino can read the whether or not the button has been pushed. After this, in line 14 we are going to call the driver to initialize and if it doesn't work the Arduino will tell us that in the serial monitor.We can now also program the pin header for the LED to be an output so that it will turn on when we activate that pin header. To make sure that we are starting with the LED off we are going to use digitalWrite to set the LED to LOW which means 0 volts. Lastly we are going to print in the serial monitor that the transmitter is now working as is ready for use.

So in line 23 we are going to start working on the loop that will make the same code run repeatedly until power is lost from the system. Right after that we are going to write out the code that will contain the message that we want to send. Because we are sending a message that is not a number we need to put it into a char so that the Arduino can read it and send it. Now, because we only want to transmit a signal when the button has been pushed, we need to include an if statement that prevents code from being executed unless the Pin header from the button is read as high meaning it reads a 5 volt charge.

When the button has been pressed I decided that I wanted the serial monitor to tell me by printing out loading so I can see that the button works. Then the transmitter will send the signal in line 28 and before the code goes any further we are going to wait for the message to be sent in line 29. Then we are going to turn the LED off again (for the first iteration this is kind of pointless , but i will come in handy for every iteration after). Then between every message sent I want the Arduino to wait 300 milliseconds before sending another message and close the if statement.

After the if statement, the LED light will turn back on so that anytime the button is not being pressed the LED will be on and when the button is pressed the LED will turn so we know the message is sent.

Step 11: Writing Reciver Code

When writing the receiver code, we are going to again start by calling the radiohead library so that the program knows we want to use it. Then we are going to set global variables again based on the pin headers that we used. After that we will start the drive again with the same conditions. Note that this time the transmitter condition is the number 12 while the receiver condition is now the one with a constant variable in it. In the setup, we are again going to start the serial monitor with the same speed of 9600. We're also going to set the LED header pin to be an output so that we can turn the LED to turn on and off when we want. Then we are going to again initialize the driver using an if statement and if it does not work then the serial monitor will tell us that the driver did not work. After all of this happens, we want the serial monitor to print out again that the receiver is now on and ready to receive messages. In the loop that will be running over and over, we are going to start by creating an unsigned 8 bit integer array so that we will use it to store the message in line 24. Right below that we will also create a variable that automatically determines the size of the integer array. The if statement in line 27 will only be activated when a message is received, meaning when the button on the transmitter size is pressed. When that happens and for as long as the button is pressed everything in the if statement will be included in the code that the Arduino will be processing. I'm going to create a new variable that will be used in the for statement below right after the if statement.

With regards to the for statement that starts in line 31 and ends in line 36, I wanted to note that this is not a part of the required code that will help with turning the LED on or off in any way. This sequence of code is meant to take the message that we are sending by the transmitter and print it to the serial monitor with its normal letter format and hexadecimal format. For any other gadget I would not do this because it would only take up more lines of code meaning that I am also taking up storage space on the already limited microcontroller. Luckily this particular example is small enough that not much space is being taken up so there is no problem with leaving it in.

After the for loop, in line 38 we are going to flash the LED by using the command true for the LED pin header. I also want to print out that the message was received by the Arduino to the serial monitor so that I can see it was received. Then I will wait 100 milliseconds before turning the LED back off again.

Note here the true and false could be replaced with HIGH and LOW is that is simpler to write out.To finish this code we are going to close the if statement as well as close the initial loop that we were working in.

Step 12: Uploading the Code

Once all of the programming has been done, we will need to upload our code to the Arduino microcontroller. First, go ahead and plug in the Arduino to your computer using the two USB type A/B wires. If your computer only has one USB type A port, then you will have to upload your codes one at a time and power either the transmitter or receiver with your external power source plugged into the other port of the Arduino. If you will be using two USB type A/B wires then you will be able to unload and power your Ardunios directly from your computer.

To start the uploading process all you need to do is click on the arrow in the top left corner of your screen. If you get an error message pop up it will be because there was some sort of error in the code that you wrote that the software caught while it was in the verification process of the upload the most common error that I receive when I am coding is that I will forget to include a semicolon somewhere in the code. Make sure you carefully go through the code to make sure you didn't do this.

Also when you will be switching between the two different Arduinos make sure that you don't forget to switch the port that the code will be uploading to. you can access this function by going to the tools tab, going to the port pullout menu and selecting the proper port.

If you can't figure it out by looking at your computer screen, when you upload the code properly the yellow LEDs that are on the Arduino will flash to show that the code was received.

Step 13: Testing the Code

At this point the, both Arduinos should now be on with their proper codes installed. Once the transmitter LED turns on, push the button on the transmitter breadboard and watch as the LED on the receiver starts to flash on and off.

With the information that you have learned in the lesson you will now be able to construct and send messages using your new one way 433mhz radio transmitter. Try playing around with the code and see what else you can do with these messages. If that becomes too easy, try to figure out if you can set up a two way transmitter on your own by adding in another transmitter and receiver pair.