Nano moisture sensor + relay + mini water pump sefl switch issue

Hello,
I am coplectly new in this "waters".
I build a small flawer water system with the bottom code:

==============================================================

#include <PCD8544.h>

PCD8544 lcd;

int sensor_pin = A0 ;

int output_value ;

int valve_pin = 8 ;

void setup ( ) {

Serial.begin(9600);

Serial.println("Reading From the Sensor ...");

pinMode (valve_pin, OUTPUT);

delay(3000);

}

void loop ( ) {

output_value = analogRead (sensor_pin);

output_value = map (output_value , 1023 , 0 , 0 , 100);
Serial.print("Mositure : ");

Serial.print(output_value);

Serial.println("%");

if (output_value < 75)

{

digitalWrite (valve_pin , LOW); //Relay operates on opposite signal

delay(4000);

}

else

{

digitalWrite (valve_pin , HIGH); //Relay operates on opposite signal

delay(4000);

}

delay(4000);

}

==============================================================

Almost work fine, but has one problem.
When humidity is 76-77% the pump stop for 2.3 min. then starts again for 6 sec. and again, and again the same cycle!

Please tell me, what is wrong?

Thanks in advance.
Regards
318/5000

Does your valve and the Arduino share the same power supply?

Can't tell from the code. Probably need a wiring diagram.

aarg:
Does your valve and the Arduino share the same power supply?

Yes!?
Mode laptop adaptor - directly 12v for pump and 5,25v (through MP1584EN, LM2596) for Nano, sensor and relay.

I have not wiring diagram.
Do not laugh on me :slight_smile:

KrAfLo:
I have not wiring diagram.
Do not laugh on me :slight_smile:

Love the clothespin cable management!

Could it be that i am powering Nano in vin pin?

Was my mistake, the voltage in vin pin must be more then 6v!
Now woking fine.