随着技术的变化,它对人类日常生活的影响越来越轻微 - 特别是在控制家用电器方面。
电气装置是每栋建筑的核心,因此智能建筑控制可以增加安全有效的控制,最终节省能源和人力。家庭自动化系统执行照明控制和调节,调节加热,设备通风和空调设备,负载和能源管理,音频和视频系统,安全和监控,人机界面等。
在今天的Wi-Fi和蓝牙连接系统环境中,IC拥有一个完全独立的基于RF的控制解决方案非常方便,该解决方案更加强大和稳定,并且不受毛病的Wi-Fi或手机电池寿命的影响。
该项目适用于那些希望拥有老式独立射频控制系统来控制家中物品的人。
基于射频的家庭自动化系统安装带有射频控制遥控器的家庭自动化系统也为您的房屋提供了更加智能化的机会。智能家居逐渐从常规交换机流向利用RF控制交换机的集中控制系统。
目前,位于房屋不同部分的传统墙壁开关使人们难以接近它们。为实现此目的,RF遥控器连接到微控制器的TX侧,其向接收器发送命令以将不同的负载连接在一起。通过操作TX上的特定远程开关,可以通过无线技术远程打开/关闭负载。
该电路使用无线电模块制作无线遥控器,可用于远距离驱动o / p。顾名思义,RF模块使用RF信号以特定频率和波特率发送信号。
RF遥控器的工作原理该项目涉及一个家庭可以使用IC的4通道射频远程家庭自动化系统。您可以使用此系统来控制任何家用电器。您可以控制LED灯泡,风扇,手机充电器,冰箱等物品。
我们将使用315 MHz RF模块和遥控器,该系统最大可达50米。
所需的硬件Arduino UNO
RF模块YK04带遥控器
4通道继电器
使用高压交流电源时,务必确保采取适当的预防措施。确保它们与DC板完全隔离,并仔细检查连接到继电器的连接。根据下面的Fritzing图进行连接:
继电器模块到Arduino UNO连接VCC为5V
IN1到A0
IN2到A1
IN3到A2
IN4到A3
GND到GND
GND到GND
5V到13
D0到12
D1到11
D2到10
D3到9
VT到8
Arduino IDE
将RM库添加到Arduino库文件夹中
将以下源代码复制到Arduino IDE,再次检查连接后,上传代码。
/*
4 push signal and one relay module 4 relay with Remote
Turns on and off 4 relays connected to digital
*/
// Read RF remote button codes using the RM4 library and send them over serial.
#include <rm4.h>
// Arduino pin connected to the receiver VCC in. Set this high to enable the
// receiver.
static const int kEnablePin = 13;
// Arduino pins connected to the data pins on the receiver.
static const int kData0Pin = 9;
static const int kData1Pin = 10;
static const int kData2Pin = 11;
static const int kData3Pin = 12;
const int relay1 = 14; // the number of the relay1 pin
const int relay2 = 15; // the number of the relay1 pin
const int relay3 = 16; // the number of the relay1 pin
const int relay4 = 17; // the number of the relay1 pin
// Create an RM4 object to read the button codes from the remote.
RM4 remote(kData0Pin, kData1Pin, kData2Pin, kData3Pin);
void setup() {
// Initialize the serial interface.
Serial.begin(9600);
// Turn on the receiver.
pinMode(kEnablePin, OUTPUT);
digitalWrite(kEnablePin, HIGH);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
}
void loop() {
// Print the button code to the serial interface every 100 ms.
const int button_code = remote.buttonCode();
if (button_code == 8) { // pin 2 is pressed and connected to GND so it will be LOW
digitalWrite(relay1, LOW); // remove 5v from pin 11 so relay in1 will be 0v and this make relay on
delay (2000); // wait 1 second
} else {
digitalWrite(relay1, HIGH); // add 5v to arduino pin 11 so relay in1 will be 5v and this make relay off
}
if (button_code == 2) { // pin 2 is pressed and connected to GND so it will be LOW
digitalWrite(relay2, LOW); // remove 5v from pin 11 so relay in1 will be 0v and this make relay on
delay (2000); // wait 1 second
} else {
digitalWrite(relay2, HIGH); // add 5v to arduino pin 11 so relay in1 will be 5v and this make relay off
}
if (button_code == 1) { // pin 2 is pressed and connected to GND so it will be LOW
digitalWrite(relay3, LOW); // remove 5v from pin 11 so relay in1 will be 0v and this make relay on
delay (2000); // wait 1 second
} else {
digitalWrite(relay3, HIGH); // add 5v to arduino pin 11 so relay in1 will be 5v and this make relay off
}
if (button_code == 4) { // pin 2 is pressed and connected to GND so it will be LOW
digitalWrite(relay4, LOW); // remove 5v from pin 11 so relay in1 will be 0v and this make relay on
delay (2000); // wait 1 second
} else {
digitalWrite(relay4, HIGH); // add 5v to arduino pin 11 so relay in1 will be 5v and this make relay off
}
// Serial.println(button_code);
// delay(100);
}
完整的射频遥控项目上传此代码后,您应该能够拥有类似的功能。