Time Lapse Camera

About the project

While the Espruino board doesn't have enough memory to take proper pictures, nothing stops it from controlling other devices. In many cases this is a cheaper and more power efficient way to get the same result!

Project info

Difficulty: Easy

Platforms: Espruino

Estimated time: 4 hours

License: Apache License 2.0 (Apache-2.0)

Items used in this project

Hardware components

insulated wire insulated wire x 1
'808' key ring camera '808' key ring camera http://www.chucklohr.com/808/index.shtml x 1

Hand tools and fabrication machines

soldering iron soldering iron x 1

Story

The Espruino board will fake the keypresses needed to turn the camera on, put it into picture mode, take a picture, and then turn it off.

Here, we'll show you how to make a time lapse camera using a cheap keyring camera and an Espruino board.

While the Espruino board doesn't have enough memory to take proper pictures, nothing stops it from controlling other devices. In many cases this is a cheaper and more power efficient way to get the same result!

Wiring




  • Take the camera to pieces - there are two screws on the 'keyring' end of the camera
  • Remove the PCB from the case (there are 3 screws), and disconnect the battery

Connect the wires as shown in the picture. You need:

  • One wire to the battery's positive terminal (red)
  • One wire to each side of the 'shutter' switch. The (green) wire nearest the camera sensor is ground, the other (yellow) wire is the shutter signal.
  • One wire to the power button nearest the edge of the board (orange)

  • Re-assemble everything. If your wires are thick then you may need to leave out the two plastic buttons and the three internal screws.
  • Now connect to Espruino:



The image above shows an Espruino Pico prototype, but you can also use a 'classic' Espruino board for this.

How it works

The manual says the following:



So (while Espruino can't check the SD card!), we need to follow the steps given which we'll do using timeouts and callbacks.

The one slight 'gotcha' is that the camera requires quite a lot of power across the 'power' button to be able to turn itself on. In order to get this from Espruino without any external components we're just going to join two outputs together (A5 and A6).

Software

Load the code below into Espruino, type save(), and you're sorted! Espruino will run off the keyring camera's battery and take a picture every 60 seconds.

Just edit the last few lines of code below to change the time period that the camera is active for...

  1. var PWR = [A5,A6];
  2. // PWR active high - we need a lot of current to force the camera on, so use 2 pins
  3. var SHUTTER = A7;
  4. // SHUTTER active low
  5.  
  6.  
  7. // Pulse the power pin(s) high for the given time period, wait, and call the callback
  8. function pulsePWR(time, callbackDelay, callback) {
  9. digitalWrite(PWR,255);
  10. setTimeout(function() {
  11. digitalRead(PWR); // set to open circuit
  12. if (callback) setTimeout(callback,callbackDelay);
  13. },time);
  14. }
  15.  
  16. // Turn power on
  17. function powerOn(callback) {
  18. pulsePWR(2000, 2000, callback);
  19. }
  20.  
  21. // Turn power off
  22. function powerOff(callback) {
  23. pulsePWR(3000, 2000, callback);
  24. }
  25.  
  26. // Short-press power to switch modes
  27. function toggleMode(callback) {
  28. pulsePWR(100, 1000, callback);
  29. }
  30.  
  31. // Short-press shutter to take picture
  32. function shutter(callback) {
  33. digitalWrite(SHUTTER,0);
  34. setTimeout(function() {
  35. digitalRead(SHUTTER); // set to open circuit
  36. if (callback) setTimeout(callback,1000);
  37. },100);
  38. }
  39.  
  40. // Glue all the commands together to turn the camera on and take a picture
  41. function takePicture() {
  42. powerOn(function() {
  43. toggleMode(function() {
  44. shutter(function() {
  45. powerOff();
  46. });
  47. });
  48. });
  49. }
  50.  
  51. // Flash every 15s to show we're alive
  52. setInterval(function() {
  53. digitalPulse(LED1,1,20);
  54. }, 15000);
  55. // Take a picture every 60s
  56. setInterval(function() {
  57. takePicture();
  58. }, 60*1000);
  59.  
  60. // Go into power save mode
  61. setDeepSleep(1);

Now you have this framework, you could easily use it to record a few seconds of video every few minutes, or when a Pyroelectricsensor detected motion!



Credits

Photo of Espruino

Espruino

Espruino, Espruino Pico and Puck.js are low-power Microcontrollers that run JavaScript. Espruino is a JavaScript Interpreter for Microcontrollers that is designed to make development quick and easy. The Espruino interpreter is firmware that runs on a variety of different microcontrollers, but we also make Espruino Boards that come with the interpreter pre-installed and are the easiest devices to get started with. However Espruino itself isn't just the interpreter firmware or hardware - there's also the Web IDE, command-line tools, documentation, tutorials, and modules that form a complete solution for embedded software development.

   

Leave your feedback...