I need help with my project for hydroponics

I am having trouble with making my Arduino. I am trying to make it so that when when you press a button it will show the temperature and humidity I have done this in tinkercad but I need help making a liquid temperature sensor and a humidity sensor.


could someone just fix the temperature sensor in this one?
Here is my code
#include <LiquidCrystal.h>

define btn2 12

define btn1 13

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd (2, 3, 4, 5, 6, 7);

int sensorPin = 0;
char* test [] = {"Water", "Humid"};

void setup()
{
Serial.begin(9600);
lcd.begin(16, 3);

lcd.setCursor(0,0);
lcd.print(">");
lcd.setCursor(1,0);
lcd.print("Water and humidity");
lcd.setCursor(0,1);
lcd.print(test[0]);
lcd.setCursor(8,1);
lcd.print(test[1]);
}

void loop(){

if(digitalRead(btn1) == HIGH)
{

delay(100);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Water Temp");
lcd.setCursor(5,1);
lcd.print(test[0]);
lcd.clear();

int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100 ;
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
lcd.print(temperatureF);
lcd.println(" degrees F ");
lcd.setCursor(0,1);
lcd.print(temperatureC);
lcd.println(" degrees C ");

}
if(digitalRead(btn2) == HIGH)
{
lcd.clear();
delay(100);
lcd.setCursor(0,0);
lcd.print("Humidity");
lcd.setCursor(5,1);
lcd.print(test[1]);
}

}

Help us help you.

1 Like

Please edit your post to add code tags.

1 Like

Post an annotated schematic, your frizz picture is missing a lot and is useless. Post links to Technical information on each of the hardware items. At this point I do not have a clue as to what you have. For example you show a LCD display with 3 wires, some are missing you you mention OLED????

image

Not everyone has a Tinkercad account.

It's handy that pins to default to inputs, isn't it?

(Even handier if they defaulted to INPUT_PULLUP, IMO)

They default to high impedance (essentially disconnected) as that is the lowest power, most innocuous option.

I know that, it was a hint to the OP :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.