This tutorial demonstrates a simple circuit for beginners that uses RF communication to gather temperature sensor data and display it on the serial monitor. It will help you get acquainted with using simple RF modules and transmitting sensor data between two arduino boards. In this tutorial, one temperature sensor has been used. However, once you are comfortable with handling RF communication, you can add more and different types of sensors to gather data.
For this tutorial, you will need:
- Two micro-controllers (I am using an Arduino Uno and an Arduino Mega)
- RF communicaton modules (Transmitter and Receiver. I am using the simple and cheap 433MHz RF transmitter and receiver)
- USB cables
- Temperature sensor (I am using the LM-35 temperature sensor)
- Jumper Wires (male-to-male or male-to-female)
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Setting Up the Circuits
Here we set up the circuit connections. The diagrams are given above.
Note that in both the receiver and transmitter modules, not all the pins need to be connected. The connections shown in the diagram are sufficient to begin with. However, one can solder/attach antennas to both the RF modules to increase their range and transmission capabilities. This has not been done in this demonstration.
In this tutorial, the Arduino Uno acts as the transmitting board and the Arduino Mega acts as the receiving board.
The transmitter and receiver boards can be simultaneously connected to your PC using two different USB cables, or can be connected one after another to upload the sketches.
Step 2: Arduino Code
The transmitter and receiver parts have their own codes. You will be required to download the VirtualWire library written by Mike McCauley. You can download it from the following link:
Once you download it, you will have to extract the files, copy-paste the VirtualWire folder into your arduino "libraries" folder. once you have done this, you will be able to include this library by typing #include
Once you have done this, download,understand and verify the sketches given below.
To understand the functions of the VirtualWire library more clearly and to modify your code according to your requirements, visit https://www.pjrc.com/teensy/td_libs_VirtualWire.html.
Step 3: Uploading the Arduino Codes
Once you have set up the circuits and saved your arduino codes, it is time for you to upload them to your arduino boards.
Remember to choose the correct ports and boards while uploading your sketches by clicking on tools->Port and tools->Board in the Arduino IDE. When I setup my connections, the Arduino Mega (acting as the receiver board) was connected via COM6 and the Arduino Uno (acting as the transmitting board) was connected via COM3. Hence the transmitter code was uploaded via COM3 and the receiver code via COM6, with the appropriate boards chosen.
Also note that the two circuits are not physically connected in any way to allow data transmission other than the RF modules which will be communicating with one another.
Once the codes have been uploaded, you can plug a power source to the transmitter board (Arduino Uno in my case) and remove the USB cable attaching it to the PC. However, do not disconnect the USB cable connecting the receiver board (Arduino Mega in my case) to your PC. This demonstrates that the RF transmitter module can operate independently on a power source without being connected to the PC, and continuously sends sensor data to the receiver module. The receiver module, being connected to the PC, receives data from the transmitter and displays it on the serial monitor.
Once you have uploaded the codes succesfully, open your receiver board serial monitor. The time and temperature values should be displayed as shown above.
Step 4: Troubleshooting
If all goes well, then you should be able to open the serial monitor for your receiver board and get the time and temperature values displayed at intervals of approximately 3 seconds. However, the RF messages may take longer to be sent or received and the time interval between two readings as displayed on the serial monitor may exceed 3 seconds, which is perfectly normal and expected.
If you are having problems with the setup, then:
- Make sure you are using a good USB cable to upload you sketches. If you are getting a message saying "unable to upload sketch" inspite of correcting everything, the USB cable may need to be changed
- Check all your connections and make sure they are firm and correct
- Choose the correct Ports and Boards while uploading your sketches
- Without the use of antennas, I was able to receive data upto a range of just about 30+ feet. If you want to increase the range of this transmission, you will need to attach antennas to the RF modules
Thats all! Thank you for going through this tutorial. Remember that the RF modules used in this tutorial are very cheap and simple to use and their use can be mastered easily.