极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14173|回复: 5

格力空调YBOF2的一些问题(arduino)

[复制链接]
发表于 2016-1-29 14:46:17 | 显示全部楼层 |阅读模式
目前在做一个手机控制格力空调的项目,手机端有app,通过蓝牙连接arduino ,事先使用IRremote库解码了格力空调YBOF2,现在的情况是没有反应,大神们给看看啊!
这是获取的原始码:8850 -4400 650 -550 650 -550 650 -1600 650 -1600 650 -1650 650 -500 650 -1600 700 -500 650 -1600 650 -1650 650 -500 700 -1600 650 -500 650 -550 650 -550 650 -550 650 -500 650 -550 650 -550 650 -500 650 -550 650 -1600 650 -550 650 -550 650 -500 650 -550 650 -550 650 -500 700 -1600 650 -500 650 -1650 650 -500 650 -550 650 -1600 650 -550 650
[mw_shl_code=c,true]#include <IRremote.h>
#define DHT11_PIN 0
byte dht11_dat[5];
int inByte, temp, direct,velo;
int temperature = 1;
int direction = 1;
int velocity = 1;
IRsend irsend;
unsigned int RawCodes_num1[73] = {4400,650,550,650,550,650,1600,650,1600,650,1600,650,1650,650,
1600,650,550,650,1600,650 ,550,650,500,650,1650,650,500,650,550,650,
550,650,500,650,550,650,550,600,600,650,500,650,550,650,1600,650,550,
650,550,600,550,650,550,650,550,650,500,650,1650,650,500,650,1650,650 ,
500,650,550,650,1600,650,550,650};

void setup()
{
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
Serial.begin(9600);
}

void loop()
{
while(1)
{
if(Serial.available() > 0)
{
inByte = Serial.read();
if(inByte = 73)
{
temp = Serial.read();
direct = Serial.read();
velo = Serial.read();
finally(temp,direct,velo);
}
}
delay(60000);
}
}
void DHT11()
{
byte dht11_in;
int i;
PORTC &= ~_BV(DHT11_PIN);
delay(18);
PORTC &= _BV(DHT11_PIN);
delayMicroseconds(40);
DDRC &= ~_BV(DHT11_PIN);
delayMicroseconds(40);
dht11_in = PINC & _BV(DHT11_PIN);
if(dht11_in)
{
Serial.println("dht11 response signal 1 not received");
return;
}
delayMicroseconds(80);
dht11_in = PINC & _BV(DHT11_PIN);
if(!dht11_in)
{
Serial.println("dht11 response signal 2 not received");
return;
}
delayMicroseconds(80);
for (i = 0; i<5;i++)
{
dht11_dat = read_dht11_dat();
}
byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
if(dht11_dat[4] != dht11_check_sum)
{
Serial.println("DHT11 checksum error");
}
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
}

byte read_dht11_dat()
{
int i =0;
byte result = 0;
for(i=0; i<8;i++)
{
while(!(PINC & _BV(DHT11_PIN)));
delayMicroseconds(30);
if(PINC & _BV(DHT11_PIN))
result |=(1<<(7-i));
while((PINC & _BV(DHT11_PIN)));
}
return result;
}

void finally (int m,int n,int t)
{
DHT11();
if(temperature!=m)
{
temperature=m;
switch(m)
{
case 2:
Serial.println("25 she shi du");
RawCodes_num1[18] = 1650;
RawCodes_num1[20] = 550;
RawCodes_num1[22] = 550;
RawCodes_num1[8] = 1650;
break;
case 3:
Serial.println("26 she shi du");
RawCodes_num1[18] = 550;
RawCodes_num1[20] = 1650;
RawCodes_num1[22] = 550;
RawCodes_num1[8] = 1650;
break;
case 4:
Serial.println("27 she shi du");
RawCodes_num1[18] = 1650;
RawCodes_num1[20] = 1650;
RawCodes_num1[22] = 550;
RawCodes_num1[8] = 1650;
break;
case 5:
Serial.println("guan ji");
RawCodes_num1[8] = 550;
break;
case 1:
default:
Serial.println("24 she shi du");
RawCodes_num1[18] = 550;
RawCodes_num1[20] = 550;
//RawCodes_num1[24] = 550;
RawCodes_num1[8] = 1650;
break;
}
if(dht11_dat[2]-23<m)
{
Serial.println("zhi re");
RawCodes_num1[2] = 650;
RawCodes_num1[6] = 1650;
// RawCodes_num1[79] = 1650;
// RawCodes_num1[81] = 550;
// RawCodes_num1[83] = 550;
}
else
{
Serial.println("zhi leng");
RawCodes_num1[2] = 1650;
RawCodes_num1[6] = 650;
// RawCodes_num1[79] = 1650;
// RawCodes_num1[81] = 550;
//RawCodes_num1[83] = 550;
}
irsend.sendRaw(RawCodes_num1,73,38);
}
if(direction!=n)
{
direction = n;
switch(n)
{
case 1:
Serial.println("Wind Direction 1");
RawCodes_num1[14] = 1650;
// RawCodes_num1[31] = 550;
// RawCodes_num1[33] = 1650;
break;
case 2:
Serial.println("Wind Direction 2");
RawCodes_num1[14] = 550;
// RawCodes_num1[31] = 1650;
// RawCodes_num1[33] = 550;
break;
/* case 3:
Serial.println("Wind Direction 3");
RawCodes_num1[29] = 550;
RawCodes_num1[31] = 1650;
RawCodes_num1[33] = 1650;
break;
case 4:
Serial.println("Wind Direction 4");
RawCodes_num1[29] = 1650;
RawCodes_num1[31] = 550;
RawCodes_num1[33] = 550;
break;
case 5:
Serial.println("Wind Direction 5");
RawCodes_num1[29] = 1650;
RawCodes_num1[31] = 550;
RawCodes_num1[33] = 1650;
break;
case 6: */
default:
Serial.println("no Wind Direction ");
RawCodes_num1[14] = 550;
//RawCodes_num1[31] = 1650;
// RawCodes_num1[33] = 550;
break;
}
if(dht11_dat[2]-23<m)
{
Serial.println("zhi re");
RawCodes_num1[2] = 550;
RawCodes_num1[6] = 1650;
//RawCodes_num1[79] = 1650;
// RawCodes_num1[81] = 1650;
// RawCodes_num1[83] = 550;
}
else
{
Serial.println("zhi leng");
RawCodes_num1[2] = 1650;
RawCodes_num1[6] = 550;
//RawCodes_num1[79] = 1650;
// RawCodes_num1[81] = 550;
// RawCodes_num1[83] = 1650;
}
irsend.sendRaw(RawCodes_num1,73,38);
}
if(velocity!=t)
{
velocity = t;
switch(t)
{
case 1:
Serial.println("Wind Velocity 1");
RawCodes_num1[10] = 1650;
RawCodes_num1[12] = 550;
//RawCodes_num1[89] = 1650;
break;
case 2:
Serial.println("Wind Velocity 2");
RawCodes_num1[10] = 550;
RawCodes_num1[12] = 1650;
// RawCodes_num1[89] = 550;
break;
case 3:
Serial.println("Wind Velocity 3");
RawCodes_num1[10] = 1650;
RawCodes_num1[12] = 1650;
//RawCodes_num1[89] = 1650;
break;
case 4:
default:
Serial.println("Wind Velocity auto");
RawCodes_num1[10] = 550;
RawCodes_num1[12] = 550;
//RawCodes_num1[33] = 1650;
break;
}
if(dht11_dat[2]-23<m)
{
Serial.println("zhi re");
RawCodes_num1[2] = 550;
RawCodes_num1[6] = 1650;
//RawCodes_num1[79] = 550;
// RawCodes_num1[81] = 550;
// RawCodes_num1[83] = 550;
}
else
{
Serial.println("zhi leng");
RawCodes_num1[2] = 1650;
RawCodes_num1[6] = 550;
//RawCodes_num1[79] = 1650;
// RawCodes_num1[81] = 1650;
// RawCodes_num1[83] = 1650;
}
irsend.sendRaw(RawCodes_num1,73,38);
}
}[/mw_shl_code]
回复

使用道具 举报

发表于 2016-1-29 15:24:21 | 显示全部楼层
IRremote库的默认buff大小不够,后面被丢弃了.你获取到的rawcode就不完整
这个验证码真坑爹,输了好几遍才过
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-1-29 15:48:51 | 显示全部楼层
xyz50270 发表于 2016-1-29 15:24
IRremote库的默认buff大小不够,后面被丢弃了.你获取到的rawcode就不完整
这个验证码真坑爹,输了好几遍才 ...

rawcode的话,我是按照官方库获取的,应该没问题吧,默认buff最大是多少?编码只有74位啊
回复 支持 反对

使用道具 举报

发表于 2016-1-29 20:39:28 | 显示全部楼层
空调的编码非常长,直接把BUFF改到300去吧
YBOF2貌似已经解了,偏偏我的是YAD0F
http://wenku.baidu.com/view/2197b3400b4e767f5bcfce34.html
回复 支持 反对

使用道具 举报

发表于 2016-1-29 21:30:37 | 显示全部楼层
看我贴的这个主题里面的帖子:
http://www.geek-workshop.com/thread-4560-1-1.html
回复 支持 反对

使用道具 举报

发表于 2016-1-30 11:15:35 | 显示全部楼层
买个逻辑分析仪,分分钟搞定呀。
几十块钱那种就可以了。
前天花2小时,搞定了杜亚的窗帘遥控器。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-15 03:07 , Processed in 0.052443 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表