Close
0%
0%

Low cost / low power sleep / WiFi Camera

Using e.g. ESP32 and cheap camera to make a remote monitoring device that can watch things e.g. meters, gages, etc...

Public Chat
Similar projects worth following
As machine vision becomes more accessible, there are many opportunities to monitor things over time in the real world by looking at them, visually, with a webcam, instead of integrating a sensor or electronic interface. I want to monitor my water use by taking remote pictures of the water meter. It's in a place where anything of value will be stolen. Also, no place for wires (sidewalk) so battery only which means low power shutdown between pictures.

I'll use my existing software:

https://github.com/JamesNewton/esp8266WebSerial

ported to ESP32, for easy setup of WiFi router connection, configuration of the pause between pics, what URL to post the pic to, etc... 

A few low cost hardware platforms were suggested at

https://hackaday.io/page/5754-lowest-possible-wifi-camera-with-low-power-sleep

but I went with 

https://www.banggood.com/TTGO-T-Journal-ESP32-Camera-Development-Board-OV2640-SMA-WiFi-3dbi-Antenna-0_91-OLED-Camera-Board-p-1379925.html?cur_warehouse=CN

because for $12 as a development version, the extra cost is well worth convenience. Hopefully the code can be ported to lower cost hardware, or even custom hardware in the future.

The overall flow after setup is:

1. wake up on RTC, check external pin to see if an event has happened during sleep, if not, go back to sleep. If this feature isn't desired, it can be disabled in config, or just pull the external pin high. The idea here is that we can wait for a light to flash on a control panel, or for some other detectable event before powering all the way up to take a pic.

2. If we are waking, try to connect to the configured WiFi. If there is no connection after a few tries, and this was our first power on, go into AP mode and wait for someone to connect and feed us a configuration.  (see the esp8266WebSerial project above for more details). 

3. If we are waking and connected to WiFi, turn on the LEDs, take a picture, turn off the LEDs, upload the picture to the configured server. In the future, some form of image processing might be added here. E.g. mask out and xmit only parts of the picture (where the dials, digits, indicators are) or subtract this picture from the last one taken and send only the difference, etc... 

4. Also upload any data e.g. from a serial port connected to a peripheral device, the status of our external event pin, battery status, etc... A "trigger" string to be sent to the peripheral can also be configured. This allows an external sensor / data logger to be used in addition to or instead of the camera. An sscanf regexp can be configured to extract up to 3 values from the returned data for local display with linear conversion to engineering units ( Y = mX + b ). 

5. if the upload succeeds, and there is no return data from the server, sleep. On failure, try again for some number of times before giving up. If we have a display, flag the error. If the server returned data, parse it for settings changes (e.g. faster or slower interval) and respond to those. A message can also be set from the server on the local display if there is one. Any additional data is sent to the peripheral device and a few seconds allowed for a response, which then takes us back to step 4. This allows the user to request that the server get additional data / change settings in the peripheral the next time the device checks in. 

Most of that is already in the ESP8266 code above, but will need to be ported / re-written. The camera / image upload will be new. Not sure if the porting or the camera would be the better starting point. 

ESP32-camera-with-support.png

For the TTGO T-Journal ESP32 with OV2640 Camera there is a model ready to be 3D-Printed with a small base: https://www.thingiverse.com/thing:3360687

Portable Network Graphics (PNG) - 504.27 kB - 01/17/2019 at 07:16

Preview

  • Simple image logging using BigIot.net

    Martin Fasani01/19/2019 at 06:53 0 comments

    I was thinking that it could be useful for someone that just needs to read a water metric or anything from a remote place in a different network, it could be useful to try the bigiot.net example.

    The only disadvantage is that is in Chinese and online translators don't seem to work well to translate private admin dashboards (Or at least not Google and Bing that I tried)

    So to simplify it in a few steps you need to : 

    1. Register in bigiot : https://www.bigiot.net/User/register
    2. Create a device and an interface
    3. Use the Apikey, Device ID and interface ID in the demo example here:

    https://github.com/martinberlin/ESP32-Camera/tree/master/examples/BIGIOT_UpdateImage

    I modified the original code to add WiFi Manager and to publish some information in the oled display.

    Then you can make a camera that uploads an image every X seconds without needing to code or prepare any backend for this, you can see a preview here:

    https://twitter.com/martinfasani/status/1086506846679109632

    So after that and uploading the code with the right credentials you can log in to BIGIOT and just click on the Camera device eye, to see the latest picture, or also see a log of the sent uploads.

    If you select the interface to be public, then the URL is public as well:

    https://www.bigiot.net/Public/upload/inputImg/9110/7832/ -> No matter what settings I've tried, it keeps always the last 9 images.

    I though it was an interesting thing to share. If it does not have much to do with the project feel free to move this away @James Newton 

  • ESPAsyncWebServer on ESP32

    James Newton01/16/2019 at 19:06 5 comments

    While the standard ESPAsyncWebServer does work on the ESP32, the author does not support the Arduino IDE for it's use, preferring PlatformIO. I want to stay with the ugly beast because it makes the code accessible to a wider range of people (Ok, really I just don't want to learn Yet. Another. IDE). Specifically, the the examples for web servers do not work in the Arduino IDE. However, this page provides a series of examples (See "Related Posts") which document how to make it work. 

    https://techtutorialsx.com/2018/08/14/esp32-async-http-web-server-websockets-introduction/

    e.g. a simple web server via access point:

    #include "WiFi.h"
    #include "ESPAsyncWebServer.h"
     
    const char *ssid = "MyESP32AP";
    const char *password = "testpassword";
     
    AsyncWebServer server(80);
     
    void setup(){
      Serial.begin(115200);
     
      WiFi.softAP(ssid, password);
     
      Serial.println();
      Serial.print("IP address: ");
      Serial.println(WiFi.softAPIP());
     
      server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){
        request->send(200, "text/plain", "Hello World");
      });
     
      server.begin();
    }
     
    void loop(){}

     I'm assuming the Async Web Server is still a better option than the built in web server which requires polling (VERY unstable if you do anything of note in the main loop). Please let me know if you have a better option. 

  • Poor picture focus / quality

    James Newton01/08/2019 at 04:17 11 comments

    Got the TTGO-CAMERA hardware. It works... ish... the picture quality is... less than fantastic. Here is a sample:



    https://hackaday.io/project/162968/gallery#f19805f77b13adad91ca41d4d607a9ec

    Both units have about the same picture quality. If anything, this was the better one. 

    I included some objects in the foreground so you can see the focus isn't any better there. 

    I'm not at all convinced that lousy focus is going to work for reading even the most bold meters. Anyone have ideas on improving the optics? Lense seem very glued on, not removable. So it would need "corrective lenses" and I'm not an optician.


  • Web hosted OCR options

    James Newton12/31/2018 at 20:08 0 comments

    Compute Engine can be setup to use Googles (very nice) image processing tools:
    https://cloud.google.com/functions/docs/tutorials/ocr

    The nice thing about google is that you get a certain amount each month free. And they use Node.js so moving part of it local is easy. The down side is that you must hope google doesn't abandon the service, change the pricing, or generally dick something else up on you. Hopefully, others have better options for local FOSS OCR. 

View all 4 project logs

Enjoy this project?

Share

Discussions

Martin Fasani wrote 01/17/2019 at 12:15 point

QUESTION: Does anyone tried a library that will detect movement comparing images ?

I would like to send images from one of this cheap cameras but only when something changes. Every jpg image weights about 10 /12Kb and if I do a security cam that sends a picture every second, then I will end up with:

12 KB*60*60*24 = 1036,8 Megabytes per day. That's way much (Of course I won't even by capable to send this at this speed I guess)

Does anyone try to do something like this ?  The goal would be to compare 2 Jpegs and say if the difference threeshold is more than X, then upload a new image.

Research links:
https://stackoverflow.com/questions/3395872/image-comparison-algorithm

https://github.com/mapbox/pixelmatch-cpp (This one looks interesting)

  Are you sure? yes | no

James Newton wrote 01/17/2019 at 17:50 point

That's exactly the sort of thing I think we should try to add to this project, once we get a bit further along in the code. 

  Are you sure? yes | no

Martin Fasani wrote 01/21/2019 at 06:48 point

This is the JPEG decompressor that needs to be used
https://github.com/espressif/esp-idf/blob/master/components/esp32/include/rom/tjpgd.h

Arduino JpegDecoder is not suited for the work it collapses parsing this 800x600 photo :(

http://elm-chan.org/fsw/tjpgd/en/appnote.html -> Chinese magic

  Are you sure? yes | no

James Newton wrote 01/08/2019 at 04:26 point

The library and example code for the TTGO-CAMERA

https://github.com/LilyGO/ESP32-Camera

  Are you sure? yes | no

Martin Fasani wrote 01/18/2019 at 07:11 point

Updated the Case now it fits better: https://www.thingiverse.com/thing:3360687
So far I added only WiFI Manager (development branch) to the Station example and also a bit more fancy display stuff (Captures counter, feedback when no WiFi is found)

I made a fork of this here: https://github.com/martinberlin/ESP32-Camera

But I'm planning to check some images comparison libraries too. Maybe when that is done we can add it to the log.

  Are you sure? yes | no

James Newton wrote 01/18/2019 at 20:45 point

Looks nice, but how do you mount that to anything? Double sided tape?

  Are you sure? yes | no

Martin Fasani wrote 01/18/2019 at 20:55 point

I dislike profoundly this tree-reply system at hackaday....

I would do an old-times unique hole and attach it somewhere. For tests can stay still. Just added the right ball size so it stays quiet!

  Are you sure? yes | no

Martin Fasani wrote 01/06/2019 at 12:08 point

I also ordered one of this in Alixpress so when it comes I will design some nice case and 3D-print it

  Are you sure? yes | no

James Newton wrote 01/06/2019 at 06:04 point

Check it out! Expressif is working on even nicer hardware an already have firmware for face detection. 

https://www.cnx-software.com/2019/01/02/esp-eye-esp32-ai-development-board/

  Are you sure? yes | no

Martin Fasani wrote 01/18/2019 at 21:05 point

It looks very nice but still having trouble to differentiate Sophia Loren from Robert de Niro. Let's give them at least some months more. So far is just a nice demo

  Are you sure? yes | no

James Newton wrote 01/18/2019 at 21:31 point

Im just blown away that you can any sort of face detect on ~$12 worth of hardware. Slaughterbots are looking more and more real everyday.

  Are you sure? yes | no

James Newton wrote 12/26/2018 at 17:19 point

this project 

https://hackaday.io/project/162256-esp32-8266-wifi-instant-camera

Is perfect except that it uses the $40 Arducam.

  Are you sure? yes | no

Martin Fasani wrote 12/26/2018 at 18:00 point

Project is far from perfect, but you can use as a working example for Arducam-> Spiffs or Arducam -> WiFi directly. There is also the 2MP OV2640 option that is a bit cheaper but does not get down of $30 at least here in germany

  Are you sure? yes | no

James Newton wrote 12/26/2018 at 18:21 point

Hard to beat the $7 to $13 total cost of an ESP32 and dumb camera for this simple application. The Arducam et all is simply out of the price range for this one.

  Are you sure? yes | no

Martin Fasani wrote 12/29/2018 at 22:02 point

Joined your invitation, tell me later in what areas I can help

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates