DEV Community

El Bruno for Microsoft Azure

Posted on • Originally published at on


#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()

Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)

Regex for lazy developers

regex for lazy devs

You know who you are. Sorry for the callout 😆