星逝々 发表于 2013-3-4 23:09:59

格力空调红外控制的问题

本帖最后由 星逝々 于 2013-3-5 12:53 编辑

求教一个问题,我用IRremote库自带的IRecvDump例子,获得到格力空调遥控器的开机键的红外编码,如下所示:
Decoded NEC: 3010040A (32 bits)
Raw (74): 764 8950 -4350 750 -500 700 -500 700 -1550 700 -1550 700 -550 700 -450 750 -450 700 -500 700 -500 700 -500 700 -500 700 -1550 700 -500 700 -500 700 -500 700 -500 700 -500 700 -450 750 -500 700 -450 750 -450 700 -1600 700 -500 700 -500 700 -450 800 -450 650 -500 750 -450 700 -1600 700 -500 700 -1550 700 -500 700 -500 700 -1550 700 -500 700 ,
然后我再写irsend.sendNEC(0x3010040A, 32);无论如何都是不能控制空调打开,这是为什么啊?用同样的方法我已经控制机顶盒成功了,就是不能控制家里的格力空调,求助!
PS:码没有错,读取了N次了,每次都是3010040A

星逝々 发表于 2013-3-5 00:17:52

unsigned int rawCodes_num9 = {-19190,8950,-4350,700,-500,700,-550,650,-500,700,-1600,700,-450,750,-500,650,-550,650,-500,700,-1600,700,-500,700,-500,650,-1600,700,-500,700,-500,700,-500,700,-500,700,-500,700,-500,650,-500,700,-500,700,-500,700,-1600,650,-550,650,-500,700,-550,650,-500,700,-500,700,-500,700,-1600,650,-500,700,-1600,700,-500,700,-500,700,-1550,750,-500,650};
   irsend.sendRaw(rawCodes_num9, 74, 38);

这个也不行

wasdpkj 发表于 2013-3-5 00:35:01

irsend.sendNEC(0x3010040A, 32);

瘦网虫 发表于 2013-3-5 08:39:14

星逝々 发表于 2013-3-5 00:17 static/image/common/back.gif
unsigned int rawCodes_num9 = {-19190,8950,-4350,700,-500,700,-550,650,-500,700,-1600,700,-450,75 ...

这个肯定不行,这个发送的格式不是你解码出来的格式。

星逝々 发表于 2013-3-5 09:24:05

wasdpkj 发表于 2013-3-5 00:35 static/image/common/back.gif
irsend.sendNEC(0x3010040A, 32);

irsend.sendNEC(0x3010040A, 32);我写了个for循环,从1~100bits都试过了,都是不行,最开始试验的就是32,后来改成35,再后来写了个循环

Damn_intuition 发表于 2013-3-5 14:40:15

有个办法肯定行
使用raw方式发送原始数据。

就是把接受方法里的所有解码部分去掉,只留最后的raw的那一部分。
发送同样使用原始方式发送。

Damn_intuition 发表于 2013-3-5 14:42:04

#include <IRremote.h>

int RECV_PIN = 11;
int BUTTON_PIN = 12;
IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(BUTTON_PIN, INPUT);
}

unsigned int rawCodes;
int codeLen;

void storeCode(decode_results *results) {
int count = results->rawlen;
codeLen = results->rawlen - 1;
for (int i = 1; i <= codeLen; i++) {
    if (i % 2)
      rawCodes = results->rawbuf*USECPERTICK - MARK_EXCESS;
    else {
      rawCodes = results->rawbuf*USECPERTICK + MARK_EXCESS;
      Serial.print(rawCodes<450?"0":"1");
    }
}


Serial.println(codeLen,DEC);
Serial.println("");
//处理逻辑
//处理逻辑
}

void sendCode() {
irsend.sendRaw(rawCodes, codeLen, 38);
}

void loop() {
if (digitalRead(BUTTON_PIN)) {
    sendCode();
    delay(50); // Wait a bit between retransmissions
    irrecv.enableIRIn();
}
else if (irrecv.decode(&results)) {
    storeCode(&results);
    irrecv.resume(); // resume receiver
}

}

星逝々 发表于 2013-3-5 15:20:20

Damn_intuition 发表于 2013-3-5 14:42 static/image/common/back.gif


我回去试试,谢谢先

星逝々 发表于 2013-3-5 15:26:55

翻了一些资料,对比了下隔离空调遥控的编码,好像格力的编码方式和标准的NEC编码不一样,脉冲卖是时间不一样好像

Damn_intuition 发表于 2013-3-5 16:12:09

星逝々 发表于 2013-3-5 15:26 static/image/common/back.gif
翻了一些资料,对比了下隔离空调遥控的编码,好像格力的编码方式和标准的NEC编码不一样,脉冲卖是时间不一样 ...

是的,很多设备只能采用raw方式。

fjycqyf 发表于 2013-3-31 11:12:32

Damn_intuition 发表于 2013-3-5 14:42 static/image/common/back.gif


这个有谁试过了?我试了好象不行,不知那里出问题了,我也是格力空调的

MicroCao 发表于 2013-4-5 16:16:54

星逝々 发表于 2013-3-5 15:26 static/image/common/back.gif
翻了一些资料,对比了下隔离空调遥控的编码,好像格力的编码方式和标准的NEC编码不一样,脉冲卖是时间不一样 ...

试成功了吗?

Evening 发表于 2013-8-17 10:41:43

我也是不行呢。。
只能用逻辑分析仪dump出代码么

HeartRain 发表于 2013-9-14 19:11:19

32位的不行,只能是原始数据了,你把所有的负号变正,把第一个放到最后就可以了
页: [1]
查看完整版本: 格力空调红外控制的问题