Panel Cookies
433MHz radio example

Help me by sharing this post


PREVIOUS TUTORIAL       NEXT TUTORIAL

So, I've made a video with some radio modules you could use. In this case we will see the 433MHz radio module with virtualWire serial communication. See the connections below, download the example code and test if it works. You need two modules, rx and tx, an LED and a potentiometer and we will send just one byte of data, 0 to 255 values. The range for this module could be up to 100m.

Arduino 433MHz radio example library schematic



PART 1 - 433MHz module

Ok, guys, now we have this very cheap module that works at 433Mhz or sometimes 315Mhz. The range depends on the voltage connected to the module and the antenna that we use. At 5V and with the stock antenna of the module, the range will hardly exceed 2 meters. Supply this at 12V and with a small copper antenna, the outdoor range can reach maybe 300 meters. Now the bad thing about these modules is that the communication is simplex (single and unidirectional channel) and they have low transmission speed (typically 2400bps). It basically works by ASK modulation (amplitude shift keying). They do not have a filter or hardware Identifier, so if we want robust communication, we will have to implement it by software.

We need:
Arduino 433Mhz radio tutorial example code

The connection is very simple. First, we power the modules by connecting VCC and GND, at 5V and GND from the Arduino. As we will see in the code, we will use the Virtual Wire library, which works with any digital pin. Therefore, we simply connect the DATA pins to any digital output as in the schematic.





PART 2 - Schematic

The schematic is simple but with a lot of pins. We have 2 Arduino NANO and we will use 5V from the Arduino in this case. If this doesn't work, connect an external 5V to 12V supply and share ground. Anyway, connect the data pins and add a potentiometer, and LED and a resistor. Upload the codes below to the transmitter and receiver and read the comments in the code for more. Test if it works and you could change the brightness of the LED using the radio connection.


Arduino schematic 433MHz radio connection





PART 3 - Code

3.1 Transmitter

Here we have the transmitter code. You will need the virtuwalWire library for this module so download that from the code link below and install it to the Arduino IDE. Uplaod this code to the Arduino with the potentiometer. Read the comments in the code for more. Copy or download the code from below.




/* 1byte 433Mhz TRANSMITTER example.
/* Tutorial link: http://electronoobs.com/eng_arduino_tut99.php
 * Code: http://electronoobs.com/eng_arduino_tut99_code1.php
 * Scheamtic: http://electronoobs.com/eng_arduino_tut99_sch1.php
 * Youtube Channel: http://www.youtube/c/electronoobs   
// Arduino          433Mhz Tx
// GND              GND
// 5V               VCC
// D3               Data
*/

#include <VirtualWire.h> //Download it here: http://electronoobs.com/eng_arduino_virtualWire.php
#define size 1
int pot = A0;
byte TX_buffer[size]={0};
byte i;


void setup() 
{
  // virtual wire
  vw_set_tx_pin(3); // pin
  vw_setup(2000); // bps
  for(i=0;i<size;i++)
  {
     TX_buffer[i]=i;
  }
}

void loop()
{ 
  int val = map(analogRead(pot),0,1024,0,255);
  TX_buffer[0] = val;  
  vw_send(TX_buffer, size); 
  vw_wait_tx(); 
  delay(10);   
}



3.2 Receiver

Here we have the receiver code now. Uplaod this code to the Arduino with the LED. Read the comments in the code for more. Copy or download the code from below.




/* 1byte 433Mhz RECEIVER example.
/* Tutorial link: http://electronoobs.com/eng_arduino_tut99.php
 * Code: http://electronoobs.com/eng_arduino_tut99_code2.php
 * Scheamtic: http://electronoobs.com/eng_arduino_tut99_sch1.php
 * Youtube Channel: http://www.youtube/c/electronoobs   
// Arduino          433Mhz RX
// GND              GND
// 5V               VCC
// D3               Data
*/

#include <VirtualWire.h>              //Download it here: http://electronoobs.com/eng_arduino_virtualWire.php
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
int received_number = 0;
int LED = 5;

void setup()
{
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
  Serial.println("Ready...");
  vw_set_rx_pin(3); // pin
  vw_setup(2000); // bps
  vw_rx_start();
}

void loop()
{
  if (vw_get_message(message, &messageLength)) // non-blocking
  {
    Serial.print("Potentiometer: ");
    for (int i = 0; i < messageLength; i++)
    {
      //Serial.print(message[i]);
      received_number = message[i];
    }
    Serial.println(received_number);
    analogWrite(LED, received_number);
  }
}




PART 4 - Test

Now you are able to control the LED using radio connection. These modules could get up to 100m according to the web comments. That's it for this module. I hope you are able to use it. If not, comment below and ask for help. Keep up!


Arduino schematic 433Mhz connection gif



Help me by sharing this post












yt_link
insta_link
fb_link
twitter_link

433MHz
page 1/1



Affiliate Disclosure

ADVERTISERS



PCBWAY PCB service





Curso Arduino Online nivel bajo