# CircuitPython Webcam with OV2640

## CircuitPython Webcam with OV2640 and Adafruit IO

Info: 

With a WiFi-enabled board like the Espressif Kaluga, you can upload your image data to [Adafruit IO](https://io.adafruit.com/). We made sure that this example works with the free version, so you can try it out even if you haven't upgraded to an IO+ subscription yet. New to Adafruit IO? [Start with this guide](https://learn.adafruit.com/adafruit-io-basics-airlift/circuitpython) to learn the basics.

### USB Type A Plug Breakout Cable with Premium Female Jumpers

[USB Type A Plug Breakout Cable with Premium Female Jumpers](https://www.adafruit.com/product/4448)
If you'd like to connect a USB-capable chip to your USB host, this cable will make the task very simple. **There is no converter chip in this cable!** Its basically a plain USB cable that's cut in half and with jumper sockets on the power and data lines. Simple to use,...

In Stock
[Buy Now](https://www.adafruit.com/product/4448)
[Related Guides to the Product](https://learn.adafruit.com/products/4448/guides)
![Angled shot of Black, USB-A plug cable with four socket jumpers.](https://cdn-shop.adafruit.com/640x480/4448-01.jpg)

### USB Extension Cable - 3 meters / 10 ft long

[USB Extension Cable - 3 meters / 10 ft long](https://www.adafruit.com/product/993)
This handy USB extension cable will make it easy for you to extend your USB cable when it won't reach. The connectors are gold plated for years of reliability. We use these handy cables all over our factory and homes. Cable is standard "Adafruit black".  
  
Cable length:...

In Stock
[Buy Now](https://www.adafruit.com/product/993)
[Related Guides to the Product](https://learn.adafruit.com/products/993/guides)
![USB Type A Extension Cable](https://cdn-shop.adafruit.com/640x480/993-03.jpg)

### Adafruit IO+ Subscription Pass – One Year

[Adafruit IO+ Subscription Pass – One Year](https://www.adafruit.com/product/3792)
The all-in-one Internet of Things service from Adafruit you know and love is now _even better_ with IO+. The 'plus' stands for MORE STUFF! More feeds, dashboards, storage, speed. Power up your [Adafruit IO](https://io.adafruit.com/) with the $99 pass for 1 year of the...

In Stock
[Buy Now](https://www.adafruit.com/product/3792)
[Related Guides to the Product](https://learn.adafruit.com/products/3792/guides)
![Text image that reads "IO+"](https://cdn-shop.adafruit.com/640x480/3792-01.jpg)

# CircuitPython Webcam with OV2640

## Set up IO Feed

New to Adafruit IO? Check out the [Adafruit IO Basics guide](https://learn.adafruit.com/adafruit-io-basics-feeds/overview), or [detailed instructions on creating a feed.](https://learn.adafruit.com/adafruit-io-basics-feeds/creating-a-feed)

## Set up the IO Feed

Create a feed called "image" and then set "Feed History" to "OFF". This allows storage of data up to 100kB, which is plenty to upload JPEGs at 640x480 resolution. (You can choose another feed name but you'll need to **make sure** that Adafruit IO's "key" for the feed matches what you use in your CircuitPython program!)

![](https://cdn-learn.adafruit.com/assets/assets/000/103/684/medium800/camera_ksnip_20210802-103924.png?1627995948)

![](https://cdn-learn.adafruit.com/assets/assets/000/103/683/medium800/camera_ksnip_20210802-103916.png?1627995933)

## Set up the IO Dashboard

Create a new dashboard. Click the gear icon and then "Create New Block". Choose the camera icon ("image") and then select your feed named "image". Enter a block title if you like, and click "Create Block".

![](https://cdn-learn.adafruit.com/assets/assets/000/103/685/medium800/camera_ksnip_20210802-104059.png?1627995980)

![](https://cdn-learn.adafruit.com/assets/assets/000/103/686/medium800/camera_ksnip_20210802-104038.png?1627996005)

# CircuitPython Webcam with OV2640

## CircuitPython Code

## Secrets File Setup for Adafruit IO

If you don't have a **secrets.py** file in your **CIRCUITPY** drive yet, create one and add the information about your wifi connection.

Then, add the following code to your **secrets.py** &nbsp;file, **replacing** `_your_adafruit_io_username` **with your Adafruit IO username.**

Then, **replace** &nbsp;`_your_big_huge_super_long_aio_key_` **with your Adafruit IO Active Key**.

```auto
secrets = {
    'ssid' : '_your_wifi_ssid_',
    'password' : '_your_wifi_password_',
    'aio_username' : '_your_adafruit_io_username_',
    'aio_key' : '_your_big_huge_super_long_aio_key_',
}
```

Make sure you **save this file** before proceeding as **secrets.py** in the root directory of your board **CIRCUITPY** drive **.**

## Upload the code

Click "Download Project Bundle" below and unzip it on your Espressif Kaluga's **CIRCUITPY** drive. It will automatically start the code and upload a 640x480 JPEG to Adafruit IO every 3 seconds or so. If you run into trouble, open up the REPL to look for clues. Carefully double-check your WIFI and Adafruit IO login information, and that you properly created & configured the Adafruit IO Feed and Dashboard.

![Listing](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/ov2640_ov2640_aio_kaluga1_3.py.png)

https://github.com/adafruit/Adafruit_CircuitPython_OV2640/blob/main/examples/ov2640_aio_kaluga1_3.py

## Watch the camera feed

Just open up the Dashboard on Adafruit IO. The image in your browser will update shortly after each new image is uploaded from the ESP32-S2.

![](https://cdn-learn.adafruit.com/assets/assets/000/103/725/medium800/camera_ksnip_20210802-103903.png?1628092833)

## Take it Further

Here are some improvements and changes you might want to make to the code:

- WiFi camera: Add a button to take a photo, and an LCD to act as a viewfinder.
- Add a button to the Adafruit IO Dashboard that signals the camera to upload a fresh photo
- Video Doorbell: Add a button to take a photo, and send you a notification on your phone (requires an IFTTT account)
- Use a PC or Raspberry Pi to download & analyze the images


## Featured Products

### ESP32-S2 Kaluga Dev Kit featuring ESP32-S2 WROVER

[ESP32-S2 Kaluga Dev Kit featuring ESP32-S2 WROVER](https://www.adafruit.com/product/4729)
The **ESP32-S2-Kaluga-1** kit is a full featured development kit by Espressif for the ESP32-S2 that comes with everything but the kitchen sink! From TFTs to touch panels, this dev board has it all. Espressif designed this kit to demonstrate the ESP32-S2’s human-computer...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4729)
[Related Guides to the Product](https://learn.adafruit.com/products/4729/guides)
### USB Type A Plug Breakout Cable with Premium Female Jumpers

[USB Type A Plug Breakout Cable with Premium Female Jumpers](https://www.adafruit.com/product/4448)
If you'd like to connect a USB-capable chip to your USB host, this cable will make the task very simple. **There is no converter chip in this cable!** Its basically a plain USB cable that's cut in half and with jumper sockets on the power and data lines. Simple to use,...

In Stock
[Buy Now](https://www.adafruit.com/product/4448)
[Related Guides to the Product](https://learn.adafruit.com/products/4448/guides)
### USB Extension Cable - 3 meters / 10 ft long

[USB Extension Cable - 3 meters / 10 ft long](https://www.adafruit.com/product/993)
This handy USB extension cable will make it easy for you to extend your USB cable when it won't reach. The connectors are gold plated for years of reliability. We use these handy cables all over our factory and homes. Cable is standard "Adafruit black".  
  
Cable length:...

In Stock
[Buy Now](https://www.adafruit.com/product/993)
[Related Guides to the Product](https://learn.adafruit.com/products/993/guides)
### Adafruit IO+ Subscription Pass – One Year

[Adafruit IO+ Subscription Pass – One Year](https://www.adafruit.com/product/3792)
The all-in-one Internet of Things service from Adafruit you know and love is now _even better_ with IO+. The 'plus' stands for MORE STUFF! More feeds, dashboards, storage, speed. Power up your [Adafruit IO](https://io.adafruit.com/) with the $99 pass for 1 year of the...

In Stock
[Buy Now](https://www.adafruit.com/product/3792)
[Related Guides to the Product](https://learn.adafruit.com/products/3792/guides)

## Related Guides

- [No-Code DS18B20 Temperature Sensor with WipperSnapper](https://learn.adafruit.com/using-ds18b20-temperature-sensor-with-wippersnapper.md)
- [All the Internet of Things - Episode Four: Adafruit IO](https://learn.adafruit.com/all-the-internet-of-things-episode-four-adafruit-io.md)
- [IoT Bird Feeder with Camera](https://learn.adafruit.com/iot-window-bird-feeder-with-camera.md)
- [How to Add a New Sensor or Component to Adafruit IO WipperSnapper](https://learn.adafruit.com/how-to-add-a-new-component-to-adafruit-io-wippersnapper.md)
- [Pico W PiCowBell Case](https://learn.adafruit.com/pico-w-picowbell-case.md)
- [Quickstart: Adafruit IO WipperSnapper ](https://learn.adafruit.com/quickstart-adafruit-io-wippersnapper.md)
- [Using Piezo Buzzers with WipperSnapper](https://learn.adafruit.com/using-piezo-buzzers-with-wippersnapper.md)
- [Adafruit IO Basics: Feeds](https://learn.adafruit.com/adafruit-io-basics-feeds.md)
- [CircuitPython OctoPrint Controller and Monitor](https://learn.adafruit.com/circuitpython-octoprint-controller-and-monitor.md)
- [Where's My Friend? A Location-Aware Display with PyPortal and ItsASnap](https://learn.adafruit.com/where-s-my-friend-a-location-display-frame-with-pyportal.md)
- [No-Code Battery Monitoring with WipperSnapper](https://learn.adafruit.com/no-code-battery-monitoring-with-wippersnapper.md)
- [Adafruit IO Basics: Analog Output](https://learn.adafruit.com/adafruit-io-basics-analog-output.md)
- [Memento Photo Capture with itsaSNAP](https://learn.adafruit.com/memento-photo-capture-with-itsasnap.md)
- [Adafruit IO Basics: Dashboards](https://learn.adafruit.com/adafruit-io-basics-dashboards.md)
- [Welcome to Adafruit IO](https://learn.adafruit.com/welcome-to-adafruit-io.md)
