Project does not run when not connected to serial

I have a some landscape lights that run of a 12v battery. It gets recharged via a solar panel. I wanted to log the voltages of the battery during a day/night cycle. I am using an Adafruit M0 Feather adalogger and a no-name voltage sensor. The sensor is just a voltage divider. Voltage gets written to SD card. It all runs great when the usb cable is hooked to my pc and the serial monitor is open. When just on battery, it doesn’t run the project. I read about the serial(!while) which I don’t have anymore. I also read some boards only run when the serial is connected. I’m a newbie, so don’t know why it won’t run on battery alone. Is it all the serial.prints? Here’s the code I cobbled together:

#include <SD.h>
#include <SPI.h>

File myFile;

int pinCS = 4; // Pin 10 on Arduino Uno
int offset =-10;// set the correction offset value

void setup() {
  // put your setup code here, to run once:


pinMode(pinCS, OUTPUT);
Serial.begin(9600);
  // SD Card Initialization
  if (SD.begin())
  {
    Serial.println("SD card is ready to use.");
  } else
  {
    Serial.println("SD card initialization failed");
    return;
}
}
void loop() {
  int volt = analogRead(A0);// read the input
  double voltage = map(volt,0,1023, 0, 1690) + offset;// map 0-1023 to 0-2500 and add correction offset
  voltage /=100;// divide by 100 to get the decimal values
  Serial.print("Voltage: ");
  Serial.print(voltage);//print the voltge
  Serial.println("V");
  // Create/Open file 
  {
  myFile = SD.open("test.txt", FILE_WRITE);
   if (myFile) {
    myFile.print("Voltage:");
    myFile.println(voltage);
   myFile.close(); // close the file
      }
  // if the file didn't open, print an error:
  else {
    Serial.println("error opening test.txt");
  }

  }
delay(60000);
 
 }

Thanks,
-Paul

I have tried it without the serial.begin but no difference.

When just on battery, it doesn't run the project.

What battery? Please explain more about the battery, its specs, and the connection to the Feather MO.

This is the setup. Pic attached.
I also have a Metro classic and loaded the same sketch to it and it works. It is currently recording data.

Can you confirm with a multimeter that you can see the correct voltage at the terminals of the JST connector?

If the wiring from the battery through the connector looks good, can you run the feather only on battery, but if you just blink an led instead of using the SD card, does the code run correctly?

Have you checked with Adafruit techinical/product support? They are usually pretty good.

M02.jpg

Very strange! Much the same as this post!

Some rechargeable LiPo batteries from eBay have opposite wiring!

Had to swap mine to get it to work on my Feather compatible board