Hi, this is my second class of learning arduino and I am trying to make my arduino project using arduino uno, water pumps,relay(for the water pumps) ,extra batteries for pump, 9v battery for the arduino power source (but in this picture I tested it out, still connected to my pc), temperature and humidity sensor(DHT11) , soil moisture sensor(the cheap one) and a I2C lcd display and a LED light to indicate that the soil moisture level is low. SO heres a picture
Somehow, the figures I got for the temperature initally was correct, around 24-25 degrees Celsius, then suddenly it skyrockets to 253 celsius, and it happens everytime I restarted the circuit. It starts off perfectly, then stays at a really high temperature. Can someone tell me why this is happening please...
EDIT: here is the code
#include <LiquidCrystal_I2C.h>
#include <DHT11.h>
#define DHTTYPE DHT11
#define THpin 7
float temp;
DHT11 dht11(THpin);
#define TRIG_PIN 3
#define ECHO_PIN 4
#define SOIL_HUMI A3
#define Relay 2 //pump relay
#define LED 8
//defining status of soil according to soil moisture readings
//>900 = dry
//500 - 900= wet
//0-500 = wet
#define POINT 800
#define DELAY_TIME 3000
LiquidCrystal_I2C lcd (0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
lcd.init();
lcd.backlight();
Serial.begin(9600);
pinMode(LED,OUTPUT);
pinMode(SOIL_HUMI, INPUT);
pinMode(Relay,OUTPUT);
digitalWrite(SOIL_HUMI, LOW);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
temp=dht11.readTemperature();
int sHumi= analogRead(SOIL_HUMI);
//print on serial monitor, soil humidity, temperature and humidity
Serial.print("Soil humidity value: ");
Serial.print(sHumi);
Serial.print("\t Temperature: ");
Serial.println(temp);
//display temperature and humidity on lcd
//first line
lcd.setCursor(0,0);
lcd.print("Temp :");
lcd.print(temp);
//second line
lcd.setCursor(0,1);
lcd.print("Soil Humi :");
lcd.print(sHumi);
if (sHumi<POINT){
//on water pump, when soil moisture is low
digitalWrite(Relay, HIGH);
digitalWrite(LED,HIGH);
}
else{
//off waterpump, when soil moisture is above index
digitalWrite(Relay,LOW);
digitalWrite(LED,LOW);
}
//one second interval between each reading
delay(DELAY_TIME);
}
end , as you might have noticed I included some code in the define for a ultrasonic sensor to be included later to measure distance from the top of the bucket to measure the water level.
