Вы находитесь на странице: 1из 5

#include <dht.

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 )-----*/

/*-----( Declare objects )-----*/


LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address Ox3F (Check yours)
RTC_DS1307 rtc;
// Create a RealTimeClock object (I set the time in another sketch)
/*-----( Declare Variables )-----*/
dht DHT;
#define DHT11_PIN 2 // use pin 2 on UNO to sample data from DHT module
void setup()
{
Serial.begin(9600);
Serial.println("DHT TEST PROGRAM ");
Serial.print("DHT LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Serial.println("Humidity % \tTemperature (C) \tTime \tDate");
lcd.begin(16,2); // defines it is a 16 character two line display
rtc.begin(); // Start the RTC library code
}
void loop()
{
// READ DATA
DateTime now = rtc.now();
int chk = DHT.read11(DHT11_PIN);
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print("\t");
Serial.print(DHT.temperature, 1);
Serial.print(",\t");
Serial.print("\t");
Serial.print("\t");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.println(now.year(), DEC);
lcd.setCursor(0,0); // start postion of Humidity text on LCD
lcd.print(DHT.humidity, 0); // 0 creates whole number, 1 two decimal

lcd.print("% Humidity ");


lcd.setCursor(0,1); // start postion of temperature text on LCD
lcd.print(DHT.temperature, 0);
lcd.print(" C");
lcd.setCursor(6,1); // start postion of time text on LCD
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print('.');
lcd.print(now.second(), DEC);
// You can display in lcd by changing Serial to lcd I have only used time above not date
//Serial.print(now.year(), DEC);
//Serial.print('/');
//Serial.print(now.month(), DEC);
//Serial.print('/');
//Serial.print(now.day(), DEC);
//Serial.print(' ');
//Serial.print(now.hour(), DEC);
//Serial.print(':');
//Serial.print(now.minute(), DEC);
//Serial.print(':');
//Serial.print(now.second(), DEC);
//Serial.println();
delay(1000); // screen - sample & LCD refresh time 1 second although DHT say min 2 seconds but works ok.
}

#include <LiquidCrystal.h>
#include <dht.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


int greenPin = A0;
dht sensor;

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

Вам также может понравиться