My code:
#include <SFE_BMP180.h>
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal.h>
// You will need to create an SFE_BMP180 object, here called "pressure":
SFE_BMP180 pressure;
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define DHTPIN 8 // what pin we're connected to
#define ALTITUDE 18.0 // Altitude of Karwan bazar in meters
DHT dht(DHTPIN, DHT11);
void setup()
{
Serial.begin(9600);
Serial.println("REBOOT");
lcd.begin(20, 4);
// Initialize the sensor (it is important to get calibration values stored on the device).
if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// something went wrong, this is usually a connection problem,
Serial.println("BMP180 init fail\n\n");
while(1); // Pause forever.
}
}
void loop()
{
char status;
double T,P,p0,a;
Serial.println();
status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Function returns 1 if successful, 0 if failure.
status = pressure.getTemperature(T);
if (status != 0)
{
// Print out the measurement:
Serial.print("T: ");
Serial.print(T,2);
lcd.setCursor(0, 0);
lcd.print("T=");
lcd.setCursor(2, 0);
lcd.print(T,2);
lcd.setCursor(6, 0);
lcd.print(" deg C ");
Serial.print(" deg C, ");
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
status = pressure.getPressure(P,T);
if (status != 0)
{
// Print out the measurement:
Serial.print("P: ");
Serial.print(P/10,2);
Serial.println(" kPa");
lcd.setCursor(0, 1);
lcd.print("P= ");
lcd.setCursor(2, 1);
lcd.print(P/10,2);
lcd.setCursor(9, 1);
lcd.print("kPa");
p0 = pressure.sealevel(P,ALTITUDE);
Serial.print("P(Sea-level): ");
Serial.print(p0/10,2);
Serial.println(" kPa");
lcd.setCursor(0, 2);
lcd.print("P0= ");
lcd.setCursor(3, 2);
lcd.print(p0/10,2);
lcd.setCursor(9, 2);
lcd.print("kPa");
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}
else Serial.println("error retrieving temperature measurement\n");
}
else Serial.println("error starting temperature measurement\n");
int sensorValue = analogRead(A0);
float outvoltage = sensorValue * (5.0 / 1023.0);
int Level = 6*outvoltage;//The level of wind speed is proportional to the output voltage.
Serial.print("V= ");
Serial.print(Level);
Serial.println(" m/s");
Serial.println();
lcd.setCursor(0, 3);
lcd.print("V= ");
lcd.setCursor(2, 3);
lcd.print(Level);
lcd.setCursor(4,3);
lcd.print("m/s");
switch(dht.read())
{
case DHT_OK:
lcd.setCursor(9,3);
lcd.print("Hum=");
lcd.print(dht.humidity);
lcd.print("%");
break;
case DHT_ERR_CHECK:
lcd.clear();
lcd.setCursor(9,3);
lcd.print("Error");
break;
case DHT_ERR_TIMEOUT:
lcd.clear();
lcd.setCursor(9,3);
lcd.print("Error");
break;
}
delay(5000); // Pause for 5 seconds.
}
this error show what is the problem?
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
D:\technology\Final Year project\Weather Station\Weather_station\Weather_station.ino: In function 'void loop()':
Weather_station:142:10: error: 'DHT_OK' was not declared in this scope
case DHT_OK:
^~~~~~
D:\technology\Final Year project\Weather Station\Weather_station\Weather_station.ino:142:10: note: suggested alternative: 'DHT_H'
case DHT_OK:
^~~~~~
DHT_H
Weather_station:147:21: error: 'class DHT' has no member named 'humidity'; did you mean 'readHumidity'?
lcd.print(dht.humidity);
^~~~~~~~
readHumidity
Weather_station:150:10: error: 'DHT_ERR_CHECK' was not declared in this scope
case DHT_ERR_CHECK:
^~~~~~~~~~~~~
Weather_station:156:10: error: 'DHT_ERR_TIMEOUT' was not declared in this scope
case DHT_ERR_TIMEOUT:
^~~~~~~~~~~~~~~
Multiple libraries were found for "DHT.h"
Used: C:\Users\Akash\Documents\Arduino\libraries\DHT_sensor_library
Not used: C:\Users\Akash\Documents\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor-master
exit status 1
'DHT_OK' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.