RF 315MHz/433MHz Wireless and Arduino...again!

by Mohannad Rawashdeh in Circuits > Arduino

24496 Views, 82 Favorites, 0 Comments

RF 315MHz/433MHz Wireless and Arduino...again!

433MHz RF kit.jpg

Hello everyone ! in this artical i will try to update my older artical about RF ASK 315MHz and 433MHz ,with more application and update the library i used before

First it might be good to check my older artical about RF433/315MHZ from here

with many feedback arrived me about it, i decided to fix many issue like:

  1. Using Radio head Library , more better and a comprehensive library .
  2. Using a module from Seeedstudio comes with antenna to see if it will increase the range of Tx and Rx.
  3. add more codes and video for this RF.

let's start with component we need

Components and Software

20170213_230940.jpg
20170213_231000.jpg
wire.jpg
  1. Arduino Board x 2 pcs "You can choose any 2 board type you want
    I used Uno and Nano to do this experiment.
  2. RF315/433 module, You can buy it from
    Seeedstudio I used This one
    Aliexpress
    amazon

  3. Breadboard
  4. Jumper wire
  5. if you choosed seeedstudio grove module, you need this type of wires with them too
  6. Power source"you can use power bank or 9V battery or even your PC usb port , it's up to you

You need to have an arduino IDE , you can download it from here.

I tested it on arduino 1.5.2 , 1.5.5 and newer 1.6.9 and worked well on them all.

you need also to download Radio head library and install it inside arduino library folder

Simple Code- Blink Rx Led

Rx schematic_schem.png
Tx schematic_schem.png
20170213_230507.jpg
20170213_230538.jpg

first i will write a simple code, sending from RF Tx a signal each 2 second to turn on-off led attached to D13

connection is very simple , you can see the Tx and Rx connection.

I powered my circuits from power bank to test the maximum range of this module.

The transmitter code

<p>/*<br>RF433 MHz Tx code
this code for turn on and LED on receiver side
every 2 seconds
connect the Data pin to pin 12
written By: Mohannad Rawashdeh
13 Feb 2017
visit my instructables profile for more information
<a href="https://www.instructables.com/member/Mohannad%20Rawashdeh/?publicView=true</p">
https://www.instructables.com/member/Mohannad%20R...</a>><p>*/
#include <rh_ask.h>
#include <spi.h> // Not actually used but needed to compile
RH_ASK Rawashdeh;
const int LEDpin=13;// indicator pin
const int delayTime = 2000;
const char *On_command = "1";
const char *Off_command = "0";
void setup()
{
  pinMode(LEDpin,OUTPUT);
    while (!Rawashdeh.init())
    {
  // no RF connected ! or error on initi
      digitalWrite(LEDpin,1);
      delay(100);
      digitalWrite(LEDpin,0);
      delay(100);      
    }
}</spi.h></rh_ask.h></p><p>void loop()
{
 Rawashdeh.send((uint8_t *)On_command, strlen(On_command));
 Rawashdeh.waitPacketSent();
 delay(delayTime);
 Rawashdeh.send((uint8_t *)Off_command, strlen(Off_command));
 Rawashdeh.waitPacketSent();
 delay(delayTime); 
}</p>

the receiver code

<p>/*<br>RF433 MHz Rx code
this code for turn on and LED on receiver side
every 2 seconds
connect the Data pin to pin 11
written By: Mohannad Rawashdeh
13 Feb 2017
visit my instructables profile for more information
<a href="https://www.instructables.com/member/Mohannad%20Rawashdeh/?publicView=true</p">
https://www.instructables.com/member/Mohannad%20R...</a>><p>*/
#include <rh_ask.h>
#include <spi.h> // Not actually used but needed to compile
RH_ASK Rawashdeh;
const int LEDpin=13;// indicator pin
const int delayTime = 2000;
const char *On_command = "1";
const char *Off_command = "0";
void setup()
{
//  RH_ASK(2000,11,12,10,false);
  pinMode(LEDpin,OUTPUT);
  if (!Rawashdeh.init())
  {
  // no RF connected ! or error on initi    
  digitalWrite(LEDpin,1);
  delay(100);
  digitalWrite(LEDpin,0);
  delay(100);          
  }
}</spi.h></rh_ask.h></p><p>void loop()
{
    uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
    uint8_t buflen = sizeof(buf);</p><p>    if (Rawashdeh.recv(buf, &buflen)) // Non-blocking
    {
      if(buf[0]=='1')
      {
  digitalWrite(LEDpin,1);        
      }
      if(buf[0]=='0')
      {
  digitalWrite(LEDpin,0);        
      }      
    }
}</p>

Add Button on Transmitter Side to Gain More Control

Tx BUTTON schematic_schem.png
20170213_230438.jpg
20170213_230443.jpg
20170213_230445.jpg

if you want to send the signal to receiver and control when the led must turn on, we can add button to transmitter circuit and connect it to pin D2

Rather than using LED you can connect Relay , Servo motor , DC motor and control it from transmitter side.

Send a Command From Serial Monitor

serial welcome mesage.png
serial SEND Y.png
serial SEND X 2.png
serial SEND X.png
serial SEND Y 2.png
serial rubbish.png
serial rubbish 2.png

If you looking for upgrade the way you want to control RF module by,you can send a command from serial monitor.

no need to change the receiver code , all you need is to upload this code to transmitter arduino board and open a serial monitor

set the buad rate to 19200

Send X character to turn on the LED on the receiver

Send Y character to turn on the LED on the receiver

You can design an application on PC or MAC with interface to control this module for more advance project.

Finally:

I powered my circuits from power bank to test the maximum range of this module.
actually it was not that much of improvement as i expected,even with antenna the range in open area was around 44 meter , and inside my home it was about 20m max.

I noticed something from my experience :

  • the range will be less if you put the Tx and Rx near WiFi router.
  • the range will be less if you put the Tx and Rx near electricity transmission line "High voltage".
  • if you touch the antenna the data might be lost
  • the range will be less if you put the Tx and Rx near Microwave oven.

  • the Transmitter will be more better if you install it on higher level "altitude"than the receiver

hope to hear your questions and suggestions about this artical in the comment below or on my facebook page from here

Video to Summarize Everything

RF 433MHz / 433MHz and arduino with code and schematic using RadioHead library

in this video you can see the connection and short demo for the code.

see the video from Here