I am making a water pump system for plants and I am running into trouble with displaying my Temperature and Humidity values. I am using a 20x4 LCD, Arduino board uno, Capacitive soil moisture sensor, 5v DC water pump, DHT22, and a single relay. When the motor is on, the display first shows the values as expected. Then, all of a sudden random characters fill and move across my screen. When I don't connect my motor to the Arduino, the values show up on the LCD as expected. Please do leave comments so that I am able to improve my code. Thanks.
//Libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
//Pins Used
#define DHTpin 2
#define DHTtype DHT22
//Initialization
DHT dht(DHTpin, DHTtype);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int sensor_pin = 0; // Soil Sensor input at Analog PIN A0
int pinValue;
int output_value ;
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT);
Serial.begin(9600);
Serial.println("Reading From the Sensor ...");
lcd.begin(20, 4);
delay(4000);
}
// put your main code here, to run repeatedly:
void loop() {
lcd.clear();
dht.begin();
float humid = dht.readHumidity();
float temp = dht.readTemperature();
lcd.setCursor(0, 2);
lcd.print("Temperature: ");
lcd.print(temp);
lcd.print("C");
lcd.setCursor(0, 3);
lcd.print("Humidity: ");
lcd.print(humid);
lcd.print("%");
pinValue = analogRead(sensor_pin);
output_value = map(pinValue,700, 300,0,100);
Serial.print("Mositure : ");
Serial.print(output_value);
Serial.println("%");
if(output_value> 0 && output_value <= 51){
digitalWrite(3,LOW);
lcd.setCursor(0,0);
lcd.print("ON");
lcd.setCursor(0,1);
lcd.print("MOISTURE VAL: ");
lcd.print(output_value);
lcd.print("%");
delay(1000);
}else if(output_value > 51 && output_value <= 100){
digitalWrite(3,HIGH);
lcd.setCursor(0,0);
lcd.print("OFF");
lcd.setCursor(0,1);
lcd.print("MOISTURE VAL: ");
lcd.print(output_value);
lcd.print("%");
delay(1000);
}
delay(1000);
}
EDIT (1)
Here are some pics of the circuitry and the LCD message. If you find these pictures to not be helpful, I can sketch this circuit. Thank You.

