Hi guys, i´m new in this Arduino world, and i´m having a issue, that i am not able to solve by my self, maybe you can help:
I have this code here:
#include <LiquidCrystal.h>
#include <dht_nonblocking.h>
#define VELOCIDAD 300
#define DHT_SENSOR_TYPE DHT_TYPE_11
LiquidCrystal lcd(12,11,5,4,3,2);
const int Bombapin =10;
const int Waterpin =A0;
int thresholdValue = 800;
const float temperature;
const float humidity;
static const int DHTpin = 6;
DHT_nonblocking dht_sensor( DHTpin, DHT_SENSOR_TYPE );
//Texto
String texto_humedad = "Humedad incorrecta, activando riego";
String texto_optimo = "Humedad de tierra optima";
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(Bombapin, OUTPUT);
}
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 );
}
void loop() {
int tam_texto1=texto_humedad.length();
int tam_texto2=texto_optimo.length();
int sensorValue = analogRead(Waterpin);
if( measure_environment( &temperature, &humidity ) == true )
{
Serial.print("\nt = ");
Serial.print(temperature, 1);
Serial.print(" - H = ");
Serial.print(humidity,1);
Serial.print("%");
Serial.print("dentro");
}
Serial.print("fuera");
lcd.setCursor(0,0);
lcd.print("Hum Tierr:");
lcd.print(sensorValue);
I have the function: "measure_environment" is a boolean, so nothing complicated...
The thing is that in the void loop i have a condition to print "dentro" =in and "fuera"=out, it always prints out...that means that the function is returning a false value...the interesting part is that when i only have this part of code, this works just fine...anyone could please help me?