You know how it is, you're shopping on one of those Chinese web stores and you have a $4 item in your cart and want to get something else interesting because shipping is going to be the same for 1 item or 2. Well I recently bought a 3.2 TFT display from Banggood.com and added a $12 ESP32 CAM module complete with OV2640 camera and yesterday I set it up so I thought I'd share my experience here.
Mini Arduino Primer
If you are familiar with the Arduino integrated development environment (IDE) you can skip this part and jump down to the ESP32 CAM part below. The Arduino platform has evolved from a simple development environment interface that supported a not very powerful 8 bit processor PCB with a weird 'shield' header setup with libraries (that you had to find and add yourself) into one that's been expanded to support multiple kinds of Arduinos (and clones) and many other cheap development platform PCBs that include the ExpressIF ESP8266 and ESP32 modules which are interesting in that they are a) cheap and b) powerful c) have WiFI capabilities built in. I wasn't a fan of the Arduino IDE when I first tried it but it has truly come of age - here are my pros and cons:
Pros1. Many different hardware platforms are supported although that has some downsides as code examples often have to be tweaked to work with different platforms
2. Driver libraries are ubiquitous, easy to find, install, and update - this is the real power of the IDE
3. There are often many example programs that are offered to you by the IDE after you add in support for a specific board/platform.
4. There are many sites such as Sparkfun and Adafruit that have some great articles and videos walking you through step by step.
5. There are 1,000s of shields and many non-Arduino evaluation boards have adopted the shield header format to allow their hardware to use Arduino shields.
6. The code and drivers are all free and Open source, you just have to buy the hardware.
Cons1. I don't like it that most of the examples and drivers are written in C++; I want them in C to make them portable to other IDEs but I guess that's my problem.
2. There are at least 3 different versions of the shield header that try to be hardware compatible but it can be confusing
3. As the Arduino caught on, they brought out newer and better versions such as Uno, Due, and Mega and these have been cloned but some clones are real clones in that they are (or claim to be) 100% compatible with the real Arduino boards. Then there are clones that look like one of the real Arduino PCBs but carry a different processor e.g. ExpressIF.
4. There are voltage differences and incompatibilities between Arduino PCBs & clones; the first ones were 5V only, now some are 5V & 3.3V with selection jumpers, and some are 3.3V only. Shield manufacturers have tried to keep up with this using things like voltage level translators but it's a jungle and you can end up with shields that just don't work or, worse still, shields that will fry if you plug them into the wrong platform.
But here's why I use the Arduino IDE - take the example of the 3.2 TFT display I was originally shopping for; I want to prove that it works and figure out how to talk to it. Well, if I find a code example for the Arduino, all I have to do is plug it into (the right) platform PCB and , load and run it. I can then study the hardware connections, sniff the busses, copy the libraries (it's all Open Source) into my own IDE and adapt the drivers to my needs.
ESP32 CAMSo I followed the
instructions for setting up the ESP32 CAM module here and it just works. The link is pretty accurate but I have a few comments to add.
1. The
schematic for the ESP32 CAM shows that the 5V supply goes into a 3.3V linear regulator. Many people claim it doesn't run reliably on a 3.3V supply so I provided my power from a 5V (measured 5.2V) 2A wall power supply and it worked well.
2. I used a cheap FTDI serial PCN just like in the pictures in the randomnerdtutorials link but make sure you set the voltage jumper to 3.3V
3. Once you've compiled and loaded the code, you need to set the Baud rate for the Arduino serial port to 115,200
4. You don't have to use the Arduino IDE serial monitor program, any other one like Tera Term will work.
5. Once you know what the IP address is for your ESP32 CAM and type that into your browser, you will see the OV2640 camera controls and you need to scroll to the bottom to find the [Start Streaming] button
6. You can remove the control bar by clicking on the =OV2640 camera text at the top and you'll just see the picture
7. My picture looks slightly out of focus, I think there's a tiny lens that I can adjust on the camera - I'll let you know
There's also a
pretty good video here although the URL they gave that ends in json wasn't the right one.
If anyone has tweaked the code to add functionality, please feel free to chip in here.