433MHz Relay Control
17/10/2020 | Views: 1365 | Arduino | by: ELECTRONOOBS      


The idea behind this tutorial is to make somethiong like this module here that you could buy from eBay, but make the homemade version. This is a radio controlled relay module. This tutorial will show you how to make the remote controller and the receiver with the relay. The receiver will be powered directly from 220VAC so it will work independent from the transmitter and will not need batteries. The radio transmitter will work with a 3.7V battery. I will show you how to implement the ultra-low power mode on the Arduino so it could last a few years with one charge. With multiple buttons you could control multiple relays around the house for light bulbs, fans, TVs, etc...





Part 1 - What we need?


Below you have all the parts needed for radio relay control project for both receiver and transmitter. I've selected components that could be small enough to fit isnide a commercial 220V outlet. For the case, you can select any other option, maybe even directly isnide the wall connected to the 220V wires of the oulet, light or any other wires. Check the list below and make the PCB.

Arduino 433MHz remote controller homemade tutorial


Part 2.1 - Select the radio module


The radio transmitter remote must be low power. Why? Well because you don't want to charge the remote to control your home lights each week. Usually these remoret last for years with one set of batteries. For that we need to make the Arduino be low-power and also select the radio module with the lowest power consumption. In my case I've tested all transmitter modules below and the 433MHz pair mdoules were the ones that least power consumption have at the voltage of the battery. Now these are the onew with the lowest range, around 20m. But for this project we don't need more than that since we want to control relays around the same room. Also, these modules are the cheapest ones. That's why I've selected the 433MHz radios.


ultra low power radio modules


Part 2.2.1 - Arduino Low-Power


We now have a low power radio module. But the Arduino Pro Mini by itself when running will draw as you can see below, around 15mA of current. So suposing a 500mAh battery, hat would last 30 hopurs or so, so a little bit more tahn a day. We want way more than that, so we need to lower the power consumprion. One thing we can do, is to implement the low power mode on the Arduino Pro Mini. With the low power code, as you can see below, the Arduino will draw only 4.2mA which is still too much. We will lower the consumption even more by removing parts. But first, see the low power code below.


Arduino pro mini low power code


Part 2.2.2 - Low-Power Code


See the code below that will implement low-power mode. Read each line. The idea is that using tgis line set_sleep_mode(SLEEP_MODE_PWR_DOWN); we can eneble the ultra low power mode. But the problem is: when the low power mode is enabled, the void loop won't run so if we press a button of the remote, we won't be able to detect that. That's why we use interruptions. Interruptions will work even we have low power mode enabled. So, when we enter the ISR(PCINT2_vect) interruption vector, we first disable low power mode and now the void loop will run. We send the data with the radio and put the arduino back to sleep.


#include <avr/interrupt.h>      // library for interrupts handling
#include <avr/sleep.h>          // library for sleep
#include <avr/power.h>          // library for power control

void setup() {
  PCICR |= B00000100;   //Port D intrruptions enabled
  PCMSK2 |= B00000100;  //PCINT18 -> Pin D2 will trigger interruption
  delay(100);   
  //We activate LOW power mode    
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  cli();
  sleep_bod_disable();    
  sei();
  sleep_cpu();
  sleep_enable();
}

//Void loop won't run only if sleep mode is disabled.
void loop() {    
  delay(3000); //Delay to simulate the radio data send code...
  
  //We activate back LOW power mode and wait for next interruption  
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  cli();
  sleep_bod_disable();    
  sei();
  sleep_cpu();
  sleep_enable();
}

//Each time we push the button on D2, the ISR will trigger and disable sleep mode
ISR(PCINT2_vect)
{
  sleep_disable();
}



Part 2.2.3 - Remove components


We don't need the power ON LED so we could remove that. The Arduino will be powered directly from the 3.7V battery connected to Vcc so, won't need the 5V voltage regulator neighter so we could remove the input diode, the regulator and the decupling input capacitor as well. That will lower the power consumption a lot. As you can see below, we now use only 90uA which is a very low value. With a 500mAh battery taht will last 5600 hours or 231 days which is a lot better!


Arduino remove components ultra low power


Part 2.2.4 - 90uA current draw


Arduino remove components ultra low power



Part 3 - Remote Schematic


Below you have the scheamtic for the transmitter. We connect the battery to the charger and we add a slide switch at the output in order to be able to totally turn off the remote. We supply Vcc to the Arduino and transmitter. The FTDI module is not part of the scheamtic, is just used to upload the code once. Connect all 4 buttons to GND on one side, and the other side connect it to pins D2 to D5. The DATA pin for the radio module goes to D12 pin for the SPI connection.


Arduino 433MHz remote schematic


Part 4 - TX code


This is the transmitter code for the 433MHz radio controller and relay control. Make the connections as below and use SPI pin D12 for the transmitter radio module. You will also need to download and install the RadioHead library from below. We use that library with the 433MHz modules. This code also includes the low-power mode and interruptions for D2 to D5 pins. Curerent draw 90uA.



#include <avr/interrupt.h>      // library for interrupts handling
#include <avr/sleep.h>          // library for sleep
#include <avr/power.h>          // library for power control
#include <RH_ASK.h>
#include <SPI.h>                // Not actually used but needed to compile
RH_ASK driver;                  // Create the TX instance






Part 5 - Receiver Schematic


Below you have the scheamtic for the receiver. Since the solid state relay module on the PCB is too big, I had to take it out from the PCB and solder the circuit on a small PCB so it could fit inside the case. You have the circuit below with a NPN transistor and a few resistors. Connect 220VAC to the converter and the 12VDC output connect it to the RAW pin of the Arduino Pro Mini. Connect pin D2 to the relay circuit. Connect D11 to the radio receiver. Share GND with the entire ciruit.


Arduino 433MHz receiver relay schematic


Part 6 - RX code


This is the receiver code for the 433MHz radio controller and relay control. Make the connections as below and use SPI pin D11 for the receiver radio module. You will also need to download and install the RadioHead library from below. We use that library with the 433MHz modules.



//Outputs
int Pin_D2 = 2;       //Connect to relay1 pin
int Pin_D3 = 3;       //Connect to relay2 pin
int Pin_D4 = 4;       //Connect to relay3 pin
int Pin_D5 = 5;       //Connect to relay4 pin





Part 6 - Mount the remote


So, get the transmitter schematic and mount it on the prototype PCB. Solder all the modules and then use thin wires to make the connections. Upload the TX code to the Arduino and that's it.


Arduino 433MHz remote homemade PCB



Part 7.1 - Receiver - SSR


Before we mount everything inside the case, as you cansee the SSR module is too big. So take it out and solder the circuit from the receiver scheamtic on a tiny PCB. Then I glue that PCB on top of the relay. As you can see below, now the SSR ia a lot smaller so it will fit better. To make the circuit I've used the same components from the original PCB, just desolder and use them again.


Arduino 433MHz remote homemade PCB


Part 7.1 - Mount the Receiver


Ok, get the case and remove the switch so we have more space. First solder the 220VAC to 12VDC converter. Add thin wires at the 12V output taht we will later connect to the Arduino. Next, on top add the relay and solder one phase to the 220VAC input. The other phase is connected direectly to the LOAD. ADD INSULATION TUBES. Add a green thin wire that will go to D2 of the Arduino. Also add 5V and GND thin wires with black and red. Next solder the wires to the Pro Mini for 12V, 5V, D2 and GND. Also solder 3 wires from the Pro Mini that will go to the receiver. Glue the Arduino in place. Solder the reciever with wires for 5V, GND and D2 and place it inside. Uplaod the reciver code to the Pro Mini. Close the case and that's it.


Arduino 433MHz remote homemade PCB


Part 8 - See the video








17/10/2020 | Views: 1365 | Arduino | by: ELECTRONOOBS      












Last tutorials

Arduino Port Register Control
433MHz Relay Control
ARDUINO E-BIKE ESC
Digital Electronic LOAD



PCBWAY PCB service

PCBWAY PCB service

PCBONLINE PCB service