一、需求和思路
1.空调不带wifi,遥控总是找不到,手机没有红外线,只好做一个基于esp8266的局域网红外遥控,顺便做个app。
2.使用esp8266开发板,红外模块一个。
3.使用Android studio制作遥控app。
二、esp8266控制程序
/*
* nodemcu引脚对应数字:
* 16=D0;
* 4=D2;
* 0=D3;
* 2=D4;
* 14=D5;
* 12=D6;
* 13=D7;
* 15=D8;
* 3=D9;
* 1=D10;
* 舵机 ->D2--模拟输出
*/
#include <ESP8266WiFi.h>
#include <Servo.h>
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
const uint16_t kIrLed = 4;
IRsend irsend(kIrLed);
//Timestamp : 000155.307Library : v2.7.19
//Protocol : COOLIXCode : 0xB29F40 (24 Bits)Mesg Desc.: Power: On, Mode: 0 (Cool), Fan: 4 (Min), Temp: 24C, Zone Follow: Off, Sensor Temp: Off
uint16_t rawData[119] ={1212, 496, 1186, 478, 418, 1270, 1210, 474, 1212, 498, 396, 1268, 416, 1268, 1210, 500, 394, 1294, 416, 1244, 444, 1266, 394, 7880, 1186, 478, 1230, 456, 414, 1294, 1186, 480, 1206, 500, 394, 1292, 394, 1270, 1206, 482, 414, 1268, 416, 1294, 394, 1270, 418, 7856, 1232, 452, 1210, 502, 418, 1268, 1208, 478, 1184, 502, 392, 1274, 414, 1294, 1210, 454, 416, 1292, 392, 1296, 416, 1268, 392, 7884, 1184, 500, 1186, 504, 414, 1270, 1184, 506, 1206, 478, 394, 1294, 392, 1294, 1198, 488, 392, 1294, 392, 1296, 390, 1294, 414, 7860, 1208, 478, 1210, 478, 392, 1294, 1208, 480, 1206, 480, 392, 1294, 394, 1294, 1206, 478, 418, 1270, 394, 1292, 392, 1296, 392};
// COOLIX B29F40uint64_t data = 0xB29F40;
uint16_t Geli_FanOpen[119] = {1268, 418, 1268, 418, 448, 1238, 1268, 418, 1268, 418, 450, 1238, 448, 1238, 450, 1236, 450,