ESP32 Camera module

20190803_150613.jpgVarious Chinese webstores sell an ESP32 based Camera module. A known one is from LilyGo, but there are  very cheap, simpler modules available too. The cheapest I found is the module as seen in the picture at 4.44 Euro, shipping included.

Using the built in camera program

Although it might not be the case for similar modules from various suppliers, mine actually already came with a camera application present in the ESP32.
To use that built-in program, one needs to connect to the ESP32-CAM acces-point in your WiFi list:

and then point your browser to ‘192.168.4.1/jpg_stream’ for  streaming video, or ‘192.168.4.1/jpg’ for stills.
The documentation on this webserver is very scarce, only a bit of information is given here. But that does not really give much extra info. The Firmware in the camera could easily be something like this.

Uploading your own camera program

So far so good if you only want a simple IP cam and you do not mind it has its own AP. It is fairly easy though to upload a camera program, that for instance does not need connection to a separate AccessPoint, but what can be found within ones own regular network.

Such a program can be found among the ESP32 examples in the IDE:

We need to make a few changes in the program:
For my specific  module, I needed to select (lines 9-14 in the program)
“#define CAMERA_MODEL_AI_THINKER”
and comment out the other defines.
For you that might be another model.
Now right under that, we define a string with the name we like the module to have in the DHCP list
Then find the “WiFi.begin()” command and add  2 lines in front, like so:

You will find it here.  Mind you though that this program needs ESP32 core 1.02 (or higher) to compile !!!! The 1.01 core comes with is own version of this program.
Now we are (almost) ready for upload. As this ESP32-CAM module has no USB port for uploading, we need a 3V3 FTDI adapter to upload programs. Make sure it is a 3v3 FTDI adaptor (NOT a 5 Volt)

The connections are as follows

FTDI <-> ESP32
Ground <-> Ground
Rx <-> UOT
Tx<-> UOR
3V3<->3V3

Additionally on the ESP32 module Pin IO0 needs to be connected with GND to put the module in Programming mode.
For my specific  module, I needed to select (lines 9-14 in the program)
“#define CAMERA_MODEL_AI_THINKER”
and comment out the other defines.
Then in the IDE, under Tools, I needed to select
Board: “ESP32 Wrover module”
Partition Scheme: Huge APP (3MB No OTA)
Once the program is uploaded, Remove the  connection between IO0 and GND and press the reset button.
Now you need to find out the IP number. You can find this by opening the serial monitor, where the IP number is printed.
IF in the serial monitor you may see a ‘Brownout detector’  warning and repeated failed attempts to start the software, do not despair, it just means that your USB port does not provide enough power.
If that happens, connect the module to a proper powersource and check in the DHCP client list of your router, what the IP number is. The module should identify itself with the name we previously defined in the program. If you didn’t do that, it will identify itself as ‘expressif’.

Then open a browser and direct it to the IP number of the module.
In the screen that subsequently opens, scroll down and click “Start Stream”.
This should start the  camera stream.

There is also a button that says “Still”. That one should just make a still picture, but in the example program that we used, it will not store that picture. But that should not be too hard to add. I may do that in the future.Should you want to dabble into that, the following pins are connected to the SDCard:

  • GPIO 2: Data 0
  • GPIO 4: Data 1 (also connected to the on-board whiteLED)
  • GPIO 12: Data 2
  • GPIO 13: Data 3 (also connected to a small red led)
  • GPIO 14: CLK
  • GPIO 15: CMD

Mind you that the program will only allow one client to view the stream

Face Detection
The webserver has buttons for face detection. Sadly there is a bug. Face detection is working in the 1.01 core but not in the 1.02&1.03 core. So if you have core 1.02, you have to roll back AND use the ESP32CameraWebServer example program coming with THAT core. If you cant find that, it is (still) on the randomnerd github from Rui & Sara Santos

The site of Rui & Sara Santos is definitely good source on the ESP32Camera module is.

LED
The module has a nice fat LED on board. If you want to control that for your camera, check here.

Advertisements

Leave a Reply

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 )

Google photo

You are commenting using your Google 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.