Bruce C. Anderson
Published © CERN-OHL

Camera Time Lapse with Fixed Start Time

It takes a photo at a set time every day and then another photo every hour for 10 photos and repeats, ad infinitum.

BeginnerWork in progress5 hours2,182
Camera Time Lapse with Fixed Start Time

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
RTC DS3231 Module
×1
4-CHANNEL RELAY CONTROLLER FOR I2C
ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C
This is not the module that I actually used, it's just the closest I could find in Fritzing parts
×3

Story

Read more

Schematics

TIme Lapse Timer with fixed start time.

Used to take a photo at the same time every day and take another photo every hour for 10 hours. Then repeat the next day, ad infinitum.

Code

TIme Lapse Timer with fixed start time.

Arduino
Used to take a photo at the same time every day and take another photo every hour for 10 hours. Then repeat the next day, ad infinitum.
// A time lapse timer that starts at a fixed time everyday, and takes a photo then and every hour afterword for 10 photos. 
//Bruce C. Anderson  
//CH1 and CH2 activate IN1 and IN2 on a 4 relay module. 
//The camera used is a SJ400 Clone.  IN1 controls the on/off switch and mode selection.  IN2 controls the shutter.
//Both normally open circuits of the relays are hard-wired to their respective switches on the SJ4000 clone.
//IN1 fires to turn the camera on, after a short delay it fires again selecting the still photo mode of the SJ4000 clone.
//Again after a short delay IN2 fires triggering the shutter.  Another short delay and IN1 fires again turning off the camera.
//I copied the basis for this sketch from http://hack.lenotta.com/arduino-diy-stupid-plants-irrigator/ by  Edoardo Odorico and Lorenzo Farnararo.

#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 RTC;
int CH1 = 7;
int CH2 = 8;
bool done = false;

void setup () {
  //Initialize the serial port, wire library and RTC module
    Serial.begin(9600);
    Wire.begin();
    RTC.begin();
    digitalWrite(CH1, HIGH);
    digitalWrite(CH2, HIGH);
    pinMode(CH1, OUTPUT);
    pinMode(CH2, OUTPUT);
    //IF YOU USE RTC FOR THE FIRST TIME: Remove the comment from the following line to set up the module time.
   // RTC.adjust(DateTime(2017, 9, 21, 7, 57, 00));
}

void loop () {
    DateTime now = RTC.now();
  
      if(now.hour() == 8){
        if(now.minute() == 00){

    for (int i=0; i <= 10; i++){
          
   digitalWrite(CH1, LOW);  
   delay(250);
   digitalWrite(CH1, HIGH);   
   delay(10000);
   
   digitalWrite(CH1, LOW);  
   delay(250);
   digitalWrite(CH1, HIGH);   
   delay(3000);
   
   digitalWrite(CH2, LOW);  
   delay(250);
   digitalWrite(CH2,HIGH);   
   delay(3000);
   
   digitalWrite(CH1, LOW);  
   delay(3000);
   digitalWrite(CH1, HIGH); 
   
   delay(3600000);
        }
        }
        else{
          
    delay (3000);   }
      }
    }

   

Modify the class DateTime in RTClib.h

Arduino
// Modify the class DateTime in RTClib.h as follow:
//
//Baldarn and Edo
//http://hack.lenotta.com
//
class DateTime {
public:
    DateTime (uint32_t t =0);
    DateTime (uint16_t year, uint8_t month, uint8_t day,
                uint8_t hour =0, uint8_t min =0, uint8_t sec =0);
    DateTime (const char* date, const char* time);
    uint16_t year() const       { return 2000 + yOff; }
    uint8_t month() const       { return m; }
    uint8_t day() const         { return d; }
    uint8_t hour() const        { return hh; }
    uint8_t minute() const      { return mm; }
    uint8_t second() const      { return ss; }
    uint8_t dayOfWeek() const;

    //This is the function to calculate which day of the year it is:

    uint8_t dayOfYear() const;

    // 32-bit times as seconds since 1/1/2000
    long secondstime() const;   
    // 32-bit times as seconds since 1/1/1970
    uint32_t unixtime(void) const;

protected:
    uint8_t yOff, m, d, hh, mm, ss;
};

Add the following function to RTClib.cpp

Arduino
//Add the following function to RTClib.cpp:
//Baldarn and Edo
//http://hack.lenotta.com
//
uint8_t DateTime::dayOfYear() const {    
    uint16_t days = d;
    for (uint8_t i = 1; i < m; ++i)
        days += pgm_read_byte(daysInMonth + i - 1);
    if (m > 2 && yOff % 4 == 0)
        ++days;

    return days;
}

Credits

Bruce C. Anderson

Bruce C. Anderson

0 projects • 1 follower

Comments