Like the title says, the temp measured from a DHT 11 sensor only updates when i reset it. While humidity updates how it's supposed to. The wiring is correct as everything works in Serial Monitor. I'll try my best to fix it but if i could get a bit of help I'll appreciate it!
//www.elegoo.com
//2018.10.25
#include <LiquidCrystal.h>
#include <dht_nonblocking.h>
#define DHT_SENSOR_TYPE DHT_TYPE_11
static const int DHT_SENSOR_PIN = 8;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
/*
* Initialize the serial port.
*/
void setup( )
{
lcd.begin(16, 2);
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*1.8+32);
Serial.print( " F, H = " );
Serial.print( humidity, 1 );
Serial.println( "%" );
lcd.print( "Temp = " );
lcd.print(temperature*1.8+32);
lcd.print( "F" );
lcd.setCursor(0,1);
lcd.print( "Humid = " );
lcd.print( humidity, 1 );
lcd.println( "% " );
}
}