In this guide, you will learn about the basics to timelapse your grow. Furthermore you will learn how to setup Linux on a Raspberry Pi Minicomputer, remote control it via VNC and how to use it as an FTP server.
List of items
To copy my workflow of approximately 10 minutes a week you need the following items:
- Raspberry Pi Minicomputer (buy @ amazon.com , 35 $) (Raspi) – This is the heart if this project. This device captures the photos at the right time ,saves the photos and is also your local Fileserver. There are different versions of the Raspberry Pi. Its important that the device can run WLAN. The best Pi to do this is the Raspberry Pi 3 Model B which brings the most calculating power.
- Raspberry Pi Wide Lens Camera (buy @ amazon.com, 23 $) – There are also some PiCams without a wide lense, but the optic helps alot in very
narrow rooms with less space
- A Power source for the Pi – You actually will not get this with a purchase of a Raspberry Pi! Make sure to have a power plug with a Micro-USB dongle which can deliver 5 V (Volts) and between 700 – 1000 ma (Milliampere). Any old smartphone loading plug should do it.
- HDMI-Cable, USB-Mouse and USB-Keyboard – You will need that only for setup. Once you setup the Pis remote control, you can use these for other purposes.
- Micro SD-Card – This is your hard drive of the Pi. Make sure you have one extra because this will stay in the Pi for the course of the run. 32 GB should be OK. for a whole run.
- WLAN Router – Since you cant access the filesystem on the card, without a linux based system, you will need to establish an FTP connection to the Pi. This is also pretty convenient because you dont have to interact with the Pi while its in the grow room anyways
PC, Notebook, etc … – This is necessary for moving pictures and merge the images in a reasonable time.
- Micro SD-Card reader – You need this to install the operating system on the Micro-SD Card.
Preparations – One Time Setup
Get the Pi ready
Everything in the Chapter Preparations you only need to do once.
- Download the operating System. You get the files here: https://www.raspberrypi.org/downloads/raspbian/ . The Version is called Raspian Stretch with Desktop as .zip and unzip it after downloading.
- In the meantime you download the software Etcher from https://etcher.io. You need that to get the OS on the SD-Card.
- After its done, put the Card in the Pi.
- Connect the HDMI-cable to a screen and then to the Pi alongside your USB-mouse and USB-keyboard.
- Plug-in the power and wait…
Raspberry Pi configuration
Congratz! You got a computer on your hands with the power of a five year old smartphone. Very much enough for this guide tho. The Pi wants to change the default setting at first start – its recommended but not necessary. The default login is username: pi, password: raspberry.This will be important later.
- In the configurations menu (caption of the picture) you can change the login.
- We will access the system time to shoot our photos. Make sure to change it to your local timezone: Click on Localisation > Timezone and choose the respective timezone.
- In the field Interface you activate the options Camera, SSH und VNC.
- Also in interfaces there is the option Keyboard. Set it to your needs! Coding is hard, if you’re using an EU keyboard with US (default) settings.
- On the Desktop to the upper right is a symbol to the WLAN connection. Connect it to your local WLAN.
Reboot the Pi to have all settings activated. You’re done configuring this for now. We’re heading to test the camera.
Testing the Camera – Your first picture
Connect the camera to the Pi. Make sure the connection adapter is tight aroung the cable. You can actually pull the sides of the connector out and back in after you set up the cable. Try it!
- Start the Pi by plugging in the power plug if not done yet.
- Start the Terminal (tool bar to the upper left) and update/upgrade the OS by typing in a row and confirm with enter:
sudo apt-get update
sudo apt-get upgrade
- This might take a few moments.
- Test the camera by typing in the terminal
raspistill -v -o test.jpg
This code will create the file test.jpg and saves it the given place (home/pi). Open the file to check out the picture!
- Call your local IP adress via typing
in the Terminal and write it down for the moment.
If the camera works, we now need to setup the automation and remote control.
VNC, SSH, FTP – Remote access
Our key target is to have the Pi shoot pictures inside the tent automatically. This is why the next step is to put the pi into the tent. You dont need the periphery keyboard, mouse or monitor anymore. Its your job now to find a nice perspective for the pi. Mine is below my DIY COB Light. Another Pi-Cam got installed on the wall. Mind that a Raspberry Pi can only handle one distinct Pi-Cam, but more than one USB-Webcam.
Remember this might be the final position. Test that, and make sure that it never moves.
- If everything is alright in the room, you can now switch on the Pi by plugging in the power source. There is no need to have a keyboard, mouse or monitor to be attached anymore,
- Download VNC-Viewer to your home PC or notebook (not the Pi). Remember to have the Pis IP adress around as well as the password and username for the connection. You can access the IP adress via your router config or by typing hostname -l in the Pis terminal.
- If you are connected tryout the code for shooting a picture again and calibrate the camera very carefully. You can turn on the lense to make the picture more sharp.
- Test the FTP connection: Download FileZilla or something similar (Filezilla download: https://filezilla-project.org/download.php) Don’t choose the pro version, its not needed.
- After you started Filezilla click File > Servermananger to connect.
- Protocol: SFTP – SSH File Transfer Protocol
- Server <local adress of the Pi>
- Connections: (normal: not as safe) but most convenient.
Now you should be connected to the Pi via your PC/notebook. You can now access the filesystem of the Pi via FileZilla and remote control it via VNC.
Creating the scheduler for the pictures
Now we are ready to script our photo scheduler using the software crontab on the Raspberry Pi. This software is able to execute operations at given time intervals. Perfect for timelapses.
Create a folder and change the restriction on it immediatly
We cant always create, read and write folders or files on the Pi, so we need to manipulate the accessability on a given folder first. Via rightclick > properties > permissions you can solve this. In the target folder for the pictures everything should be available for everyone.
Create the file “camera.sh” for capturing the photos
In the target folder (where you changed the read/write rights): Rightclick > Create New… > Empty File and name it camera.sh
- Open the file camera.sh in Text Editor and write the
cd <Path of the folder>
raspistill -n -q 100 -o <Path of the folder>$DATE.jpg
- Just exchange
<Path of the folder>
with the path to the place where camera.sh is. This code creates filenames like: 2018-10-15_2250.jpg and will therefore list the pics chronologically inside the folder.
- Test the script: Open up the Terminal. Navigate to the right folder via cd <Path of the folder> and confirm with Enter. After this you type in:
sudo sh camera.sh
into the Terminal. If everything works as intended there should now be a .jpg with a timestamp in the right folder!
Configure crontab to finalize automazation
In order to do this last step of preparation you need to be remote connected to the Pi via VNC. Open up the terminal and write:
sudo crontab -e
If you get asked what editor to choose, take nano. The terminal should change to this:
Be careful when editing this file! Scroll to the bottom of the file and press Enter to end up with a newline without a “#” symbol upfront.
Disclaimer: Youre probably using other light cycles. And we want the camera only to shoot when its bright for the plants.
*/20 21,22,23,0-8 * * * sh <Path to the folder>/camera.sh
How does this code work?
- */20 takes a photo every 20 minutes in a given hour
- 21,22,23,0-8 says that it only shoots pictures between 21:00h and 08:XXh. Change this, if youre different cycles!
- * * * takes care of weekdays, months and years. You put in asteriks so that you dont need to bother for this on the course of your run.
- sh initializes the shellscript of the camera.sh file
- <Path to folder>/camera.sh tells the cronjob what is to execute. In our case the photographing script.
Via the software FileZilla you should backup your files regulary. I do it once a week. If you config crontab my way, you will shoot about 18 pictures a day.
ffmpeg and rename.bat – Creating the timelapse
Turn on your PC/Notebook.
In order to use ffmpeg follow the instructions here. You only need to do it one to make it work: https://video.stackexchange.com/questions/20495/.
ffmpeg works the easiest with filenames that are numbered in order. To transform the filenames you need to create a file which you call rename.bat and write in the following code:
for %%a in (*.jpg) do (
set /a i+=1
ren "%%" "!i!.new"
ren *.new *.jpg
Now create your first timelapse:
- Copy all pictures to the folder with rename.bat in it. Never run rename.bat in your backup folder. It will destroy everything.
- start CMD and navigate to the timelapse folder: type in
cd <Path to the folder containing the renamed pictures>
- type in the following to initate the timelapse process:
ffmpeg -r 60 -i %d.JPG -s 1440x1080 -vcodec libx264 timelapse.mp4
This will create a 60 FPS videofile named “timelapse.mp4” with the resolution 1440×1080 under the x264 codec out of the renamed frames.
Maintenance and cleanup
It happens rarely, but you will find frames which you dont want to use in the timelapse. You need to sort them out before you rename the images and merge them. The ffmpeg code will not work if hes not fed with consecutive numbers.