The next step in my plans was to add vision to my environment. For this I selected the Arducam Mega 3MP camera, which seemed to be straight forward enough from the initial research that I did. That has turned out to be significantly wrong.
I started off with trying to connect the camera to the ESP32 S2 Wroom but that was an abject failure. I then decided to move back to the Adafruit Huzzah ESP8266 to eliminate challenges with the ESP-32 S2 Wroom. Even this has proved challenging. Here’s what I have achieved so far.
The first challenge is to understand the SPI interface, which I haven’t dealt with before. You can read more about the SPI interface here:
https://docs.arduino.cc/learn/communication/spi/
and here:
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all
but according to the docs:
Serial Peripheral Interface (SPI) is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances.
In essence, I needed to correct connect the Arducam Mega 3MP camera SPI interface to the Adafruit Huzzah ESP8266 SPI interface. The Arducam Mega 3MP camera pinouts look like:

and this is how I connected it to the Adafruit Huzzah ESP8266
1. CS (Chip Select) -> GPIO16 (or any available GPIO pin) (D4)
2. MOSI -> GPIO13 (D7)
3. MISO -> GPIO12 (D6)
4. SCK -> GPIO14 (D5)
5. GND -> GND
6. 3.3V –> 3V

VCC (3.3V) and GND for the camera I have taken from an external power supply source.
With all that now wired up, the other trick is that you need to have something to receive and display the image from the camera. All the demos I saw pointed to a Arducam GUI tool:
https://www.arducam.com/docs/arducam-mega/arducam-mega-getting-started/packs/GuiTool.html
or direct download:
https://github.com/ArduCAM/Arducam_Mega/releases/download/v2.0.1/ArducamMegaSetup_Windows_x64.exe
which you install on your PC and view the camera via the USB cable

However, I had no real luck getting this to work at all with the example code provided. Therefore I returned to first principles.
I used this code:
https://github.com/directorcia/ciaopslabs/blob/main/Projects/15/ov3640-capture.cpp
to capture an image which seemed to work without any issues when I looked at the terminal messages and execution. Problem was, I could now capture an image but I couldn’t see it! I needed to send the image somewhere to view it. Rather than use the Windows app I thought I’d send it to an adafruit.io dashboard.
Once I had set up a dedicated feed in adafruit.io and a dashboard with an image widget I used this code:
https://github.com/directorcia/ciaopslabs/blob/main/Projects/15/ov3640-upload-v1.cpp
to try and send it. Unfortunately, I could see the code was executing and uploading to adafruit.io but I was getting feed errors. Some data had indeed appeared in the feed but an image wasn’t displaying. I also found that the Adafruit Huzzah ESP8266 was getting some sort of major error causing it to reset regularly.
After some investigation, it was recommended to disable the history on an adafruit.io feed to allow for greater data transfer sizes. The documentation tells me:
While history is turned ON, feed data is limited to 1KB (1024 bytes) in size.
While history is turned OFF, feed data is limited to 100KB (102400 bytes) in size

To do this go into the adafruit.io Feed and select the COG next to the Feed History heading as shown above. In the dialog that appears set the history to OFF as shown.
The other thing that I noted was:

The uploaded images appear to need to be base64 encoded.
I have some new code to try and overcome all of these issues which I’ll now go and try.

