Infrared Receiver Module
Module Source
Purchase Link:
https://detail.tmall.com/item.htm?_u=72t4uge51318&id=548393997684&skuId=4361372496386
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1dEWVMIFDWb7k1NcsRy5hHA
Password: uucv
Specifications
Instructions for Use
In the spectrum, electromagnetic waves with wavelengths ranging from 760nm to 400μm are called infrared rays, which are invisible to the human eye. Examples of infrared communication are something we are all familiar with. Nowadays, most household appliances can be controlled via infrared remotes, such as televisions, air conditioners, projectors, and more. This technology is widely used, and the corresponding components are very inexpensive, making infrared remote control an ideal method for controlling everyday devices. Infrared Communication Principle
Infrared light is emitted in the form of specific frequency pulses. After the receiver detects the signal, it decodes the data according to the agreed protocol, completing the data transmission. In consumer electronics, the pulse frequency commonly used is between 30KHz and 60KHz, and the NEC protocol uses a frequency of 38KHz. This emission at a specific frequency can be understood as simply controlling the flicker rate (on/off) of a light, much like blinking an LED in microcontroller projects. It's essentially the same principle; it's just that the "light" is a different type of signal.
Receiver Principle: The receiver's chip is sensitive to this infrared light and can output high or low levels based on the presence of the light. If the emission frequency of the transmitter is regular, the high and low levels output by the receiver are also regular. Once the transmitter and receiver agree on the pattern, data can be transmitted.
Infrared transmission protocols are considered the lowest-cost and most convenient of all wireless transmission protocols. However, it does have some drawbacks, such as short transmission distances and slow speeds. Of course, each transmission protocol is used in different environments with different requirements, so comparing their pros and cons depends on the specific application and scenario.
Introduction to the NEC Protocol
The NEC protocol is one of many infrared protocols (the term "protocol" refers to the different data frame formats, but the principles of data transmission are the same). Most of the remote controls for items like air conditioners, TVs, and projectors, such as those bought from Taobao or other stores, use the NEC protocol. Some devices, like Gree or Midea air conditioners, use a different protocol, but once you learn how to decode one protocol and understand infrared transmission principles, you can decode any other remote control protocol.
Here is the translation for the text you provided:
In the spectrum, electromagnetic waves with wavelengths ranging from 760nm to 400μm are called infrared rays, which are invisible to the human eye. Examples of infrared communication are something we are all familiar with. Nowadays, most household appliances can be controlled via infrared remotes, such as televisions, air conditioners, projectors, and more. This technology is widely used, and the corresponding components are very inexpensive, making infrared remote control an ideal method for controlling everyday devices.
Infrared Communication Principle
Infrared light is emitted in the form of specific frequency pulses. After the receiver detects the signal, it decodes the data according to the agreed protocol, completing the data transmission. In consumer electronics, the pulse frequency commonly used is between 30KHz and 60KHz, and the NEC protocol uses a frequency of 38KHz. This emission at a specific frequency can be understood as simply controlling the flicker rate (on/off) of a light, much like blinking an LED in microcontroller projects. It's essentially the same principle; it's just that the "light" is a different type of signal.
Receiver Principle: The receiver's chip is sensitive to this infrared light and can output high or low levels based on the presence of the light. If the emission frequency of the transmitter is regular, the high and low levels output by the receiver are also regular. Once the transmitter and receiver agree on the pattern, data can be transmitted.
Infrared transmission protocols are considered the lowest-cost and most convenient of all wireless transmission protocols. However, it does have some drawbacks, such as short transmission distances and slow speeds. Of course, each transmission protocol is used in different environments with different requirements, so comparing their pros and cons depends on the specific application and scenario.
Introduction to the NEC Protocol
The NEC protocol is one of many infrared protocols (the term "protocol" refers to the different data frame formats, but the principles of data transmission are the same). Most of the remote controls for items like air conditioners, TVs, and projectors, such as those bought from Taobao or other stores, use the NEC protocol. Some devices, like Gree or Midea air conditioners, use a different protocol, but once you learn how to decode one protocol and understand infrared transmission principles, you can decode any other remote control protocol.
A complete NEC protocol transmission consists of: a lead code, 8-bit address code, 8-bit address inverse code, 8-bit command code, and 8-bit command inverse code. Here, we will primarily focus on how to receive and decode the NEC protocol data sent by the infrared transmitter.
Lead Code : Composed of a 9ms low level followed by a 4.5ms high level.
4 bytes of data: address code + address inverse code + command code + command inverse code. The inverse code can be used to verify if the data transmission is correct and if there has been any packet loss.
Note: In the NEC protocol, distinguishing between 0 and 1 in data transmission relies on the duration of the high and low levels received. This is essential for decoding.
Data transmission for 0 code: 0.56ms low level + 0.56ms high level.
Data transmission for 1 code: 0.56ms low level + 1.68ms high level.
So, the complete timing representation for receiving a data bit is as follows: Receiving data bit 0: 0.56ms low level + 0.56ms high level Receiving data bit 1: 0.56ms low level + 1.68ms high level
**There is also a repeat code, consisting of a 9ms low level followed by a 2.5ms high level. ** When an infrared signal is sent continuously, the repeat code can be used to transmit more quickly.
Hardware Interface
- VCC: Connect to the 5V pin of the development board
- GND: Connect to the GND pin of the development board
- OUT: Connect to digital pin 2 of the development board
Usage Method
Install Library In the Arduino IDE Library Manager, search for and install the IRremote
library, ensuring to install version V2.2.3; otherwise, the output may show FFFFFF.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 11, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <IRremote.h>
int RECV_PIN = 2; // 定义红外接收器连接的Arduino的引脚号
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600); // 启动串行通信,设置波特率为9600
irrecv.enableIRIn(); // 启动IR接收器
Serial.println("IR Receiver Ready...");
}
void loop() {
if (irrecv.decode(&results)) { // 检查是否接收到了IR信号
Serial.print("irCode: "); //打印出"irCode: "
Serial.println(results.value, HEX); //打印出当前信号16进制的值
irrecv.resume(); // 接收下一个信号
}
delay(100); // 简短的延时可以帮助稳定输出
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35