I am trying to combine the DHT22 library with the Liquid Crystal library to display Temp and Humidity on a 16,2 LDC display. This is the code I have so far.
// include the library code:
#include <LiquidCrystal.h>
// include DHT lib
#include <DHT22.h>
// connect dht data to pin 7
#define DHT22_PIN 7
// Setup DHT instance
DHT22 myDHT22(DHT22_PIN);
// initialize the lcd library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(" TEMP HUM");
}
void loop(void)
{
DHT22_ERROR_t errorCode;
delay(15000);
errorCode = myDHT22.readData();
switch(errorCode)
{
case DHT_ERROR_NONE:
lcd.setCursor(2,1);
lcd.print(myDHT22.getTemperatureC());
lcd.print("C ");
lcd.setCursor(10,1);
lcd.print(myDHT22.getHumidity());
lcd.println("%");
break;
case DHT_ERROR_CHECKSUM:
lcd.setCursor(2,1);
lcd.print(myDHT22.getTemperatureC());
lcd.print("C ");
lcd.setCursor(6,1);
lcd.print("SMER");
lcd.setCursor(10,1);
lcd.print(myDHT22.getHumidity());
lcd.println("%");
break;
case DHT_BUS_HUNG:
lcd.setCursor(4,1);
lcd.println("BUS Hung ");
break;
case DHT_ERROR_NOT_PRESENT:
lcd.setCursor(4,1);
lcd.println("Not Present ");
break;
case DHT_ERROR_ACK_TOO_LONG:
lcd.setCursor(4,1);
lcd.println("ACK time out ");
break;
case DHT_ERROR_SYNC_TIMEOUT:
lcd.setCursor(4,1);
lcd.println("Sync Timeout ");
break;
case DHT_ERROR_DATA_TIMEOUT:
lcd.setCursor(4,1);
lcd.println("Data Timeout ");
break;
case DHT_ERROR_TOOQUICK:
lcd.setCursor(4,1);
lcd.println("Polled to quick ");
break;
}
}
This is the errors I get
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:47:24: error: WConstants.h: No such file or directory
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp: In constructor 'DHT22::DHT22(uint8_t)':
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:64: error: 'digitalPinToBitMask' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:65: error: 'digitalPinToPort' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:65: error: 'portInputRegister' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:66: error: 'millis' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp: In member function 'DHT22_ERROR_t DHT22::readData()':
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:90: error: 'millis' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:115: error: 'delayMicroseconds' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:122: error: 'delayMicroseconds' was not declared in this scope
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp: In member function 'void DHT22::clockReset()':
C:\Users\Documents\Arduino\libraries\DHT22\DHT22.cpp:242: error: 'millis' was not declared in this scope
I do not understand what to do to fix these errors. I am guessing it has something with the .cpp however I do not know how to fix it. Any efforts to help me figure this out is greatly appreciated.