Auto watering system, using soil moisture sensor arduino

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.

No, no one can do that. They would have to have psychic superpowers.

Please read the forum guide in the sticky post, then edit your post and add all the things that are needed to allow forum members to help you.

EDIT: All the things...

Hi~, may I ask what else do I need to provide in order for people to understand what's happening in my project? Do I include like descriptions and pictures of parts of my arduino?

Good luck with your project.

tq!

Start with schematics.

Replace that with:

  lcd.setCursor(0,0);
  lcd.print("Temp :");
  lcd.setCursor(0,6);
  lcd.print("      "); // 6 spaces
  lcd.setCursor(0,6);
  lcd.print(temp);
  // second line

Do you have a pull-up resistor on the DHT11 data line?

A rats nest of wires and a solderless breadboard sometimes just don't provide a stable and reliable set-up. Try to tidy things up a little

1 Like

Does the temperature reading increase when you increase the temperature on the sensor?

Are the connections on the breadboard ok? I've found in the past that solderless breadboards give mixed results for sensor readings and much prefer solder connections (give them a wiggle and watch the screen).

Could this be a display error, displaying 253 instead of 25.3?

This won't solve your problem but will allow you to post a little more information here to help get that result.

As a beginner this is where I'd look to help isolate the cause of your error.

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