Windows 10 IoT Core:温控风扇系统

De****ne UID.1201912
2015-11-20 发表

本帖最后由 newsmanager 于 2015-11-21 00:29 编辑

温控风扇系统搭载树莓派,并可从放置在家居的温度传感器里以恒定的间隔读取数据,且当温度过热时激活高压电路的系统。该系统的原理图如下:

***附件停止解析***

该温控风扇包括:
[list]
[*]树莓派1,B +
[/list]
[list]
[*]5V继电器
[/list]
[list]
[*]温度传感器DHT11
[/list]
[list]
[*]分形设计静音系列 R3 80毫米
[/list]
[list]
[*]12V DC适配器
[/list]
温控风扇的相关代码:
[list]
[*]查看温度传感器值:[mw_shl_code=c,true]
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define MAXTIMINGS 85
#define DHTPIN 4
int dht11_dat[5] = { 0, 0, 0, 0, 0 };
float read_dht11_dat()
{
uint8_t laststate = HIGH;
uint8_t counter = 0;
uint8_t j = 0, i;
float result = -1;
dht11_dat[0] = dht11_dat[1] = dht11_dat[2] = dht11_dat[3] = dht11_dat[4] = 0;

/* pull pin down for 18 milliseconds */
pinMode( DHTPIN, OUTPUT );
digitalWrite( DHTPIN, LOW );
delay( 18 );

/* then pull it up for 40 microseconds */
digitalWrite( DHTPIN, HIGH );
delayMicroseconds( 40 );

/* prepare to read the pin */
pinMode( DHTPIN, INPUT );

/* detect change and read data */
for ( i = 0; i < MAXTIMINGS; i++ )
{
counter = 0;
while ( digitalRead( DHTPIN ) == laststate )
{
counter++;
delayMicroseconds( 1 );
if ( counter == 255 )
{
break;
}
}
laststate = digitalRead( DHTPIN );

if ( counter == 255 )
break;

/* ignore first 3 transitions */
if ( (i >= 4) && (i % 2 == 0) )
{
/* shove each bit into the storage bytes */
dht11_dat[j / 8] <<= 1;
if ( counter > 16 )
dht11_dat[j / 8] |= 1;
j++;
}
}

/*
* check that we read 40 bits & verify checksum in the last byte.
*/
if ( (j >= 40) &&
(dht11_dat[4] == ( (dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF) ) )
{
result = (1.0 * dht11_dat[2]) + ((float)dht11_dat[3]/10.0);
}
return result;
}[/mw_shl_code]
[/list]
[list]
[*]继电器控制(检查温度阈值和启动/关闭继电器):[mw_shl_code=c,true]
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define RELAYPIN 2
#define TEMPMAX 30

int state = 0;
void controlRelay(float avg_t){
pinMode( RELAYPIN, OUTPUT );
if(avg_t > TEMPMAX-state){
digitalWrite( RELAYPIN, HIGH );
state = 1;
}
else{
digitalWrite( RELAYPIN, LOW );
state = 0;
}
}[/mw_shl_code]
[/list]

敬告:
为防止不可控的内容风险,本站已关闭新用户注册,新贴的发表及评论;
你现在看到的内容只是互联网用户曾经发表的言论快照,仅用于老用户留存纪念,且仅与科技行业相关,全部内容不代表本站观点及立场;
本站重新开放前已针对包括用户隐私、版权保护、信息安全、国家政策在内的各种互联网法律法规要求,执行了隐患内容的自查、屏蔽和删除;
本站目前所属个人主体,未有任何盈利安排与计划,且与原WFUN.COM所属公司不存在任何关联关系;
如果本帖内容或者相关资源侵犯到您的合法权益,或者您认为存在问题,那么请您务必点此举报或投诉!
全部回复:
ilakb24 UID.707208
2015-11-20 回复

不明觉厉,高大上

Lumiayun UID.1103326
2015-11-20 使用 Lumia 640 回复

期待win10全面发力!

Rel****007 UID.1203920
2015-11-20 回复

不明觉厉,高大上

Di****er UID.1207524
2015-11-20 使用 Lumia 636 回复

这是c语言

zho****243 UID.41604
2015-11-20 回复

这代码写的,看得我都醉了。。。。。有点谭浩强的影子

四叶****幻想 UID.986522
2015-11-21 使用 Lumia Icon 回复

物联网。。。

lu163 UID.214118
2015-11-22 使用 Lumia 920 回复

物联网的时代

本站使用Golang构建,点击此处申请开源鄂ICP备18029942号-4联系站长投诉/举报