HUM: 433MHZ (4 BUTTON) REMOTE + RECEIVER

HUM: 433MHZ (4 BUTTON) REMOTE + RECEIVER-Uncategorized

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include technical characteristics, work principles, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.

INTRODUCTION

In today’s tutorial, we will explain how to connect a 433Mhz receiver to Dasduino, as well as describe how to detect which protocol, package size, and decimal value the transmitter uses to transfer the data to the Receiver (Dasduino). We will also show how the remote control works for a built-in LED which is also connected to pin 13.

 

SPECIFICATIONS

This RF transmitter is very small in terms of dimensions and has a wide range of operating voltages (3V-12V). This RF transmitter has a range of up to 100m, just keep in mind that this is in perfect conditions only and it is affected by numerous things, among which the obstacles between the transmitter and Receiver, battery voltage transmitter, and antenna design are crucial. It is beneficial for use at shorter distances. This remote works at a frequency of 433 MHz and it is very easy to connect them to a microcontroller of any type. The RF receiver is also very small in size, and this cheap receiver is used to receive RF signals at a specified frequency. Super regenerative design ensures sensitivity to weak signals. It has 4 pins, but we actually only need 3 pins and we will use GND, VCC, and one data pin. In order to achieve wireless data transmission, the transmitter and receiver must work in pairs to communicate with each other.

• Frequency: 433MHz
• Modulation: ASK
• Output on the receiver: HIGH – 1/2 od VCC, LOW – 0.7V
• Voltage on the transmitter: 3V – 12V (higher voltage = greater range)
• Range: Max. 100m in enclosed spaces, 100 m outdoors (for better range, use the antenna (solder it to the ANT spot on the board) and higher voltage on the transmitter)

In this tutorial, we will work with a 433Mhz Transceiver (remote with 4 buttons) and the Receiver which we will connect to Dasduino.

Receiver

Transmitter (remote)

 

HOW TO CONNECT IT?

In order to connect Dasduino to the receiver, we will use 3 pins from the receiver, two of which are power supply pins and one for data transmission (the right data pin in the image below). We will also use Dasduino’s power supply and one digital pin (D2 pin on which there is also one of two interrupts on the Dasduino).

Gnd –> GND DASDUINO

VCC –> +5V DASDUINO

DATA1 –> D2 (interrupt)

 

ADDING THE LIBRARY

In order to use the receiver we must teach the Dasduino to communicate with the module, i.e. we must add the rc-switch library which we will use for functions used to communicate to the module.
1. Download the library here: https://github.com/sui77/rc-switch

2. Open the Arduino IDE and add the library you have just downloaded.
3. To learn which codes the remote sends, we must upload an example that will display all the codes transmitted to the 433Mhz on the Serial Monitor, in the immediate vicinity, and on the same signal modulation.
4. Upload the code to your Dasduino and press different buttons on the remote to find out the specific codes of certain buttons.

Notice how 4 different codes show up, and since we have 4 different buttons, it means that we have successfully gathered all the codes we will need in the future.

 

DASDUINO CODE

In order to proceed to this step, you must find out everything from the Adding the Library step, so if you have not done that, please go back and continue after you have fully completed the previous step. Once you know which code is associated with which key, we can use it very easily. In this example, we will use 2 buttons on the remote (the up button and down button) to turn the LED on and off, this LED can very easily be replaced with a solid-state relay that will run a much larger load.

#include <RCSwitch.h>  //adding the downloaded library
RCSwitch mySwitch = RCSwitch();
void setup() {//the function that is active only once
  mySwitch.enableReceive(0);  //Receiver on the interrupt pin 0 => digital pin 2
  pinMode(LED_BUILTIN,OUTPUT);//declaration of the built-in LED as an output
}
void loop() {//the function that is active as long as the microcontroller is on
  if (mySwitch.available()) {//if we receive data
    
    int value = mySwitch.getReceivedValue();//save the data to the variable
    if( mySwitch.getReceivedValue()==5592332)//if the decimal value of the received data is equal
  {
    digitalWrite(LED_BUILTIN,HIGH);//turn the built-in LED on
    }
    else if( mySwitch.getReceivedValue()==5592512))//if the decimal value of the received data is equal
      {
    digitalWrite(LED_BUILTIN,LOW);//turn the built-in LED off
    }
  
   
    mySwitch.resetAvailable();//after the data is received, reset the function
  }
}

If you have successfully completed all the previous steps, you should see the following:

After pressing the “up” button, the built-in LED turns off

After pressing the “down” button, the built-in LED turns on 

After pressing the “down” button, the built-in LED turns on