#ESP32CAM – WebServer taking photos πŸ“Έ every N seconds #Arduino

Hi !

Still learning with the ESP32 CAM board.

In today’s post the scenario is simple:

  • Init the camera
  • Init the local File System
  • Take a photo every 5 seconds and store it in memory
  • Creates an endpoint named [/photo] to return the last saved photo

As the previous sample, I’ll write this using Visual Studio Code and PlatformIO project, using the AI Thinker ESP-32CAM board.

Demo here is tricky, but hey, a selfie is always a good excuse.

selfie with the esp32 cam

As usual, the full sample code is in the demo repository.

Let’s review some noted from the code:

  • The setup and loop are the key codes for this demo.
  • In the setup, init wifi, fs, and camera
  • As a visual clue, I turn on the flash 1 second after each one
  • In the loop, the camera takes a photo every 5 seconds
void setup()
  // Serial port for debugging purposes

  // initialize digital pin ledPin as an output

  // connect to wifi

  // init fs and camera
  // init and start server
  server.on("/photo", HTTP_GET, [](AsyncWebServerRequest *request)
            { request->send(SPIFFS, FILE_PHOTO, "image/jpg", false); });

void loop()

Next steps will include learning Edge Impulse and Computer Vision in this device !

Full code available in my ESP32 Cam Demo repository.

Happy coding!


El Bruno

More posts in my blog ElBruno.com.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: