I am playing around with 2 different sensors, one being a temp/humidity and the other a water sensor. I can get the temp and humidity to display just fine, and I can get the water sensor "Water Detected" to work without the other code. What I am trying to achieve is having the temp and humidity displayed, but when water is detected to display "Water Detected" until the water goes away. Any help is appreciated.
Yes. If I run just the temp/hum sensor it works just fine. If I run the water sensor code it works just fine. But combined, I don't think my if statement is correct.
gcjr:
why do you conditionally either display water or humidity info?
why not read and display both
The LCD only has "two lines" it can display at a time, so there isn't enough room for all the data
The water info isn't important until water is detected. Such as a flooded mechanical room, but having the temp and humidity display at all times is more important.
What is happening when you run the code?
Without knowing what is happening we can't really help.
The first thing I note in your code is you do not clear the display before sending the Temp/Humidity info, this can lead to scrambled characters if the the new message doesn't over write the "water detected" message completely.
My thoughts exactly, in fact set up serial print for all the information and see whether the issue is with the LCD not clearing properly between displays, I would also slow it down further by delaying for at least 5 seconds per step. (I know delay should not be used in most cases, but I don't think it is an issue here).
gritpit:
Yes I responded, but didn't quote. My response was #4.
But all you said was, "works real fine". That doesn't tell me much. I'd like to know what actual ADC input values you are getting. I have no visibility to the other ("water sensor is working") program either, since you didn't post it.
Kiwi_Bloke:
My thoughts exactly, in fact set up serial print for all the information and see whether the issue is with the LCD not clearing properly between displays, I would also slow it down further by delaying for at least 5 seconds per step. (I know delay should not be used in most cases, but I don't think it is an issue here).
I ended up modifying my code a bit, and adding in the 5 second delay and got it to work the way I was intending.
aarg:
But all you said was, "works real fine". That doesn't tell me much. I'd like to know what actual ADC input values you are getting. I have no visibility to the other ("water sensor is working") program either, since you didn't post it.
I'll communicate better next time. This was my first post. I apologize.
void setup(){
Serial.begin(9600); // Communication started with 9600 baud
}
void loop(){
int sensor=analogRead(A1); // Incoming analog signal read and appointed sensor
Serial.println(sensor); //Wrote serial port
}
Can you just tell us what a typical value is printed when the sensor is A) wet, B) dry.
Also, this sketch appears to be written for a different board because it uses A0 instead of pin 8. Please explain. To be useful for troubleshooting, you would definitely have to use the same board!