Circuit Power Problem

Hey, first of all a small description of my project...
I've got a smart irrigation system, arduino, lcd and 3 sensors are powered by a li-ion battery connected to CN3065, a charger that allows me to use solar panels to charge my batteries.The output is connected to a 5V usb step_up that allows me to power up arduino, and it works ok.
The 5v water pump connected to a 5v relay and 4 buttons are powered by another li ion battery connected to another charger and 5V step_up for the breadboard.The problem is, when water pump starts everything freezes and LCD screen goes crazy.If I don't use the pump everything works ok.
Links to the hardware:
Relay : 5V Single-Channel Relay Module - Pin Diagram, Specifications, Applications, Working
Water Pump: https://5.imimg.com/data5/IQ/GJ/PF/SELLER-1833510/dc-mini-submersible-water-pump.pdf
The 5V step_ups:0.9V-5V input, 5V USB Output Boost Regulator Module [CE8301] - US $0.70 : HAOYU Electronics : Make Engineers Job Easier
https://de.aliexpress.com/i/4001143782139.html?gatewayAdapt=glo2deu
Charger: CN3065 Datasheet(PDF) - Shanghai Consonance Electronics Incorporated
Any advice would help me!
A fritzing drawing to show an idea about how I wired my circuit:


I've tried in KiCad to do a schematic, I'm still learning:

This is the code:

#include <LiquidCrystal.h>
#include <DHT.h>

// set the DHT Pin
#define DHTPIN 6

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

float tempC;
float hum;
int motorPin = 7; // pin that turns on the motor

int watertime = 10; // how long it will be watering (in seconds)
int moisturelevel = 40; //when the pump starts

//initialize buttons
const int b1incrtime = 13;
const int b2decrtime = 10;
const int b3incrlevel = 9;
const int b4decrlevel = 8;

int button1State = 0;
int button2State = 0;
int button3State = 0;
int button4State = 0;


void setup() {


  // set up the LCD's number of columns and rows:
  lcd.begin(16, 4);
  dht.begin();

//buttons
  pinMode(b1incrtime, INPUT);
  pinMode(b2decrtime, INPUT);
  pinMode(b3incrlevel, INPUT);
  pinMode(b4decrlevel, INPUT);

}

void loop() {

  //buttons
  button1State = digitalRead(b1incrtime);
  button2State = digitalRead(b2decrtime);
  button3State = digitalRead(b3incrlevel);
  button4State = digitalRead(b4decrlevel);


  // read humidity
  hum = dht.readHumidity();
  lcd.setCursor(0, 0);
  lcd.print (hum, 1); lcd.print("%"); lcd.print(" "); lcd.print("Humidity");

  // read temperature
  tempC = dht.readTemperature();
  lcd.setCursor(0, 1);
  lcd.print(tempC, 1); lcd.print(" "); lcd.print("C");
  lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" "); lcd.print(" ");

  // read soil humidity
  int moisturePin = analogRead(A0); //read analog value of moisture sensor
  int moisture = ( 100 - ( (moisturePin / 1023.00) * 100 ) ); //convert analog value to percentage
  lcd.setCursor(0, 2);
  lcd.print (moisture, 1); lcd.print("%"); lcd.print(" "); lcd.print("Soil Level"); lcd.print(" "); lcd.print(" ");

  //read water level
  int waterPin = analogRead(A1);
  int water = waterPin;
  lcd.setCursor(0, 3);
  lcd.print (water, 1); lcd.print(" "); lcd.print("Water Level");

//a function to stop water pump if water sensor goes below 100
  if (button1State == HIGH & water > 100)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Set Water Time");
    lcd.setCursor(0, 1);
    watertime = watertime + 1;
    lcd.print(watertime); lcd.print(" "); lcd.print("seconds");
    delay(200);

  }
//4 functions that incremenent and decrement the seconds needed to water the plants and
  when the water pump starts 
  if (button2State == HIGH & water > 100)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Set Water Time");
    lcd.setCursor(0, 1);
    watertime = watertime - 1;
    lcd.print(watertime); lcd.print(" "); lcd.print("seconds");
    delay(200);

  }


  if (button3State == HIGH & water > 100)
  {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Set When");
    lcd.setCursor(0, 1);
    lcd.print("Irigation Start");
    lcd.setCursor(0, 2);
    moisturelevel = moisturelevel + 1;
    lcd.print(moisturelevel); lcd.print(" "); lcd.print("Moisture");
    delay(200);

  }


  if (button4State == HIGH & water > 100)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Set When");
    lcd.setCursor(0, 1);
    lcd.print("Irigation Start");
    lcd.setCursor(0, 2);
    moisturelevel = moisturelevel - 1;
    lcd.print(moisturelevel); lcd.print(" "); lcd.print("Moisture");
    delay(200);

  }
  delay(1000);  //delay

  if (water < 100 )
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Error!");
    lcd.setCursor(0, 1);
    lcd.print("Water Level Low!");
    lcd.setCursor(0, 2);
    lcd.print("WaterPump Stops!");
    digitalWrite(motorPin, LOW);
    delay(2500);   // delay

  }


  if (moisture < moisturelevel & water > 100 ) { //change the moisture threshold level based on your calibration values
    digitalWrite(motorPin, HIGH);  // turn on the motor
    delay(watertime * 1000); // seconds

  }
  else
  {
    digitalWrite(motorPin, LOW);
    delay(1000);
  }

}

Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

2 Likes

I'll bet you don't have kickback diodes on your solenoids ...

1 Like

You may want to Start Here, flyback diodes and why you need them. We can follow that up with posting a good schematic, even a simple hand drawn schematic helps. With those things already covered previously are all of your grounds common tied together. That would show in a schematic. Pump motors generate noise and micro-controllers hate noise. Depending on motor type it's not unusual to place a capacitor or flyback diode across motor terminals.

Ron

1 Like

Be sure all the grounds are connected. You are correct about the pump. I can imagine about a hundred ways you could have connected these items. I do not that the time to keep guessing. That will possibly take weeks or until you give up. We are waiting for an annotated schematic showing all power and ground connections. It appears you have the solenoids connected directly to the Arduino, if so and it is not broken you are extremely lucky. Also post links to each of the hardware items showing "Technical Information", links to azon and others like it are sales info and basically useless.

1 Like

I updated this post with a proper description and more informations about my project.
Any advice will be helpful!

Thanks emil, nice schematic. and thanks for providing all the links.

When the pump starts there will be a large current demand that the psu will not be able to supply.

can be operated from a 2.5 ~ 6V power supply. It
can take up to 120 liters per hour with very low current consumption of 220ma

You can provide for this inrush current by adding a LARGE (say 10mF) capacitor across the 5V - GND rails.

However the PSU may not even be able to supply the "220mA" to RUN the pump once it has started.

1 Like

Thanks for the idea.I'm going to try to add a 8-10mF capacitor and see if anything changes.Because the pump needs a 2.5-6V power supply I tried a couple ways to power it so it won't interfere with Arduino and other componets but nothing has changed.

Hand drawn schematic please ...

1 Like

Update. Circuit works fine now. I connected a 10 nF capacitor and a diode to the pump.

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