Electronics Microcontrollers Sensors "/>

ESP32 and the OV2640 camera module

31 July 2021 at 10:38 pm

Article image for ESP32 and the OV2640 camera module

This year, my Machine To Machine (M2M) students will be working with a camera setup, so I’ve reasearched what is possible within my budget. The obvious solution is to use something based on ESP32 so you get WiFi with a cheap camera module like the OV2640. There are several modules like this on the market and I’ve now found myself a favorite.

On the M2M course that I lecture at Kristiania University, we have a theme each year. The M2M business is really varied and thus far we’ve done indoor environment monitoring, security systems, biometrical data and plant & soil sensors. The theme for this year is vision, access and AI (if possible).

Dev boards

There are several dev boards based on ESP32 that uses the OV2640 camera sensor and above, you can see the collection that I’ve tested. The first two modules are the same, but with alternate boards to program them via USB. The first uses an FTDI 232 clone and the second is based on the CH340G. These two modules offer a powerful LED as their “feature” apart from the camera. This LED is plenty bright (as in “it hurts”), but that’s all you get. These are cheap - really cheap. I found one for $5.23, but the camera on this was damaged in transport. It worked when I replaced the camera though. Read very carefully when ordering these, as some are sold without the OV2640 camera sensor or a USB serial programmer.

In my opinion, the third board is a better alternative to the former despite being a little bigger. It has the USB serial chip built in, so it’s much easier to work with. These are a dollar more than the former two, but has the same features in a more flat solution than stacking the serial programmer underneath. Neither of these boards have a working auto-programming, so you’ll have to tap the boot and reset buttons every time you program the boards. They also do not come with the 8Mb PSRAM chip that the remaining 3 boards do, so you cannot capture more than 720p.

The fourth board is the smallest I’ve tested. It’s the ESP-EYE 2 reference module created by Espressif Systems (the makers of the ESP32 wifi modules). As far as I can gather, it’s this reference design that has spawned the other variants. These cost about $25 and they have an onboard microphone as their main feature. They also come in a nice padded plastic box and a short USB Micro cable. They are well documented and generally work really well. The onboard 8Mb PSRAM chip allows capture of the full 1600x1200 pixel resolution. Be sure to get the ESP-EYE version 2.1 if you are getting this module.

The remaining two boards are from Chinese manufacturer Lilygo and they are both a lot more advanced than the others. They have 8Mb PSRAM, LiPo charging and builtin sensors. The “LILYGO TTGO T-Camera Mini” comes complete with a white casing. It has a hidden touch button on the casing and a 400mA liPo battery hidden inside. This is not a large battery, but used sparingly it can be very useful. At $22, it’s cheaper than the ESP-EYE and a far more complete product.

The last one is my absolute favorite. It has a PIR sensor to detect motion, an OLED screen, an expansion port and the option of a microphone. You can also select what USB to serial chip to use, so this module ranges from $17 to $20. You can also select between FishEye (160 degree FOV) and normal lens (66 degrees FOV). It comes in a nice box with a battery cable that you can solder to the battery of your choice.

Why the OV2640?

It’s an odd module, given that it’s been discontinued for many years, but is still in production due to how the Chinese market will allow you to clone without major copyright issues. It can be hard to secure a good manufacturer, but Alibaba lists several. This is a module that can capture 2 megapixel images (1600x1200) and they have acceptable optics (but by no means stellar).

I hear you say - why not use the OV5642 (5 Megapixel) or something even more powerful? It comes down to cost per unit. I have a fixed budget and the students have a list of components they need. The ESP32 can certainly capture and compress large images, but when capturing live video at 2k, you’ll only manage something like 2-4 fps. At 720p, it’s much better and at 800x600 it’s quite fluid (20-25 fps?). So to be able to process larger images, you’d basically need more speed than what the 240Mhz ESP32 offers. That usually means getting a SingleBoard Computer (SBC) and that breaks my budget per student. So - a 2 megapixel sensor is a good balance between price and the required performance.

Lens options

There’s three easily available lenses that offer different Field Of View (FOV). I’ve mentioned the 66 and 160 degree variants and there’s also a 120 degree FOV that I have not yet tested (but have on order). You can get these with short, long or longer cable for various use cases. I’ve also found a fourth variant pictured below. This one seems to be almost the same as the 66 degree variant.

I posted some microscope shots of the OV2640 sensor on my Tumblr also.

My choice

So as mentioned above, I’m going for the TTGO v17 camera module for my students. It has all the tings they’ll need to make a smart system and I’ll add a solenoid lock and some other things they might need also. One nice thing about this is that they also offer some sensors and a nice looking enclosure with an optional bumper. I won’t purchase these, but I’ll tell the students about them in case they want this.

Based on my tests, you can do quite a bit using these and there’s a reasonable collection of software to get the students going. They also have a very extensible component set (300+ components) from this autumns Embedded Systems course, so together this will make a very complete package to build solutions from.