Code Monkey home page Code Monkey logo

micropython-ov2640's Introduction

MicroPython class for OV2640 Camera

This is a basic interface to the ArduCAM OV2640 under MicroPython for the ESP8266. I wrote this because I could not find any good camera interfaces with MicroPython on the ESP8266.

Using this class you can:

  • Initiate still pictures up to 1600x1200 resolution
  • Read them from the camera
  • Save them to flash on the ESP8266

After saving the image you can use other modules to post it to a REST API, or save a (short) history of pictures on the flash for later retrieval.

Usage - Hardware Setup

This particular camera has both an i2c and spi interface for setup and getting data on/off the camera. A good way to wire up the camera to the ESP8266 is as follows (note Vcc and GND pins are not included here):

Camera Pin ESP8266 Pin
CS GPIO2
MOSI GPIO13
MISO GPIO12
SCK GPIO14
SDA GPIO4
SCL GPIO5

Usage - Software

First upload the module 'ov2640.py' into the root filesystem on the ESP8266 board you are using. The ampy tool from Adafruit is a useful tool for doing that. Together with esptool, you can re-flash your board and load the code here in one shot with these commands.

First download the latest MicroPython image from here.

sudo esptool.py --port /dev/ttyUSB0 erase_flash
sudo esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 ~/Downloads/esp8266-20170526-v1.9.bin
git clone https://github.com/namato/micropython-ov2640
cd micropython-ov2640
sudo ampy -p /dev/ttyUSB0 put boot.py
sudo ampy -p /dev/ttyUSB0 put main.py
sudo ampy -p /dev/ttyUSB0 put ov2640_constants.py
sudo ampy -p /dev/ttyUSB0 put ov2640_hires_constants.py
sudo ampy -p /dev/ttyUSB0 put ov2640_lores_constants.py
sudo ampy -p /dev/ttyUSB0 put ov2640.py

Then initialize and capture still frames using code like this. The included main.py contains an example.

import ov2640
cam = ov2640.ov2640()
nbytes = cam.capture_to_file("/image.jpg")

You can then retrieve the image off of the board, upload it to a server, etc.

A good way to retrieve files for testing/verification is rshell.

sudo rshell -p /dev/ttyUSB0
Connecting to /dev/ttyUSB0 ...
Welcome to rshell. Use Control-D to exit.
/home/namato/micropython-ov2640> 
/home/namato/micropython-ov2640> cp /image2.jpg .

This will copy the newly created image locally for viewing.

Credits

The original driver source from Arducam was instrumental in the creation of this pure MicroPython version.

The overall project was inspired by esparducam, but getting this to work doesn't require any SMD soldering. :)

micropython-ov2640's People

Contributors

namato avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.