Extended time lapse with Internet connection and power saving - General Help and Assistance on using CHDK stable releases - CHDK Forum

Extended time lapse with Internet connection and power saving

  • 130 Replies
  • 42189 Views
*

Offline Sdack

  • ***
  • 195
Extended time lapse with Internet connection and power saving
« on: 02 / October / 2017, 22:15:58 »
Advertisements
Hi folks,
Thanks for this amazing resource and community.

I'm a professional video producer with a smattering of Python programming and a yearning for DIY.
I have a time lapse project in mind to cover the construction of two classrooms at a local school and have identified CHDK as the best solution for quality and affordability.

After some research here and with Google, I've narrowed my camera choice to two recent 20MP models.  ELPH/IXUS160 and Powershot SX410IS, both of which I understand to be successfully ported.

The initial goals for my CHDK rig are as follows (using a Raspberry Pi (with a SleepyPi2 HAT - or STM32 microcontroller to add a Real Time Clock and power up the gear) 

https://spellfoundry.com/product/sleepy-pi-2/

  • To control the camera and Raspberry Pi on and off state
  • To capture RAW images at complex intervals, ie. Mon-Fri / every 10min / 8am-4pm
  • To move images from camera to USB connected Raspberry Pi and upload to a website (via alternate chdk-ptp), then delete the images from the SD card
  • To power the system from a single battery source
  • For Internet connection, use WIFI (available at the school)

I've been inspired by ahull's Sunset Timelapse Project, which features an STM32 microprocessor controlling power on and off, leading to extreme power savings ( the SleepyPi2 device includes an Arduino but it may be overkill and I might be able to get away with a cheaper STM board like ahull used)

https://hackaday.io/project/2126-sunset-and-sunrise-camera-controller

And Ant Thomas' Raspberry Pi timelapse set up (camera 2 - half way down the page), which features a hacked camera on/off switch and a bash linux script to handle the ptp and image uploading side of things.

http://www.antthomas.co.uk/webcam/guide.php

As I'll be relying on the SleepyPi2 (or microcontroller) to activate both camera and Raspberry Pi, I'll need to control the time lapse interval from there.

It's all a bit hazy still, so any comments criticism or advice are welcome.  Especially when it comes to power supply regulation and connections.  I'm such a novice with electronics I don't know a MOSFET from a relay or a resistors etc.

Here is a crude schematic of my idea.




*

Offline reyalp

  • ******
  • 14125
Re: Extended time lapse with Internet connection and power saving
« Reply #1 on: 18 / October / 2017, 18:44:43 »
FWIW, in the other thread (https://chdk.setepontos.com/index.php?topic=12648.msg134957#msg134957) I mentioned http://escursionisticivatesi.it/webcam/ is a somehwat similar raspberry pi/chdkptp based project. The source code is available at https://github.com/alesanmanoweb/multilapse-CHDK

Note the signal handling stuff currently requires https://github.com/LuaDist/lua-signal and a special build of the chdkptp executable. I expect to make the standard builds support this soon.

edit:
Just to be clear, I'm not the author of this code, I'm just passing it along as another example of something similar to what you are trying to do.
« Last Edit: 18 / October / 2017, 18:49:28 by reyalp »
Don't forget what the H stands for.

*

Offline Sdack

  • ***
  • 195
Re: Extended time lapse with Internet connection and power saving
« Reply #2 on: 18 / October / 2017, 19:09:08 »
Thanks,

I'd love to dive into this but my technical skills are already stretched nearly to breaking point, so I'll watch from the sidelines til it makes the mainstream.

Cheers

Nigel

Re: Extended time lapse with Internet connection and power saving
« Reply #3 on: 19 / October / 2017, 01:31:19 »
Hullo!
I made that script reyalp referenced (in fact, he helped me write most of it).
I can say that it's been online for over two years now, 24h/24, and just a few months ago I added two more cameras, and tweaked the details to make it extremely stable.

I also use a raspberry pi, the script has to be copied in a directory on your pi, customize the config file, and should be ready to run. It also has a "night" mode where it uses a long shutter time. If you want to try it out, I can give you some guidance.

Re: Extended time lapse with Internet connection and power saving
« Reply #4 on: 19 / October / 2017, 03:08:35 »
And Ant Thomas' Raspberry Pi timelapse set up (camera 2 - half way down the page), which features a hacked camera on/off switch and a bash linux script to handle the ptp and image uploading side of things.

http://www.antthomas.co.uk/webcam/guide.php

As I'll be relying on the SleepyPi2 (or microcontroller) to activate both camera and Raspberry Pi, I'll need to control the time lapse interval from there.

What kind of battery were you thinking to use? How often are you going to charge it? Controlling the power to the camera can be an issue - I decided to switch the actual power, not the camera switch, that I have shorted so the camera always "wakes up" when I powercycle. Please note that my camera (A4000is) did NOT work at 5V, it turned itself off at about 4.5V and above IIRC.

*

Offline Sdack

  • ***
  • 195
Re: Extended time lapse with Internet connection and power saving
« Reply #5 on: 19 / October / 2017, 05:06:36 »
I also use a raspberry pi, the script has to be copied in a directory on your pi, customize the config file, and should be ready to run.

I'd love to see how you manage it all but I got the impression from ReyAlp that I'd need some custom patches/libraries/bits and bobs to get your script working.  Considering I've just spent an entire day simply trying to install a USB wifi network dongle, I'm nervous about installing stuff I barely understand.
Quote
It also has a "night" mode where it uses a long shutter time. If you want to try it out, I can give you some guidance.
I like the idea of smooth motion in time lapses, plus the extra sharpness on static parts of the image that comes from longer exposures.  Will definitely be checking out your stuff.
Thanks again
Nigel

Re: Extended time lapse with Internet connection and power saving
« Reply #6 on: 19 / October / 2017, 10:39:42 »
I like the idea of smooth motion in time lapses, plus the extra sharpness on static parts of the image that comes from longer exposures.  Will definitely be checking out your stuff.

Oh I see what you mean, but in fact, it all boils down to use a zip file that I or reyalp can provide to you, instead of the generic one you can download from the website. This will include the whole chdkptp installation for the raspberry Pi. Let me know if you want to proceed.

*

Offline Sdack

  • ***
  • 195
Re: Extended time lapse with Internet connection and power saving
« Reply #7 on: 19 / October / 2017, 15:12:31 »
Hey thanks, that would be great..please hook me up!
I would love to see how you set up your bash script.. I'm a novice in that area too and have been struggling to get my command list organised.  I can now manage the very basics.. set manual focus.. set zoom, shoot (just JPEGs at this point), then copy to a USB stick in the Raspberry Pi and upload via FTP.

I'd like to figure out 3/4G mobile upload of (smaller resized) images because I have a possible remote shoot coming up and I need the peace of mind that it's all running smoothly.

Look forward to downloading your goodies

Thanks again
Nigel

Re: Extended time lapse with Internet connection and power saving
« Reply #8 on: 19 / October / 2017, 15:36:26 »
I would love to see how you set up your bash script.. I'm a novice in that area too and have been struggling to get my command list organised.  I can now manage the very basics.. set manual focus.. set zoom, shoot (just JPEGs at this point), then copy to a USB stick in the Raspberry Pi and upload via FTP.

Hello. Save for the very initial setup of the system, I do not really use a bash script. I think most people agree that bash's flow control operations and error handling is basic and not very readable. For this reason the "core" of the operations is Lua, that is the same language that chdk-ptp (running on the host) and CHDK (running on the camera) also use.

Setup bash script:
https://github.com/alesanmanoweb/multilapse-CHDK/blob/master/multilapse
As you can see, it merely sets something with LEDs (I turn off ALL of them, as I keep my Pi in the same box as the camera, and the emitted light interefers with night exposures) and then execute the Lua chdk-ptp script in an "infinite" loop, just in case it crashes.

Configuration file:
https://github.com/alesanmanoweb/multilapse-CHDK/blob/master/multilapse-config.lua
This is the file that containsl the main settings that you may have to tweak depending on the installation.

Main script:
https://github.com/alesanmanoweb/multilapse-CHDK/blob/master/multilapse.lua
I realize this might be more complicated than something you had in mind, and yes my very initial script over two years ago was much, much shorter. But, complete error handling, night exposure, thorough setup, complete logs, are items that bring in complexity. Please feel free to have a look at the script and see if it makes sense. I do not know if you have any Lua background, or any programming background at all :)

Misc files:
https://github.com/alesanmanoweb/multilapse-CHDK
'turnon' and 'turnoff' are two python scripts that are called by the Lua script to, guess what, turn on and off the camera. In my implementation they just flip a raspberry PI GPIO. If you use a different GPIO or any different method, just customize these scripts. Note: python is grossly overkill here. They could easily be Bash scripts. However, there is a neat Raspberry Pi GPIO library for python, and that is why I used it.

Quote
I'd like to figure out 3/4G mobile upload of (smaller resized) images because I have a possible remote shoot coming up and I need the peace of mind that it's all running smoothly.

Uploading files that have been resized down to a smaller resolution is definitely something that could be implemented, and it's not even a big deal; in fact I like the idea a lot. I might very well fix the script to support it.


Now, a question to reyalp: you gave me a "private" version of CHDK-PTP that supports signaling. I also know you want to port this experimental feature in the "mainstream" version of CHDK-PTP. Are you going to do it soon so user "Sdack" can get an official version, or can I just provide the binaries I already use for now? I ask this to avoid the proliferation of non-official builds unless it's necessary.

*

Offline reyalp

  • ******
  • 14125
Re: Extended time lapse with Internet connection and power saving
« Reply #9 on: 19 / October / 2017, 18:41:50 »
Are you going to do it soon so user "Sdack" can get an official version, or can I just provide the binaries I already use for now? I ask this to avoid the proliferation of non-official builds unless it's necessary.
I hope to do it "soon" but in the meantime the chdkptp build and signal.so is available at https://app.box.com/s/z02em32wedyqlmf29pidmwpxtrsuj16b this is now in the normal distribution https://app.assembla.com/spaces/chdkptp/documents

edit:
If you find the time, a description of the hardware side (power supply, power control from pi etc) might be of interest to the forum.
« Last Edit: 27 / November / 2017, 03:29:15 by reyalp »
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal