Wireless communication between two Arduinos using inexpensive RF modules
|
This article explores an easy wireless communication setup between two Arduinos using low-cost ASK RF transmitter and receiver modules that are readily available in the market. They are found in different shapes, but functionally they are all same. Both Tx and Rx modules contain a single data line for input and output and support a low-speed Amplitude Shift Keying modulation for data communication. You can get them with 315MHz or 433MHz carrier frequency. In this tutorial, I am using a 433MHz Tx/Rx pair with two Arduino boards to illustrate how to construct a low-range wireless temperature and humidity monitor.
ASK Tx/Rx modules
As I mentioned, you can buy varieties of ASK Tx/Rx modules from both domestic and international markets (specially China). Some of them come with spring antennas, and some don’t. With the ones without antennas, you can connect ~20cm wire to their antenna pin on circuit board. The figure below shows some of the ASK RF modules you can buy on eBay and Amazon.
The Tx/Rx RF modules I am using in this project are manufactured by NiceRF, a China-based company. You can also buy these modules directly from our Tindie store. The nice things about these modules are they are very compact, breadboard and PCB friendly, made of high-quality PCB, come with copper spring antennas and have a reasonably good coverage area. With the spring antennas installed on both ends, I was able to achieve reliable communication between any two corners within my 2-story, 2000 sq. ft. house. Below is a picture of these Tx/Rx modules.
Things you will need
You will need the following items to build this project.
- ASK transmitter/receiver pair
- Two Arduino boards. I am using an Arduino Nano on transmitting side and Arduino Uno on receiving end.
- One Nokia 5110 LCD for receiving side
- One DHT22 sensor for measuring temperature and humidity at the remote site
- Two LEDs and two 330Ω resistors
- Wires, breadboard, prototyping board, etc.
Circuit setup: Tx End
The ASK transmitter module has three pins: VCC, Data, and Gnd. They could be in different sequence depending upon the manufacturers. So, always read the pin labels carefully to identify the data and power supply pins on these modules. The VCC and Gnd pins are connected to +5V and Gnd pins of Arduino Nano, whereas the Data pin of the Tx module goes to digital I/O pin 12 of Arduino. An LED is also connected to I/O pin 11 along with a current limiting resistor in series. During data transmission, this LED is turned on.
The above circuit is wired up on a breadboard as shown below.
Circuit setup: Rx End
The Rx module also consists of VCC, Gnd, and Data pins. Some modules may have more than one Data pin. In such case, you can use any one of them as they are all connected together. On the receiving side, the Data pin of the Rx module output and is read by an Arduino pin. In our case, it is connected to the D11 pin of Arduino. Similar to the Tx end, an LED connected to D3 pin is an indicator of receiving the data sent by the transmitter. A Nokia 5110 LCD is also connected to the receiving side Arduino to display the temperature and humidity at the remote station. For this experiment, I am using Crowduino Uno (Arduino Uno clone) on the receiving side.
Please note that Nokia 5110 LCD operates at 3.3V. I am running my Crowduino Uno board at 3.3V so it does not matter in this case. If your Arduino board operates at 5.0V, you would need a voltage shifter in between the Arduino and the LCD. The following diagram shows the connections at the receiving end in more detail.
I used a general purpose Arduino proto-shield to build the above circuit. Following figure shows the assembled receiver circuit soldered on the Arduino proto-shield.
Software
This project uses the VirtualWire library for Arduino written by Mike McCauley. This library supports numerous low-cost RF transmitters and receivers available in the market and allows to send short messages through ASK modulation. In this project, the Arduino on Tx end reads temperature and humidity from the DHT22 sensor, combines the two readings into a character string, and send it over the RF link. On the receiving end, the Arduino extracts the two readings back from the received string and displays the data on the Nokia 5110 LCD. You can download the VirtualWire library and Arduino codes for Tx and Rx ends from the following links.
Download VirtualWire library
Download Arduino code for transmitting end
Download Arduino code for receiving end
Output
After uploading the firmware to two Arduino boards, the project is ready for testing. You can place the Tx module to the place where you would like to monitor the temperature and humidity remotely and place the Rx module within a 100ft range. You should see the measured values on the LCD screen as shown below:
This project can be further expanded by adding a buzzer to the Rx end and programming the Arduino to alarm when the temperature and/or humidity falls outside preset limits.
We sell these Tx and Rx modules as a kit at our Tindie store. If you are interested to get one, click the following link:
|
Is there a way to have multiple transmitters/receivers in a given area and distinguish them? In your example, could you have made 1 indoor and 1 outdoor transmitter and perhaps 2 receivers (and/or 1 reading both readings?) Perhaps that is packet related and not transport related? New to this whole thing, but I am curious. Thanks for your post btw, it is very helpful.
can we used rf wireless between two arduinos mega??
Thank you for publishing this project, I have rebuilt it, and it works very nicely. Thanks, greetings from Germany 🙂
Hi, do you have the code to be added to activate a buzzer when the temperature exceeds a certain value?
After reading quite a few articles and comments I finally found one with a working software library… TYSM for this article, now I can go to sleep.
Hi:
I’ve been searching for the right wireless project to send water levelinfo from our water tank to the cottage and sound an alarm if the water drop is too great. Your project looks almost perfect to adapt. Am I right that I would have to swap out the temperature sensor for the ultra-sonic sensor and change the associated sensor info in the sketch? I guess I’d like to know if you or anyone has already done that and save me writing the code (which I’m very new at). No use re-inventing the wheel. Anyways, thanks for the excellent head start.
Best
Jeff
Receiving module soldered on a prototyping Arduino Uno shield how do i wire up the shield for Wireless communication between two Arduinos using inexpensive RF modules .
Thank you
Paul
Pingback: Wireless communication between two Arduinos using inexpensive RF modules - Electronics-Lab