Hi All,
I am struggling to Compile the ESP32 CAM Motion sensor example in Visual Studio Code
Please see below code:
The error I am getting is:
src\main.cpp: In function ‘void capturePhotoSaveSpiffs()’:
src\main.cpp:137:25: error: ‘checkPhoto’ was not declared in this scope
ok = checkPhoto(SPIFFS);
^
*** [.pio\build\esp32cam\src\main.cpp.o] Error 1
Hi.
Move the definition of the checkPhoto() function
// Check if photo capture was successful bool checkPhoto( fs::FS &fs ) { File f_pic = fs.open( FILE_PHOTO ); unsigned int pic_sz = f_pic.size(); return ( pic_sz > 100 ); }
before the
void capturePhotoSaveSpiffs( void ) {
Regards,
Sara
Thanks Sara – worked like a charm, I should’ve checked the code better!, thanks for the help
Great!
I’ll mark this issue as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara
Just for future reference for anyone else coming across this answer, the reason why this works is because PlatformIO is more strict in the layout of your code. The Arduino IDE is very lax with this and you can put your functions anywhere.
Another way to “fix” this would be to declare your functions before trying to use them and leave the function definition where it is. This is the came concept as a .h (header) file. The header file contains the definition of variables/functions and the .c file contain the actual code of the functions.
So, just adding:
bool checkPhoto( fs::FS &fs );
to the beginning of the file would suffice.