#include #include // Set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); //LiquidCrystal_I2C lcd(0x3F, 16, 2); //www.elegoo.com //2018.10.25 #include #define DHT_SENSOR_TYPE DHT_TYPE_11 static const int DHT_SENSOR_PIN = 2; DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE ); /* * Initialize the serial port. */ void setup( ) { Serial.begin( 9600); } /* * Poll for a measurement, keeping the state machine alive. Returns * true if a measurement is available. */ static bool measure_environment( float *temperature, float *humidity ) { static unsigned long measurement_timestamp = millis( ); /* Measure once every four seconds. */ if( millis( ) - measurement_timestamp > 3000ul ) { if( dht_sensor.measure( temperature, humidity ) == true ) { measurement_timestamp = millis( ); return( true ); } } return( false ); } /* * Main program loop. */ void loop( ) { float temperature; float humidity; /* Measure temperature and humidity. If the functions returns true, then a measurement is available. */ if( measure_environment( &temperature, &humidity ) == true ) { Serial.print( "T = " ); Serial.print( temperature, 1 ); Serial.print( " deg. C, H = " ); Serial.print( humidity, 1 ); Serial.println( "%" ); // Robojax code for LCD with I2C // initialize the LCD, lcd.begin(); // Turn on the blacklight and print a message. lcd.backlight(); // Robojax code for LCD with I2C //start of loop Robojax code for LCD with I2C lcd.clear(); lcd.print("Temp = "); lcd.print(temperature); lcd.setCursor (0,1); // go to start of 2nd line lcd.print("Humidity= "); lcd.print(humidity); //lcd.print(millis() / 1000); delay(500); //end of loopcode Robojax code for LCD with I2C } } /* This is code for LCD1602 Display with I2C module * watch the video for this code https://youtu.be/q9YC_GVHy5A * Permission granted to share this code given that this * note is kept with the code. * Disclaimer: this code is "AS IS" and for educational purpose only. * This library is based on work done by DFROBOT (www.dfrobot.com). */ /* * This code has been modefied from the Arduino library * Updated by Ahmad Nejrabi on Jan 20, 2018 at 11:09 * in Ajax, Ontario, Canada * for Robojax.com * * This is code for LCD1602 Display with I2C module * which can display text on the screen. */