Arduino Uno Weather station program error...

So im Currently Programming a weather station using the arduino uno..But im getting a very annoying error which i cannot figure out.The error in question is

C:\Program Files (x86)\Arduino/Weatherstation.ino:127: undefined reference to `dht11::read(int)'

I have had so much trouble with this code from the beginning but this is hopefully the last error i will face.I need a response ASAP as this is a school project and needs to be completed pretty soon.I have attached the code im using,

Thanks in advance,
Oliver Ferris.

Inputs : DHT11
LDR
10K Potentiometer (Lcd contrast control)
Push Switch (Change info displayed)

Outputs: LCD 2x16

#include <dht11.h>



#include <LiquidCrystal.h>





//initialize DHT11
dht11 DHT11;

// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//pin declaration
int lightPin = A0;
int dhtPin = A1;
int buttonPin = 7;

unsigned long cur = 0;
unsigned long measurementFrequency = 1000;
unsigned long lastMeasurement = 0;
int measurementValue = 0;

int lastButtonState = LOW;
unsigned long lastDebounce = 0;
unsigned long buttonDebounceDelay = 250;

int currMode = 0;
boolean modeChanged = false;

boolean isPing = false;
unsigned long lastPing = 0;
unsigned long pingDelay = 250;

void setup() {
  
  //debug
  //Serial.begin(9600);
  
  //setup LCD
  lcd.begin(16,2);

  //print welcome text
  lcd.setCursor(3,0);
  lcd.print("Welcome to");
  lcd.setCursor(2,1);
  lcd.print("Olivers Weather Station!");
  delay(3000);
  lcd.clear();

}

void loop() {
  
  //record current time in milliseconds
  cur = millis();

  //see if we need to measure
  if ((cur - lastMeasurement > measurementFrequency) || modeChanged) {
    
    //control members
    lastMeasurement = cur;
    lastPing = cur;
    modeChanged = false;
    
    //do the work
    measureAndDisplay();
    
    //make the ping (blink an asterisk)
    ping();
  }
  
  //check if blinking
  if (isPing && cur - lastPing > pingDelay) pong();
    
  //monitor if button pressed
  int currentButtonState = digitalRead(buttonPin);
  if ((currentButtonState != lastButtonState) && (currentButtonState == HIGH) && (cur - lastDebounce > buttonDebounceDelay)) {
    lastDebounce = cur;
    if (currMode == 2) currMode = 0;
    else currMode = currMode + 1;
    modeChanged = true;
  }
  //debug
  //Serial.println(currentButtonState);
}

void measureAndDisplay() {
    //clear the display
    lcd.clear();
    switch (currMode) {
      //0: temperature - read DHT11.temperature and write it out
      case 0:
        DHT11.read(dhtPin);
        measurementValue = DHT11.temperature;
        lcd.setCursor(2,0);
        lcd.print("Temperature:");
        lcd.setCursor(2,1);
        lcd.print(measurementValue); 
        lcd.print(char(223)); 
        lcd.print("C - ");
        int toFarenheit;
        toFarenheit = (measurementValue * 1.8 + 32); //for our American friends
        lcd.print(toFarenheit);
        lcd.print(char(223)); 
        lcd.print("F");
        break;
      case 1:
      //1: humidity - read DHT11.humidity and write it out in %
        measurementValue = DHT11.humidity;
        lcd.setCursor(4,0);
        lcd.print("Humidity");
        lcd.setCursor(7,1);
        lcd.print(measurementValue);
        lcd.print("%");
        break;
      case 2:
        //2: light intensity - read the light sensor and output the value in %.
        //This can be converted into Lux, but I believe this setup is not precise enough.
        measurementValue = analogRead(lightPin);
        measurementValue = map(measurementValue, 0, 1023, 100, 0);
        lcd.setCursor(0,0);
        lcd.print("Light Intensity");
        lcd.setCursor(7,1);
        lcd.print(measurementValue);
        lcd.print("%");
        break;
    }
}

//show asterisk
void ping() {
  lcd.setCursor(15,1);
  lcd.print("*");
  isPing = true;
  //debug
  //Serial.println("Ping");
}

//clear asterisk
void pong() {
  lcd.setCursor(15,1);
  lcd.print(" ");
  isPing = false;
  //debug
  //Serial.println("Pong");
}

Anybody Have any solutions?

I pulled the library from the playground page, restarted the IDE and it compiled fine.

Sounds like an issue with your library installation.

Thanks for the reply...Would you mind walking me though the steps for setting up the Lib?

From this page: DHT11Lib:

To use the library, make a folder in your SKETCHBOOKPATH\libaries with the name DHT11 and put the .h and .cpp there. Optionally make a examples subdirectory to place the sample app. Be aware that the library will only be visible after restarting all instances of the Arduino IDE.

Thanks,
I have followed all of your steps but i am now facing this error:

C:\Users\oliver\Documents\Arduino\libraries\DHT11\dht11.cpp: In member function 'int dht11::read(int)':
C:\Users\oliver\Documents\Arduino\libraries\DHT11\dht11.cpp:64: error: expected `}' at end of input

any ideas whats causing this?

Where did you get the library from and which version of the IDE are you using?

it seems to be a corrupted lib. Line 64 seems to be in the middle of the file.

Which version of the IDE are you using...

find attached my latest version of the .ccp and .h file (just compiled your code with it)

dht11.zip (1.8 KB)

Im using the 1.0.6 version of the IDE...And i got the libraries from wildbill above

Try the files robtillaart attached, and post your results.

I get this error when i use the Lib supplied by robtillaart

statioin.ino:36:10: error: #include expects "FILENAME" or
statioin.ino:37:10: error: #include expects "FILENAME" or

When I said use, I meant copy the dht11.h and dht11.h to where your current libraries are, and that would not involve changing your code. You need to download the zip file, extract it and copy the contents to the correct place in your libraries. It should over write two files.

Thanks for all your help guys...Its now working..But having another Issue :confused:

avrdude: stk500_getsync(): not in sync: resp=0x30

Serial problems . Open serial monitor in IDE then close it . Try using another serial port .
Maybe even re-starting your computer might help depending on which code is causing this problem . Had the same error when I wrote serial.begin in Uno . Which serial codes have you used ?
Because serial.begin is commented in the code .

Hi there,

Followed your instructions and restarted my Pc..But still no luck...Also the Serial monitor is blank when i open it

I suppose before that error , a pop-up appears stating that the com port you were using is 'busy' and that you could open another one ?
I once had this error , when working with serial , but it was solved with opening and closing the serial monitor .
:slightly_frowning_face: