Header Ads

Temperature,Humidity and Pressure sensor data find using Arduino .(BMP180,DHT11)


******************************DHT11*****************
#include <DHT.h>
// for DHT11,  VCC: 5V or 3V,GND: GND,DATA: 2
int pinDHT11 = 2;
DHT11 dht11;
void setup() {
  Serial.begin(9600);
}

void loop() {
  // start working...
  Serial.println("************************");
  Serial.println("DHT11...");
    byte temperature = 0;
  byte humidity = 0;
  int err = DHTErrSuccess;
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != DHTErrSuccess) {
    Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000);
    return;
  }
   Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" H");
    delay(1500);
}
*************************************BMP180***************
#include <Wire.h>
#include <Adafruit_BMP085.h>
  products from Adafruit!
// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
                Serial.println("Could not find a valid BMP085 sensor, check wiring!");
                while (1) {}
  }
}
 
void loop() {
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
     Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");
     Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude());
    Serial.println(" meters");
    Serial.print("Pressure at sealevel (calculated) = ");
    Serial.print(bmp.readSealevelPressure());
    Serial.println(" Pa");
 Serial.print("Real altitude = ");
    Serial.print(bmp.readAltitude(101500));
    Serial.println(" meters");
   
    Serial.println();
    delay(1500);
}

No comments

Theme images by Matt Vince. Powered by Blogger.