hello small issue only works when usb is connected

I have a dedicated 12 volt input.
This 12 volts input is then dropped down to 5 volts using a buck.
All Voltage shows fine and seems to be working no voltage is pulled from the board itself.
5volts into vin and ground into ground.
only two other wires come from the board a signal wire for the relay and a signal wire on A0

#define pump 13
const int AirValue = 576;   //you need to replace this value with Value_1
const int WaterValue = 368;  //you need to replace this value with Value_2
int intervals = (AirValue - WaterValue)/3;   
int soilMoistureValue = 0;
void setup() {
  //Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
  pinMode(pump, OUTPUT);
  pinMode(A0, INPUT);
  digitalWrite(pump,LOW);
  delay(2000);
  
}
void loop() {
soilMoistureValue = analogRead(0); //put Sensor insert into soil
if(soilMoistureValue > WaterValue && soilMoistureValue < (WaterValue + intervals))
{
  //Serial.println("Very Wet");
  delay(1);
  digitalWrite(pump, LOW);
}
else if(soilMoistureValue > (WaterValue + intervals) && soilMoistureValue < (AirValue - intervals))
{
  //Serial.println("Wet");
  delay(1);
  digitalWrite(pump, LOW);
}
else if(soilMoistureValue < AirValue && soilMoistureValue > (AirValue - intervals))
{
  //Serial.println("Dry");
  delay(1);
  digitalWrite(pump, HIGH);
}
delay(1000);
}

So I don't understand why it only works when the USB is plugged in looking for any advice.

Vin is the input to the on-board regulator, it needs at least 7v in to get 5v out.

(assuming this is an Uno/nano/other normal AVR board, not something weird)

If you want to feed in 5v, you need to either feed into USB port, or the 5v pin - but you should not use the 5v pin, because if you have 5v on the 5v pin and connect to USB, it will frequently damage the board as the two 5v supplies fight eachother (how bad this is depends on which board it is, which you haven't told us, despite this being basic information). For feeding 5v from external supply, I recommend using the USB port (ie, cut up a USB cable and connect it to your 5v supply)./

Sorry the board itself doesn't provide 5volts to anything in the project. The nano is powered by 5 volts ands and the only thing that comes off the nano is the signal wires. Everything else is on it's own 5 volt supply from the power source not the board.

grounds connected ?

correct all grounds are connected

flukethoughts:
correct all grounds are connected

What about the Vin question?
What are you doing there?