广州网站开发软件平台,wordpress 问号,高端网站官网,推广策略都有哪些室内检测系统由ESP12E ShieldArduino UNO R3开发板DHT11温湿度模块双色LED灯有源蜂鸣器光敏电阻模块I2CLCD1602液晶显示器所构成。DHT11温湿度模块获取室内温湿度数据通过I2CLCD1602液晶显示器进行显示#xff0c;另一方面通过ESP12E Shield将数据上传至云平台。光敏电阻进行捕…室内检测系统由ESP12E ShieldArduino UNO R3开发板DHT11温湿度模块双色LED灯有源蜂鸣器光敏电阻模块I2CLCD1602液晶显示器所构成。DHT11温湿度模块获取室内温湿度数据通过I2CLCD1602液晶显示器进行显示另一方面通过ESP12E Shield将数据上传至云平台。光敏电阻进行捕获室内光照强度若光照强度过弱即日光过弱周围环境太黑暗低于设定的阈值则有源蜂鸣器警报双色LED灯变红正常情况下LED灯为绿色。
一、设备准备
Arduino UNO R3 I2CLCD1602液晶显示器 ESP12E Shield DHT11温湿度模块 有源蜂鸣器 光敏电阻模块 双色LED灯
二、设备连接
ESP12E Shield直接覆盖Arduino UNO R3开发板 DHT11模块
DHT11模块Arduino UNO R35V-GNDOUTP2
I2CLCD1602液晶显示器
I2CLCD1602液晶显示器Arduino UNO R3GDNGNDVCC5VSDAA4SCLA5
光敏电阻模块
光敏电阻模块Arduino UNO R3VCC5VGNDGNDAOA0
有源蜂鸣器
有源蜂鸣器Arduino UNO R3GNDGNDI/OP7VCC5V
双色LED灯
双色LED灯Arduino UNO R3GNDGNDRP11GP10
三、云平台设置
联网上传至服务器的配置可参考该篇博文 一、Arduino UNO R3将数据上传至云平台 需要添加俩个设备名称分别为humi和temp用于存放温湿度信息
四、完整代码
#include dht.h
#include LiquidCrystal_I2C.h
#include Wire.h
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 and 0x3F for a 16 chars and 2 line displaydht DHT;//create a variable type of dhtconst int DHT11_PIN 2;//Humiture sensor attach to pin2const int greenPin 11; // R petal on RGB LED module connected to digital pin 11
const int redPin 10; // G petal on RGB LED module connected to digital pin 10 const int photocellPin A0; //photoresistor module attach to A0
int outputValue 0;
const int buzzerPin7; //buzzer attach to digital 7
int val 0;
int wendu0;
int shidu0;
void setup()
{Serial.begin(9600);randomSeed(analogRead(0));pinMode(buzzerPin,OUTPUT);pinMode(redPin, OUTPUT); //set redPin as OUTPUTpinMode(greenPin, OUTPUT);//set greenPin as OUTPUTlcd.init(); //initialize the lcdlcd.backlight(); //open the backlight
}void loop()
{// READ DATA//Serial.println(DHT11:);D: int chk DHT.read11(DHT11_PIN);//read the value returned from sensorswitch (chk){case DHTLIB_OK: //Serial.println(OK!); break;case DHTLIB_ERROR_CHECKSUM: //goto D;//Serial.print(Checksum error,\t); break;case DHTLIB_ERROR_TIMEOUT: //goto D;//Serial.print(Time out error,\t); break;default: // goto D;//Serial.print(Unknown error,\t); break;}// DISPLAY DATAlcd.setCursor(0, 0);lcd.print(Tem:);//Serial.print(Tem:);lcd.print(DHT.temperature,1); //print the temperature on lcd wendu DHT.temperature;
/*Serial.print(wendu:);Serial.print(wendu);Serial.print(\n);
*/Serial.print(cmduploaddevice_nametempdata);Serial.print(wendu);//send a random numberSerial.println(uidbeyondyykey6d2cc6e3e19efa259a302fcf4166e2ce);lcd.print(char(223));//print the unit ℃ lcd.print(C);// Serial.println( C);lcd.setCursor(0, 1);lcd.print(Hum:);//Serial.print(Hum:);lcd.print(DHT.humidity,1); //print the humidity on lcdshidu DHT.humidity;/*Serial.print(shidu:);Serial.print(shidu);Serial.print(\n);*/Serial.print(cmduploaddevice_namehumidata);Serial.print(shidu);//send a random numberSerial.println(uidbeyondyykey6d2cc6e3e19efa259a302fcf4166e2ce);lcd.print( %); //Serial.println( %);delay(200); //wait a while outputValue analogRead(photocellPin);//read the value of photoresistor//Serial.println(outputValue); //print it in serial monitorif(outputValue 500) //else{digitalWrite(buzzerPin,LOW);analogWrite(redPin, 255); //red value decreaseanalogWrite(greenPin, 0); //green value decreasedelay(100);//Serial.println(val, DEC);}else{digitalWrite(buzzerPin,HIGH);analogWrite(greenPin, 255); //green value decreaseanalogWrite(redPin, 0); //red value decreasedelay(100);}delay(1000); //delay 1s}
所需库下载连接 将下载好的压缩包解压把文件Dht复制到你的编译器Arduino的libraries文件夹下
五、视频效果演示 基于Arduino UNO R3开发板的安全检测系统的实现---DHT11数据采集上云视频链接CSDN 视频链接B站