How to detect new image files in the SD card?

The requirement is to transmit the image files from Arduino to Raspberry PI which I have already achieved. However, there is a question that could SD card detect new image automatically by programming without knowing the file name? Just to detect whether there is a new image stored or not.

Any ideas will be appreciated. Thanks. :grin:

This is a dirty way of doing it.

In the SD Library there is an example to list all files. As it lists files, count the files and store that as int fileCount.

When you write a file yourself, fileCount++.

When you want to check to see if there's a new image on the SD that you didn't put there yourself, list all files again and make a second count, int fileCount2 If fileCount2 is greater than fileCount1, you have new images.

If you're worried about losing this integer during power off/on, store the integer in a permanent file every time you update it and get it when the board turns on.

stoutfiles: This is a dirty way of doing it.

In the SD Library there is an example to list all files. As it lists files, count the files and store that as int fileCount.

When you write a file yourself, fileCount++.

When you want to check to see if there's a new image on the SD that you didn't put there yourself, list all files again and make a second count, int fileCount2 If fileCount2 is greater than fileCount1, you have new images.

If you're worried about losing this integer during power off/on, store the integer in a permanent file every time you update it and get it when the board turns on.

Thanks a lot for your idea. I will try it. :)