I wrote a program to create a time lapse camera and am storing each image in a directory on an 8 GB SD card. The card was formatted as FAT32 using Ubuntu 16.04. Every time I run the script the program stops after 1025 images have been recorded. There is still ~7.8 GB of space on the card so space doesn’t appear to be the limitation. I have the same problem with the M4 and M7. Does anyone have ideas what might be causing the problem? Here is the code I’m using:
import pyb, machine, sensor, image, pyb, os
# Create and init RTC object.
rtc = pyb.RTC()
if(os.listdir('/images') == []): # If there are not images in directory then set the RTC
#datetime format: year, month, day, weekday (Monday=1, Sunday=7), hours (24 hour clock), minutes, seconds, subseconds (counds down from 255 to 0)
rtc.datetime((2018, 3, 9, 5, 13, 0, 0, 0))
# Enable RTC interrupts every 10 seconds, camera will RESET after wakeup from deepsleep Mode.
rtc.wakeup(10000)
BLUE_LED_PIN = 3
newName=''
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 1000) # Let new settings take affect.
pyb.LED(BLUE_LED_PIN).on()
if(os.listdir('/images') == []): # If images directory is empty then first image is labeled image_0001.bmp
newName='images/image_0001.bmp'
with open("time.txt", "a") as timeFile: # Write text file to keep track of date, time and image number
timeFile.write("Date and time format: year, month, day, weekday, hours, minutes, seconds, subseconds" + '\n')
timeFile.write("date and time for image 1: " + ' '.join(str(s) for s in rtc.datetime()) + '\n')
else :
lastName=os.listdir('/images')[-1] # Get the last image file name then add 1 to file name
newNumber = int(lastName.split('.')[-2].split('_')[-1])+1
newName='images/image_' + '%04d' % (newNumber) + '.bmp'
with open("time.txt", "a") as timeFile: # Append to date, time and image number to text file
timeFile.write("date and time for image " + str(newNumber) + ": " + ' '.join(str(s) for s in rtc.datetime()) + '\n')
# Take photo and save to SD card
sensor.snapshot().save(newName)
pyb.LED(BLUE_LED_PIN).off()
# Enter Deepsleep Mode.
machine.deepsleep()