Hi Folks,Im on a quick turnaround putting together a little timelapse kit for my next grow, so I thought I would blog this as yall might find it useful.Im doing it in a way which others could reproduce quite easily I hope, and get to a decent good quality and low cost.

I did a mini time-lapse for my last grow, but only a small vid early on before the grow lighting was turned on and saturated the poor little IP camera that was tasked with it.Check it out here ;

Doing that I had lots of other ideas how I would like it done properly, showing much more of the growth, start to finish if possible! So here I am, and for this grow im going to give it a crack.Im going to use an airpot and have a Think Different in there. the camera will have to pan out as it gets older.

At the moment im awaiting a couple of gizmo's to arrive so I can hobble the solution together from relatively standard components. Im going to be using the now famous Raspberry Pi board to run things, and its optional camera module to collect some snapshots at regular intervals and store them away. I might also attach one or more Hd webcams and thus collect several angles at once.

The 5MP camera module of the Raspberry Pi looks quite decent spec for what I need (cant block up my DSLR for months!) , will snapshot a resolution of 2592 x 1944 , very nice compared to the 800x600 I was getting previously on a Tenvis PTZ IP camera. Since the cam will be close at start and physically be stepped back to keep the growing plant in shot, this should give incredible clarity and a HD 1080p video at the end.

So the R-Pi board is en route, also the camera module. As well as this a couple of sold state relays, the R-Pi will drive these and control the grow lighting and white lighting , switching back to white for each time-lapse shot.

That's the plan anyway, I'll post some pics when stuff arrives and as I go along with this project.

I should mention a few other bits are required but I have those to hand so no need to order. Power supply, a 2A micro USB power supply, Ethernet cables, HDMI cables, a spare USB hub and USB keyboard & mouse, and a HDMI monitor. Most of that stuff will be needed only for the setup and testing, later we will leave the R-Pi to run by itself without most of this stuff.

I think I could make use of a spare USB HD webcam maybe even two, and have this thing taking several timelapse vids from >1 angle. I'll focus first cam on the whole plant and another up close to the top bud.OK so not bad on spend so far. For what it'll do I think its good anyway, not so long ago this would have required a spend of thousands im sure.

OMG Godzilla, you make it look so easy.You said that not so long ago this would all have cost thousands, well also the kit required would have taken up half your growroom. You crammed all that into something the size of a fag packet!!!That Raspberry Pi is amazing, I googled it just now, and now your thread makes total sense. Its just a tiny basic computer, but the way you have decided to adapt it is pure genius. I am looking forward to seeing this evolve.... I've said it before on other threads, man you should market some of this stuff!!

Ok things are getting up and running! the Raspberry Pi is a great little thing really.

I connected the board up, HDMI to my TV for the moment, LAN, USB hub with mouse and keyboard. I also attached the Pi's camera module on, inserted the SD card which is pre-loaded with the operating system "raspian wheezy".Time to power up

The R-Pi boots up looking like a typical Linux startup, then you're hit with a menu about the install.

We need to make some setup here. Go to the internationalisation settings and correct the locale and timezone, keyboard layout if needed. I went with en-GB and London timezone, standard 105key layout.Back in the main menu, use the enable R-Pi camera support optionThen expand FS to fill the card (option 1)Also, enable boot to desktop.

Go to advanced options, change the hostname to "pilapse" and enable the SSH interface in case we need it later.

Fine so far then in the menu go to finish and select to reboot the Pi.

After the restart it will load the GUI and things look a bit prettier :

Great, time to test the camera module we've got plugged in. The software needed for it is already on the raspberry pi, so all we need is to see it work. Open the LXTerminal , we have to type some commands.Also open the File Manager (icon near bottom left) and leave that around, it open in default at your home folder, we'll try to take some snapshots in a second, we'll see them appear here and be able to open and check.

In the LXterminal, issue this command ;

>raspistill -o test.jpg -w 2592 -h 1944

It does its thing and an image appears in the folder we've got open. The camera module is 5 mega pixel, so it has a pretty decent 2592 x 1944 resolution. So far so good.

Next up is to see that the Web cams I want to use in addition can do the same. I have two sat here, a SWEEX WC061 and a Microsoft LifeCam HD-5001. These are now plugged in.!

In the LXTerminal issue this cmd and see if the devices are picked up OK ;

>ls -l /dev/video*

I can see /dev/video0/dev/video1

these are the two webcams. time to install a software which can take the snapshots for us. we will use the fswebcam package, it is installed from the internet so make sure you are connected.install the software ;

Ok peeps next update, I have now connected the extra hardware that we need - the relays to control the lighting, an LED so we know when its "live" , and a switch to stop it being live (so we dont get caught in shot).

To do it I connected to the Raspberry Pi's P1 interface, where there is some I/O pins we can use. I have connected like this ;

P1 - pin 4 , +5V VCC, in case we need it. - pin 1 , +3.3V , we'll need this to run the switch off at least, since R-Pi does not tolerate 5V input. - pin 18 - GPIO24 - this connects to a latching switch, push turns on, push again turns off etc. The other end of the switch connects to +3.3V. So the switch is between pin 1 and pin 18 - pin 22 - GPIO25 - this connects to anode (long leg) of an LED to show the "live" status. I used a blue LED and put a 47 ohm resistor in series. -pin 24 - GPIO8 - this connects to the first SSR's + input on the low side. -pin 26 - GPIO7 - this connects to the second SSR's + input on the low side.

-pin 20 - GPIO23 - connected it while I was there, maybe could be used to drive some power white or IR led's , perhaps during the darkness hours the timelapse can continue without disturbing the plants too much?

Heres how it looks now at the Raspberry Pi end ;

the cable used was some 8 core alarm cable. This is the other end wired into the relays, LED and switch ;

You can see the LED is ON and so are the Relays, since I took the shot after testing. There is nothing plugged in their high side yet, but the LED's on the SSR's shows the status.

Next to interact with that stuff. I will rely on the Kernel driver for the GPIO, it means we can do it with the similar commands in LXTerminal like before.

To setup those pins we used for use, we need to configure them and set their direction as so

>sudo su (get root permission otherwise next commands will fail)

>echo "7" > /sys/class/gpio/export

>echo "8" > /sys/class/gpio/export

>echo "25" > /sys/class/gpio/export

>echo "24" > /sys/class/gpio/export

>echo "out" > /sys/class/gpio/gpio7/direction

>echo "out" > /sys/class/gpio/gpio8/direction

>echo "out" > /sys/class/gpio/gpio25/direction

>echo "in" > /sys/class/gpio/gpio24/direction

Now we are ready to use those IO! First lets try read the switch ;

>cat /sys/class/gpio/gpio24/value

toggle the switch and re-run and confirm the return value changes.

Finally lets switch on the SSR's and the indication LED to verify all is working OK ;

echo "1" > /sys/class/gpio/gpio7/value

echo "1" > /sys/class/gpio/gpio8/value

echo "1" > /sys/class/gpio/gpio25/value

Heres what it should look like ;

After the next reboot of the Pi, all the export and directions will be default again. We want this configuration to be applied on startup. To do it those commands need to be entered into a bash script, and set the script to auto run.In /home/pi/bin I create a new file called startup_script.sh which contains this ;

#set LED indicator and Flash LED to OFF stateecho "0" > /sys/class/gpio/gpio25/value

stateDN=$(./resolveDN.sh)

if [ "$stateDN" -eq "1" ] then echo "DAY"else echo "NIGHT"fi

echo "Done"

Then you need to edit the /etc/rc.local file, and set this script to start automatically. This is what the updated rc.local file looks like ;#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.

Now all is well, straight after reboot you can fire any command to change the IO state, they are already set up correctly.

Gonna have to call it a night there but that's not a bad place to leave it. Most of the immediate HW challenge is done I think, next some software config will get us taking the timelapses , and other cool stuff. Looking pretty good so far.

Glad I finally found a reason to get acquainted with the raspberry pi, im growing to like this little gem very quickly

Last edited by godzilla on Thu Nov 28, 2013 1:44 am, edited 1 time in total.

looking good guys. have got some of the software scripting sorted out over the weekend so that the Pi now controls the lighting ON/OFF period for a start, and building up more scripts that manage the other functions.just wrapping up (I hope) a box containing the mains electronics, switches and indicators, also the low level night lighting. this will go on the wall and a cable runs down to the Pi (since the Pi and its camera cant be separated to a long distance, it needs to be able to be moved)needed to get this done now as I can test with the right combo of switches and sort out the disable function. Also, I reckon couple more days SW tweaking and Im almost ready to deploy, so makes sense to get it together in a safe and sensible way.

managed to get a few more things sorted on the control box tonite, still got the usb hub to fit tomorrow but the rest looks good to go.I'll post a wiring diagram tomorrow, running short of time

Now the only power in is into the control box, the Raspberry Pi is fed 5V from the beefy 3.8A PSU, which also powers the LED "night light" and will power the USB hub and the camera's once they attached. Nice that it avoids having to plug the micro USB power into the Pi to power it. there will be two cables in the end between the Pi and the control box, the power+gpio white cable, and USB from the Pi back to the hub. usb cameras will branch out from there.

In the control box there are the two solid state relays on their heatsinks. they switch the mains to the grow lighting and white lighting under control of the raspberry pi. I added an LED drive using a MOSFET driver to take R-Pi's 3.3V output and drive fully on the IRF830 power MOSFET. That thing will drive a lot more than we're asking of it, I just had these bits so made use of them here. The flash LED is an Osram single chip, kind of thing you might get in your mobile phone. This will be used to continue timelapse during lighting offtime hours.

This shot is taken in darkness, lit only by the flash LED.

The setup so far. No longer a bundle of wires and stuff on the end of the desk