Close

Cameras and Arduino or ESP8266

A project log for Budget wi-fi nest box camera

Finding the cheapest way of getting a camera in a bird nest box, and then making it simple to use and install.

fractalFractal 12/19/2017 at 15:071 Comment

This should summarize the options available for getting a camera usefully connected to a microcontroller.

This is NOT about simply putting a remote shutter on a camera for a time lapse jig, this is about getting the data usefully out so a micro can use it.

The main problem is that a picture, even 640x480 (0.3 megapixels), is much larger than the ram on cheap microcontrollers. The second problem is that most cameras need the data to be clocked out far quicker than cheap microcontrollers can process. The third problem is that a lot of cameras need configuring before use, even if they have automatic modes for contrast, white balance, etc. you still need to set them up.

Now there are options - you can look at only very small parts of an image, and ignore the rest. I've done this with a simple old CMOS camera at 2 MHz and an Arduino (ATmega328p) - it could read one line, send it over serial, and then a frame or two later read the next line. For slow moving objects this can work, but the microcontroller really can't do much else - even for a slow, 2MHz camera the ATmega328 is completely tied up while a line is being read - every 8 clock cycles a new byte of data comes in, and it takes at least 4 cycles to copy the data into ram, let alone synchronize with a data stream. You're never gonna get a good image since it can't hold the whole frame at once. 

There's also the option of using a more powerful device - a cheap raspberry PI zero can easily handle the data stream from a camera, but I'm wanting a lower power, even lower cost device than that.

So overall what's wanted is a camera module which has memory on it, and some high speed buffer to store each frame. The excellent ArduCam project is the logical conclusion to this, though it adds cost. A microcontroller can then access the picture slowly on a simple protocol, like SPI. Or an ESP8266 could stream the picture out of memory slowly over WiFi, in little 2 kB packets.

The low cost options:

£2.40. OV7670.

A OV7670 module with a nice big lens on a pcb with a 2x9 header. The cheapest result for "arduino camera" on ebay.co.uk. Also, completely unusable on nearly every Arduino. The OV7670 is a VGA CMOS module, it outputs pixel data over 8 pins, which update at a minimum speed of...10 MHz. The controller has to provide that 10 MHz too, plus there's some synchronization signals there too. 

Now, some people have got some semblance of functionality working with a small device ... but it's not very good honestly. Scroll down to 10: Results, at this instructables: framecapture, It's impressive but sad.

The Arduino is running 100% dumping all 8 bits of PORTC out of the serial port at 128 Kbytes per second. (Quick aside - that's 128*8 = 1 Mbit per second, which is the fastest any arduino could possibly go at 16MHz)

It requires special software to receive and process this unformatted data, it's only reading one of the colour channels, it's only reading 320x240, and it's still underclocking the camera. Overall, not usable on anything short of a raspberry PI.

£19.99. Arducam Mini. 

This is the logical conclusion to prototypers needing a camera on an underpowered platform. Arducam have good open source documentation too! It's a CMOS module (OV2640) attached to a FIFO ram buffer, and a controller on board to handle shuffling bits around. It's terriffic, and you can even attach multiple ones to microcontrollers for 360 vision! They have easily changeable lenses too. Full details on their website: ArduCam mini.

However, £20 is a lot! It would be the majority of the project cost. Really the cost is the only downside!

£7.35. OV7670 with AL422 FIFO.

It looks like the OV7670 with a big old FIFO slapped on. Because it is. Now this is a bit more feasable, there are people asking how to use it on stackexchange... but it's still a lot of work. It's also got a crystal onboard, so you have to worry about synchronising it with any device. Unlike the Arducam, it's lower resolution, and has no premade examples (though the sensor is well documented). Cheaper though, and takes lenses well!

£2.98. Keychain USB spy cam 808.

Now, this is a mass produced cheap piece of rubbish. However, if it works at all, it has all sorts of advantages versus the other modules: 720x480 or WXGA depending on what you read. Has a lithium battery. Takes microSD card. Has a shutter button. Stupidly cheap. Built in mass-storage mode on USB. JPG images, AVI video.

At first this would seem useless for using with a microcontroller - and it is if you intend to do processing on the microcontroller since it stores JPEG. But if you want a way of getting a picture onto a SD card, this is it, and this is the cheapest.

Of course, lenses are a problem, and so is the fact that there could be many different versions of electroincs lurking within this form factor.

There's a page where a guy has helpfully reviewed the multitude of different cameras that live in this case: http://www.chucklohr.com/808/ Truly incredibly helpful. Still it is hard to tell what you get for the cheapest price! 

Assuming the worst, it would probably be a camera that gave poor video performance, and upscaled a 640x480 image to 1280*1024. This is fine, since video's not needed, just snapshots.

As discussed previously, getting an ESP8266 to read from a SD card is solved. (Yes, both the camera and ESP8266 want FAT32 formatting...) So to interface this to the web one only needs to make sure both the micro and the camera are not accessing the SD card at the same time, and wire up the shutter button. Shutter button's been done before, not sure about shared SD card access.

The keychain camera is the route I'd be intending - total costs may even be under £10 in one-offs.

Discussions

olegst90 wrote 10/18/2018 at 22:13 point

Have you succeeded with it? To the best of my knowledge, OV7670 requires at least 10Mhz external clock. How are you going to get it on ESP8266? I'm also considering this configuration, but I have no idea how to solve the issue. I wanted to use PWM but was unable to get more than a few dozen khz as ths mcu has no hardware PWM module.

  Are you sure? yes | no