This camera never sleeps

pascal boudalier
4 min readApr 18, 2024

--

Hacking my way out of disappointment.

I’ve been thinking for a while to install a small camera to watch the 13 solar panels I installed in my garden.

Not that I am concerned they may walk away. In fact, I am interested in looking at shading, in evaluating whether it would be worth moving some of the panels to a better place, a place with less shade.

My idea is to take a picture of my solar array every hour or so, every day and then eventually have a look at the yearly picture.

A timelapse. Not a big deal.

Adorable camera

A few weeks ago, I spotted this adorable, inexpensive (15$) tiny camera from M5 stack (I typically love their products).

Out of the box, this camera can be configured to take pictures on a regular basis, and either save the pictures on a local SD card, or push them to M5 stack’s cloud.

This seems to fit the bill. I ordered this tiny camera.

The camera comes with a lego mount. How cute!

Afterthought

Waiting for the camera to arrive, I suddenly realized that I had made a critical assumption which may indeed be false. I assumed the camera would deep sleep between taking pictures.

Deep sleep is a very common mechanism for embedded devices and allow the device to consume almost no power for a long time, then wake up, do its job, and go back to deep sleep until the next wake up.

Power consumption in deep sleep mode can be 100’s, 1000’s time less than when running “normally”.

I know the micro-controler powering the camera is perfectly capable of deep sleep, and of course I want deep sleep.

Because this camera is to be installed at the back of my garden, and would be powered by a battery charged with a small 6W solar panel.

Such a setting is not enough to power a camera running continuously, but is perfectly adequate if the camera were using deep sleep.

It is true that for this very application, I have all the power I need. Afterall, I could just use my mighty 5000W solar array (and any wall plug USB charger) to power the camera. But this would have created its own set of problem, such as running a cable on the ground from the array to the location I have chosen for the camera. Messy. I passed on this idea.

Bummer

Upon receiving the camera, I quickly realized its software is not designed to use deep-sleep. It just idles, doing nothing between taking pictures, just sucking energy.

Bummer.

The camera consumes 60 ma while running. Too much for a battery-operated project.

Even if energy wise this product sucks (energy too), feature wise it is quite nice and comprehensive. In particular, it can provide a real-time feed to any browser which connects to the camera.

So what about salvaging this project and repurposing the device I just bought into a very inexpensive, cloud free, “surveillance” camera?

If the camera sucks power 24x7, at least let’s have it provide a 25 fps real-time feed.

The real time feed is available from any browser

Bummer again

The real time feed works flawlessly but, bummer again, it is only available in the “configuration” phase of the system, when the credentials for the home wifi network are entered.

I guess that for the M5 Stack guy who wrote the camera’s software, it is only meant as a help to correctly position the camera, before starting the regular picture taking.

I shall not be left defeated

At this point, I had invested a bit of time and expectation in this project, and I had nothing concrete.

It is time to react. After all, the camera’s software is open source. So let’s modify the camera software to add a real time stream mode.

The modified firmware is available on github.

It was not a particularly difficult task. I just had to carefully analyze how the standard software works and “rewire” some modules.

The way the modified software works is as follows:

  • when the camera boots, it creates its own little wifi network (ssid = “UnitCamS3-WiFi-PABOU”).
  • once connected to this wifi, one can access the camera web page (192.168.4.1) and enter the credentials for the home wifi.
  • the camera will use those credentials to connect to the home wifi.
  • then just point any browser to http://IP-of-camera/api/v1/stream/, and you’ll get a real time steam of what the camera is currently seeing.

It is good practice to configure your home router to allocate a fixed IP address to the camera. In addition, one can also use NAT (network address translation) and dynamic DNS to access the camera feed from anywhere on the Internet.

Connecting two pins on the back of the camera will enable “standard” software
The camera creates its own Wifi. use 192.168.4.1 to access the camera configuration

Enter home wifi credential using Image Poster SetUp

Go to http://IP-of-camera/api/v1/stream/ and enjoy the real time steam… et voila!

--

--

pascal boudalier
pascal boudalier

Written by pascal boudalier

Tinkering with Raspberry PI, ESP32, RiscV, Solar, LifePo4, IoT, Zigbee, energy harvesting, Python, MicroPython, Keras, Tensorflow, tflite, TPU. Ex Intel and HP