Arduino board with custom PCB records less data than it should do

We want to record data from a dust sensor. We set the board to report the data every 10s (write to SD card). When we uploaded the sketch and kept the cable on, it will record data timely, for example 12 rows of data for 2 minutes . But after we disconnected the cable then power the system with battery or with USB, the system just recorded 2 to 3 rows of data. These 2 or 3 rows of data were the first 2 or 3 sets of data.

I am wondering does anyone have similar problem? Or anyone could help with this?

Thanks.

Bug in the code that you haven't posted is my guess. Though there could also conceivably be a design flaw in the board, which you have not posted a schematic of.

Hopefully a mod will move this over to project guidance where it belongs, this is absolutely not installation/troubleshooting.

Hi! Thanks for your answer. We have six boards, one of them works perfectly(with the same code), the rest of them don't.

(deleted)