Creating a Basic Remote Video Monitor with ESP32-WROVER and ESP32-CAM

In this tutorial we will show how to create a basic remote video monitor using 2 ESP32-based boards communicating via Wi-Fi:

The modules will communicate to each other using Wi-Fi (the WROVER module will act as a Wi-Fi access point and the ESP32-CAM module will connect to it). The diagram below provides an overview of the communication between the modules:Before you begin, install Visual Studio and VisualGDB 5.4 or later and ensure that you can program both modules by following our ESP32-WROVER LCD tutorial and the ESP32-CAM tutorial.

  1. We will begin with creating the firmware for the camera module. Start Visual Studio and open the VisualGDB ESP32 project wizard:
  2. On the first page of the wizard select the CMake build subsystem:
  3. Next, select the latest ESP32 toolchain and the latest ESP-IDF checkout:
  4. We will create the camera firmware by cloning the Wi-Fi station example and modifying it to serve pictures taken from the camera via HTTP. Hence, pick the wifi/getting_started/station sample:
  5. On the Debug Settings page select the settings necessary to debug the ESP32-CAM module. If you are not sure, follow theĀ ESP32-CAM tutorial to get JTAG to work:
  6. Press “Finish” to generate the project. Once the project is loaded, right-click on the components view in Solution Explorer and select Add->New Item:
  7. Add an empty component called “esp32-camera” to the project:
  8. Now we will replace our dummy component with a copy of the actual ESP32 camera library. Right-click on the project in Solution Explorer and select “Open ESP-IDF Terminal here”:
  9. Run the following commands in the terminal:

  10. Once the camera library is cloned, go back to Visual Studio and reload the project:
  11. Once the project is reloaded, VisualGDB will automatically display the contents of the esp32-camera library in Solution Explorer:
  12. Before we proceed with using the camera library, open VisualGDB Project Properties and set the Wi-Fi SSID and password to match your Wi-Fi network:
  13. If you are using the Custom edition of VisualGDB, we recommend enabling the raw terminal on the COM port connected to the ESP32-CAM board. For lower editions, simply use an external terminal program instead:
  14. Now we will add the code that will take pictures using the camera. First of all, copy the camera I/O pin definitions from the Arduino sample:

    Then add a basic HTTP request handler that will take a picture and send it via HTTP each time it receives a request:

    Finally, replace the app_main() function with a version that enables the camera driver and starts an HTTP server:
  15. Press F5 to build and start your program. Take a note of the IP address reported by the board via the COM port:
  16. Open the IP address of the board in your browser. You will see a low-resolution picture from the camera:
  17. Now it’s the time to create the firmware for the ESP32-WROVER board that will request the pictures from the camera and display them on the on-board LCD screen. Open another instance of Visual Studio and start the VisualGDB ESP32 project wizard:
  18. Proceed with the CMake build subsystem:
  19. This time ensure you are using ESP-IDF 3.3 or later, as the older versions do not report the IP addresses assigned to the Wi-Fi clients:
  20. Select the spi_master sample and press “next”:
  21. Select the debug settings for the ESP32-WROVER board. Do not confuse them with the settings for the ESP32-CAM module:
  22. Now we will modify the LCD display example to show the pictures received via Wi-Fi instead of the hardcoded JPEG image. First of all, modify the decode_image() function to accept an arbitrary JPEG buffer instead of the one in the FLASH memory:See the ESP32-WROVER LCD tutorial for more details about the roles of various LCD-related functions.
  23. Now we will proceed creating a Wi-Fi access point. Add the following code to the main source file:

    Ensure that the Wi-Fi SSID and password on the WROVER board match the SSID and password in the ESP32-CAM firmware and do not conflict with your normal Wi-Fi network.

    Note how the handler for the SYSTEM_EVENT_AP_STAIPASSIGNED event (raised by ESP-IDF when a client connected to our access point gets assigned an IP address) saves the address assigned to the last client into the s_ClientIP variable.

  24. Add the following function that will continuously download the JPEG images from the last connected client and will display them on the LCD screen:

  25. Finally, remove the call to the pretty_effect_init() function (and the function itself) and replace the end of app_init() with the following code:

  26. Now you can build and run the WROVER firmware. Once it starts up, power up the ESP32-CAM board and check the WROVER output for messages regarding the Wi-Fi clients:If the boards do not connect, ensure they both use the same Wi-Fi SSID and password and check that it doesn’t conflict with your main Wi-Fi connection.
  27. Once the boards connect, you the pictures taken by the camera will be shown on the LCD display of the WROVER module:

You can find the source code of the projects shown in this tutorial on our GitHub repository. If you would like both boards to connect to your regular Wi-Fi network instead, replace the call to the wifi_init_softap() function in the WROVER firmware by an equivalent of the wifi_init_sta() function from the ESP32-CAM firmware and update the WROVER firmware to fetch the images from a fixed IP address.