For the air-conditioning controls are generally infrared control. So that we can esp module and an infrared module used in conjunction with
such control to the remote wireless air conditioning
Demo video:
IR receiver
Pin 11 is used baud rate is 9600
irRemote library call, converts the received optical signal to a numerical value.
#include <IRremote.h>
int PIN_RECV = 11;
IRrecv irrecv(PIN_RECV);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value);
irrecv.resume();
}
}
You may be obtained based on this remote control code value associated key
record is used to transmit the following
(In my project I want to demonstrate in effect, so control is a digital control using arduino pro mini processes the received information received through the infrared control TM1637 digital display)
Infrared transmitter
The following code after the transformation, is to use infrared to control the display. The idea is the same as
that used sendNEC (); function sends the value to be transmitted in decimal or hexadecimal values and the like.
Many online codes
can also refer to my blog
http://niehen.cn/arduino/arduino%e6%8e%a7%e5%88%b6%e7%ba%a2%e5%a4%96%e6%8e%a5 % e6% 94% b6% ef % bc% 8c% e5% 8f% 91% e9% 80% 81 /
Use esp Development
Analyzing esp instruction is sent to the appropriate callback function into the
following analysis control infrared transmitter to send a corresponding code segment
Esp12f used GPIO4 pin
using the library to have
<IRremoteESP8266.h>
<IRsend.h> // library of infrared transmitter
<ESP8266WiFi.h>
<PubSubClient.h> // the MQTT library
- Rules sent and received
char * order_infor [] = { " on", "off", "tema", "tems", "warm", "cold", "winda", "winds"}; // temperature controlled
long enc [] = {0xFF30CF, 0xFF18E7,0xFF7A85,0xFF10EF, 0xFF38C7,0xFF5AA5,0xFF42BD, 0xFF4AB5 }; // transmit infrared hexadecimal value
Receiving 0 (open) sends the received first code 1 (off) transmitting second coded ...
2. the callback processing received values (to prevent erroneous command is present)
int isint = 0;// 如果有字母 就为1 全数字就为0
for (int i=0; i< strplayload.length();i++) // 检测接收到的命令里面是否含有 非数字的字符
{
if (!isDigit(strplayload[i]))
{
isint = 1;
break;
}
}
- Transmitting (callback code) based on the result of processing callback
if(isint == 0){
int older_air = strplayload.toInt() ; // 转换为 int类型
if(older_air >=1 && older_air<=8){
irsend.sendSony(enc[older_air - 1], 12);
client.publish("air_cond/status", "IR remote is running");
client.publish("air_cond/status", order_infor[older_air -1]);
}
Code
esp8266 mqtt use arduino development
http://niehen.cn/esp8266/esp8266-mqtt-%e4%bd%bf%e7%94%a8arduino%e5%bc%80%e5%8f%91%e6%95%99%e7%a8%8b/
esp8266-12f use Description
http://niehen.cn/esp8266/esp8266-12f%e4%bb%8b%e7%bb%8d%e4%b8%8e%e4%bd%bf%e7%94%a8/
The complete code for reference only
then make the appropriate changes to the code according to their own scenarios
Item reference code links
More tutorials
ESP developers learn the basics
Including an understanding of the basics esp modules awareness and understanding mqtt agreement, arduino IDE application code is written, and so on.
- arduino based learning
- Introduction esp Series Modules
- Introduction and use mqtt agreement
- Using mqtt esp module arduino IDE Development Methodology
- AT command esp brush firmware module
- esp module using sleep mode
- esp8266-01s introduction and use
- esp8266-12f introduction and use
- NodeMcu introduction and use
esp development of IOT applications
Based modules and other modules esp8266 application scenario according to an actual production and demand of Things
- FRID access control systems FRID arduino relay electromagnetic lock-based development
- esp32-cam video stream acquired image processing
- Stepping motor esp8266 mqtt developed automatic curtain control
- Gets indoor temperature and humidity based on DHT11 Esp8266 mqtt
- Gets indoor air quality based on CCS811 esp8266 mqtt
- Based on infrared remote control intelligent module esp8266 mqtt development
- Based ws2812 esp8266 mqtt development of intelligent multi-level lighting
- Based ws2812 esp8266 mqtt development of intelligent multi-mode light atmosphere
- Broadcast System Intelligent Voice mp3player esp8266 mqtt based development
- The wisdom of the comprehensive application of IOT classroom project development