|
新的SOC微信宠物屋的温湿度代码要放在gizwits_product.c的userHandle函数下。如下:
希望能帮助还没解决的朋友,我看代码看了几天才搞定
void ICACHE_FLASH_ATTR userHandle(void)
{
/ *
currentDataPoint.valueInfrared = curIr; //添加传感器数据收集
currentDataPoint.valueTemperature = curTemperature; //添加传感器数据收集
currentDataPoint.valueHumidity = curHumidity; //添加传感器数据收集
* /
uint8_t ret = 0;
uint8_t curTemperature = 0;
uint8_t curHumidity = 0;
uint8_t curIr = 0;
static uint8_t thCtime = 0;
static uint8_t irCtime = 0;
thCtime ++;
irCtime ++;
/// <新添加代码:红外传感器数据获取
if(INF_TIMEOUT <irCtime)
{
irCtime = 0;
curIr = irUpdateStatus();
currentDataPoint.valueInfrared = curIr;
}
/// <新添加代码:温湿度传感器数据获取
if(TH_TIMEOUT <thCtime)
{
thCtime = 0;
ret = dh11Read(&curTemperature,&curHumidity);
if(0 == ret)
{
currentDataPoint.valueTemperature = curTemperature;
currentDataPoint.valueHumidity = curHumidity;
}
else
{
os_printf(“@@@@ dh11Read error!\ n”);
}
}
system_os_post(USER_TASK_PRIO_2,SIG_UPGRADE_DATA,0);
}
|
|