Building a low cost wifi camera

Update! Here is a post with the BOM for the project.

Sometime ago I came across the Arducam Mini which is quite a nice camera module from UCTronics. It is a small PCB with a two megapixel OmniVision OV2640 sensor, an interchangeable lens and an FPGA to do the heavy lifting of image processing and JPEG encoding. Priced at around 24 Euros (lens included) you can easily buy a few without hurting your wallet and combined with an ESP8266 you can build quite a low cost wifi camera. Or several. Because designing and building PCBs is both fun and inexpensive I designed a board to go with the ESP8266/Arducam Mini combo, aptly named the Esparducam. And uniquely named too, try googeling for “esparducam“. Heck, even the domain name is available at the time of writing 🙂

The Espaducam board
The Espaducam board

Anyhow. The Esparducam board is a development board for the Arducam Mini module and is quite well suited for ESP8266 development in general.

Espaducam with Arducam Mini module
Espaducam with Arducam Mini module

The board is powered through a barrel connector at a minimum of 5V (upper limit untested) and all the IO pins on the ESP8266 are available on pin headers. The double rows are intended for the design of small breakout boards that sit on the inner 0.1″ aligned headers while the outer headers allow for connecting logic analyzers/oscilloscopes and so on. The Arducam Mini module plugs right into the front header and the standard FTDI connector is at the back of the board.

Image quality is, imho, quite decent at this price point, here are a few samples.

An optional SPI flash can be mounted for image storage and you can connect a standard eBay PIR module to the white JST header next to the FTDI connector if you want to build a motion triggered camera.

I am no hardware engineer but if you are and you find any silly design mistakes please let me know.

Schematics
Schematics

You can order the Esparducam board form DirtyPBCs and I would love to know if you build one. I plan to build a few for house monitoring, kite photography, reading my water meter and whatever else I can come up with.

The demo application listens to port 80 for HTTP GETs and will capture and return an image. It also has a command line interface on the serial port and the command ‘upload:<ip number>’ will capture an image and upload it via HTTP. A Python script is included that will receive and display the image using your system’s default image viewer. Note that the demo application is just that, a demo application. It does not handle simultaneous clients, errors or anything else that occurs in the real world.

IMG_3761Lastly a note about the lens. It uses a mount called M12xP0.5 and there are plenty of lenses to choose between. The one included with the Arducam Mini module has about the same field of view as a normal 50mm lens on a full frame DSLR. I would recommend getting a 3.2mm lens or shorter for some more wide angle if you plan to use the module for surveillance applications. The 3.2mm lens (called LS-40136) can focus at a very short distance making it a candidate for water meter reading applications.

I have yet to try the even shorter ones like the LS-20150 at 2.8mm or the LS-40166 at 2.6mm.

The Esparducam turned out so nice it became my preferred ESP8266 development board, why is a different post.

Code and hardware schematics as always on Github.

 

 

64 thoughts on “Building a low cost wifi camera

  1. Pingback: A versatile ESP8266 development board – Johan Kanflo

  2. Pingback: Building a low cost wifi camera - Electronics-Lab

  3. eas

    I was just reading the datasheet for the OV2640 tonight. It has its own JPEG capable compression engine. I wonder if Arducam is using it and just using the FPGA to provide the serial data interface (the OV2640 has a parallel interface for data), or if they are doing compression on the FPGA as well.

    1. Johan

      Interesting, I haven’t checked the data sheet myself. The sensors I have seen so far just provides raw bayer data and leaves the image processing and subsequent image compression to you.

      1. eas

        I have an OV7670 module that I want to try to get working with the ESP8266. I picked it because it was the cheapest available, at less than $4 US. It can spit out various RGB, or YUV/YCrCb formats. No compression though, beyond the chroma subsampling in YCrCb.

        I figured if I could acheive a high-bit rate, I could upgrade to something more capable.

        It looks like ArduCam may use the FPGA to present a consistent command set and hardware interface across camera modules. In poking through their ArduCam library it doesn’t seem complicated enough to be providing the abstraction in software.

    1. Johan

      That would be an interesting use case. I tried tesseract on an image of my water meter and it did find the static text on the meter. Image quality is ok for OCR I think and the optics can focus on quite a short distance (~15 cm with the wide angle lens I tried).

          1. Johan

            I had a quick glance at the 7670 and the amount of required IO seem to be too much for the ESP8266. The ESP32 would probably do.

    1. Johan

      Thanks! The frame rate currently is quite poor but then there’s lots of optimization to be made. For instance I read the JPEG FIFO one byte at a time (one complete SPI transaction for each byte image data). There is a streamed mode on the Arducam Mini that would increase frame rate by at least 4x.

  4. PaulG

    Great project, thanks so much for sharing.

    I too would be interested in buying components for my own projects, specifically how to take and send an image “on demand”, kinda “I’m in the vicinity, gimme a sit-rep.”.

    Some thoughts on building battery powered units would be helpful (to me). For me, this almost always boils down to “how do I switch it on, on demand?” “what power usage can it get down to in listening mode?”.

    Anyhow, another use-case you might take into consideration when keeping options open for other makers.

    1. Johan

      Thanks! I just finished a write up about the BOM. Running the Esparducam on battery would be interesting. I guess adding a PIR to wake the ESP from deep sleep and log on to wifi would be the way to go. I have not looked into low power operation of the ESP8266 yet.

  5. Pingback: ESP8266 WiFi Module Design Notes - manton

    1. Johan

      Actually I noted that sellers on AliExpress have a better price, €1.63 compared to €3.00 on eBay. I just search for ESP-12f, sort by lowest price and pick the first seller with many orders and good reputation.

    1. Johan

      A couple of 100ms. Currently I don’t use the fastest way of reading data from the camera module. I will get back with an exact number when I have optimised the code.

  6. Johan

    Hi Johan,

    Thanks for this great project!!
    I got this already running on a NodeMCU and of course
    i need to try your project too!

    i ordered a few of those boards and can’t wait to start 🙂

    Regards,
    Johan

  7. johan

    Hi Johan,

    Question. is there much difference when i use the ESP-14 instead of the ESP-12?
    When i mount the components except the ESP module the power voltage is 3.3 V.
    But as soon as i mount the ESP-14 the LM1117 is getting extremely hot.

    I tried to build two units with exact the same result.

    Regards,
    Johan

    1. Johan

      I have no experience with the ’14 but a quick Google turns out it’s not pin compatible with the ESP-12. The ’14 GND pad is in the same location as the ’12 VCC for starters. Do you have an ESP-12?

  8. Jep

    Hi Johan,
    Thanks so much for sharing your project!
    I’d like to get your opinion on what I intend to do which is not so far from that …
    I’m looking for the cheapest configuration that would allow me to do the following:
    1) take a screenshot from any low size camera (low resolution is not a problem) when a tilt sensor is triggered
    2) wake up a wifi soc (esp8266 would be the best because of its price) to send the picture to a web site
    3) return into deep sleep mode and notify the user (could be done though the web server I guess …)
    Any idea of the best configuration to do that? 🙂

    1. Johan

      Hi Jep,

      Sorry for the delay. You could use a Arducam/Esparducam combo for this but you could of course run everything on a Ras Pi. It depends on your {size, power & monetary} budget.

      Regards,
      Johan

      1. Jep

        Hi Johan,

        No problem for delay of course!! 🙂
        Esparducam is a good idea but it is much too high in terms of budget
        I was targeting something like the OV7670 but I’m afraid there are too few GPIOs on ESP8266.

        Regards,
        Jep

  9. Pingback: Weekend Reads [14th May 2016] | esp8266hints

  10. Johan

    Hi Johan,

    Just finished my build with the ESP-12. Looks much better.
    Yes. the ESP-14 is definitly not compatible with the ESP-12.

    Now i need a way to flash this baby as my esptool sais it cannot
    connect to the ESP8266

    Regards,
    Johan

    1. Johan

      Hi. That sounds strange. A few things worth checking, depending on what gear you have. Current consumption, voltage level at relevant pins. I have found that sometimes I need to revisit some ESP12 pads with the soldering iron. Check the GND pad on the ESP. Also check GPIO 0 and 2. Also, you might have a dead ESP12 module. I often find that one out of 10 is a dud. That’s why I always test my ’12s using the pinlet board prior to mounting.

  11. Johan

    Hi Johan,

    I got it working.

    The problem was the esptool.py what i use to program
    the esparducam. it seems that you have to put the gpio0 to the ground
    and power cycle the board. After that it can find the esp8266 and am i
    able to program it.

    The setup is working good. It is faster as running the cam on a NodeMCU.

    Regards,
    Johan

  12. David Clapp

    Nice project. I’ve not got a board built and am working through the build readme.

    fatal: Authentication failed for ‘https://github.com/kanflo/eor-spi.spiflash/’

    That wants a user and password?

      1. David Clapp

        That was easy – thanks.

        Sorry to be dense, but one more please:
        …/esp-open-rtos/common.mk:356: extras/http-upload/component.mk: No such file or directory
        Did I miss the easy path to http-upload? Git has so many of them…

  13. Johan

    Hi Johan,

    Question. Does your code also support the OV5642? I tried that camera
    as it has a better resolution as the OV2640 but with the OV5642
    cam i only have SPI errors.

    Welcome to camera mon. Type ‘help’ for, well, help
    % Camera power cycle
    scandone
    arducam_spi_init
    arducam_i2c_init
    SPI interface error (got 0xff)!

    with the Arducam code there was a bit rotation needed what was done in the SPI.c but i have
    no idea how to get that done with open-rtos

    uint8_t SPIClass::transfer(uint8_t data) {
    while(SPI1CMD & SPIBUSY) {}
    // reset to 8Bit mode
    setDataBits(8);
    SPI1W0 = data;
    SPI1CMD |= SPIBUSY;
    while(SPI1CMD & SPIBUSY) {}
    uint8_t val = SPI1W0 & 0xff;
    val = (byte)(val >> 1) | (val << 7); // correction for bit rotation from readbac
    k
    return val;
    //return (uint8_t) (SPI1W0 & 0xff);
    }

    Regards,
    Johan

  14. iota

    Sir,
    How is viewing angle of this ? can i use it as car reverse camera. It needs good viewing angle of 170 – 180 degrees to be a reverse camera for the car.

  15. Ben

    Hi, what is the program flash size? nearly full 1MB?
    I am thinking if we can use 2 of esp-8266 to connect wifi directly or through a router. One ESP8266 as a surveillance camera sending video 24/7 to another ESP8266 which is storing video to either a sd card or hard drive? Able to do so?

      1. ben

        Thanks for your advise. So do you mean use ESP8266 s a surveillance camera sending video 24/7 to another Pi Zero or even a Windows PC which is storing video to either a sd card or hard drive?

        1. Johan

          You’re welcome. Mind that the Arducam does not produce video but JPEGs, thus you will not get a very high frame rate. It will make quite a good still image surveillance camera though. I plan to use a PIR to detect when to capture.

          1. ben

            Thank you very much for this advise on Arducam which now I had realized my mistake. Now I know why Arducam did not reply my second email after I had let them know it is a video project.
            Yes, I am also planning to use PIR to start camera with a delay to 30 seconds after PIR had stop detecting motion.
            Is ESP8266 has the ability to act as a surveillance video camera with low resolution 480p, 8 frame/s?

          2. Johan

            It might be able to do 8fps at low resolution. There is still improvements to be made in reading the image from the Arducam sensor.

    1. Johan

      Hi Dave. You could have WU pull the image directly from the camera (there is an implementation for that) but it would probably better to have the camera upload the image to a server where WU can request it.

          1. Dave

            Johan, good point i didn’t think of the lense. I only want to take pictures of the sky to go with the weather station data. In your opinion would the standard 60° lense do the trick, seems like it should be good enough for my purposes. Thanks.

          2. Johan

            60° should be enough, according to Wired the FOV on the iPhone 6 camera is 63.54° for comparison.

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*