To monitor caterpillars bought from Insect Lore with timelapse and webcam as they grow and pupate.

UPDATE: The caterpillars are all now butterflies! Live webcam has stopped. You can catch up by watching the timelapse videos below.


The above webcam image was captured every minute. As well as being posted here, the images were saved and manually put into a timelapse sequence (30fps) using Openshot video editing software in Linux.

This video is of the first butterfly to emerge. It was FAST! It took less than a couple of minutes, so for the later video above I increased the capture rate to every 10s.

This video covers the last few days upto formation of chrysalides. The first caterpillar starts to pupate at about 1 minute in, the rest towards the 2-3 minute mark.

This is the video of the first couple of days timelapsed (30fps, original 1 frame per minute):

The python program that takes the pics, updates the webcam and turns on the IR LEDs:

import shutil
import time
import picamera
import datetime as dt
import RPi.GPIO as GPIO

#Set up the Pins. 23 & 24 each switch 3 IR LEDs
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)

#set up the camera
with picamera.PiCamera() as camera:
	camera.led = False
	camera.resolution = (640,480)
	camera.rotation = 270
	for filename in camera.capture_continuous('01caterpillar{counter:04d}.jpg'):

		#turn IR lights off

		print ('Captured %s' % filename)

		#copy latest picture to www for webcam
		shutil.copy(filename, "/var/www/images/caterpillars.jpg")
		print ('copied file to webcam')

                #add a timestamp to the picture 
                timestamp ='%Y-%m-%d %H:%M:%S')

		#is it time to turn on the IR lights?
		start = dt.time(4, 30) 
		end = dt.time(23)
		currentTime =

		if (start <= currentTime <= end):
			#turn IR lights on for next picture
	                GPIO.output(23, 1)
        	        GPIO.output(24, 1)