Академический Документы
Профессиональный Документы
Культура Документы
h>
dht DHT;
#define DHT11_PIN 5
void setup()
{
Serial.begin(115200);
Serial.println("DHT TEST PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop()
{
// READ DATA
Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
case DHTLIB_ERROR_CONNECT:
Serial.print("Connect error,\t");
break;
case DHTLIB_ERROR_ACK_L:
Serial.print("Ack Low error,\t");
break;
case DHTLIB_ERROR_ACK_H:
Serial.print("Ack High error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
delay(2000);
}
#include
#include
#include
#include
/*-----(
<Wire.h>
// In standard library
<dht.h>
// https://arduino-info.wikispaces.com/TemperatureHumidity
<LiquidCrystal_I2C.h> // https://arduino-info.wikispaces.com/LCD-Blue-I2C
"RTClib.h"
// https://arduino-info.wikispaces.com/DS1307_RealTime_Clock_Brick
Declare Constants )-----*/
#include <LiquidCrystal.h>
#include <dht.h>
void setup()
{
lcd.begin(16,2); //16 by 2 character display
}
void loop()
{
delay(1000); //wait a sec (recommended for DHT11)
sensor.read11(greenPin);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Humidity = ");
lcd.print(sensor.humidity);
lcd.setCursor(0,1);
lcd.print("Temp = ");
lcd.print(sensor.temperature);
}
<p>#include <wire.h>
#include <lcd.h>
#include
<liquidcrystal_i2c.h>
#include "DHT.h"
#include
<sfe_bmp180.h></sfe_bmp180.h></liquidcrystal_i2c.h></lcd.h></wire.h></p><p
>SFE_BMP180 pressure;</p><p>#define ALTITUDE 20.56
#define I2C_ADDR 0x27 // <<- Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7</p><p>#define DHTPIN 2
// what digital pin we're
connected to</p><p>// Uncomment whatever type you're using!
//#define DHTTYPE DHT11
// DHT 11
#define DHTTYPE DHT22
// DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C
lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
float t1,t2; </p><p>
void setup()
{
Serial.begin(9600);
lcd.begin (16,2); // <<-- our LCD is a 20x4, change for your LCD if
needed
// LCD Backlight ON
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home on LCD
lcd.print("Weather Station");
delay(5000);
dht.begin();
pressure.begin();
}
void loop()
{
char status;
double T,P,p0,a;
status = pressure.startTemperature();
if (status != 0)
{
delay(status);</p><p>
if (status != 0)
{
Serial.print("1");
status = pressure.getTemperature(T);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Baro Temperature: ");
lcd.setCursor(0,1);
lcd.print(T,2);
lcd.print(" deg C ");
t1=T;
delay(3000);</p><p>
status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);</p><p>
status = pressure.getPressure(P,T);
if (status != 0)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("abslt pressure: ");
lcd.setCursor(0,1);
lcd.print(P,2);
lcd.print(" mb ");
delay(3000);</p><p>
p0 = pressure.sealevel(P,ALTITUDE);
// we're at 1655 meters (Boulder, CO)</p><p>
a =
pressure.altitude(P,p0);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Altitude: ");
lcd.setCursor(0,1);
lcd.print(a,0);
lcd.print(" meters");
delay(3000);
}
}
}
}
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
t2=t;
lcd.clear();
lcd.setCursor (0,0); // go to start of 2nd line
lcd.print("Humidity: ");
lcd.setCursor(0,1);lcd.print(h);
lcd.print(" %");
delay(3000);
lcd.clear();
lcd.setCursor (0,0); // go to start of 2nd line
lcd.print("DHT Tempurature: ");
lcd.setCursor(0,1);
lcd.print(t);
lcd.print(" deg C ");
delay(3000);
lcd.clear();
lcd.setCursor (0,0); // go to start of 2nd line
lcd.print("Mean Tempurature: ");
lcd.setCursor(0,1);
lcd.print((t1+t2)/2);
lcd.print(" deg C ");
delay(3000);
https://forum.arduino.cc/index.php?topic=385496.0