This post will try and cover what is required to setup a time lapse system on a Kijanigrows V2 Control board using a webcam, and an SD card. Let me know if anything is unclear or if you have any questions about the process. I am very new to coding in Linux and most of what I learned in this lesson I don’t entirely understand, but hopefully this will get you up and running with some time lapse photography, which is a very fun way to track the growth of your plants!
What is needed:
- Kijanigrows V2 control board, and power supply, connected to your network.
- MicroSD card formatted in FAT32.
- USB Webcam (I used this one)
- Computer on the same network as the Kijanigrows V2 controller.
- You know the IP address of your controller
- An ssh client (I used PuTTY for Windows)
Power down your V2 controller board, and plug in your camera. Power up the board. Once powered up, give it a minute to connect to the network, then using your computer that is on the same network as your controller, open up a web browser and navigate to http://yourboardsipaddress:8080 (for example, my board’s IP address is 10.0.0.2 on my network so I navigated to “http://10.0.0.2:8080” and you should see a stream of your USB camera’s video feed.
If you see the video feed, that means the board has connected to your camera, and is likely able to grab a screenshot of this feed and save it to a jpg on an SD card based on a bit of code you’re going to write into the main garden utilities script. To do that, we’ll need to use an ssh client to edit the scripts on the controller.
Next, open up your ssh client on a computer that is on the same network as the controller, and ssh into port 22 of the IP address of your V2 controller.
In this case, my board’s IP address was 10.0.0.2.
Once you press enter or click “Open”, you will be prompted for the login information for your controller. This is the same login information you use to configure your controller over its HTML server. First type your username, in my case I used “root”, and then press enter, and then your password, and press enter. When you type your password, you won’t see any characters, but just type it and press enter and it should work.
After your login, you should see a screen like this:
Type “ls” and press enter. A list of things in the root directory will show up like this:
You are going to edit “gardenUtils.sh” and add some code to take a snapshot from the video stream and save it to a jpg on the sd card. To do this first type “vi gardenUtils.sh” and press enter, you should see something like this, without the last few lines:
Type “G” and then press enter, then type “o” and then press enter. You now should be able to type and have what you type add to the file. Type the following three lines in (the last line is a bit long but should be all on the same line):
mount /dev/sda1 /tmp/tlapse
while true; do curl -s http://localhost:8080/?action=snapshot >/tmp/tlapse/tlapse_`date +”%Y%m%d%H%M%S”`.jpg ; sleep 60; done &
When done typing that in, press esc, then type “wq” and press enter. What that does is write the changes and quit the file editor. The first line created a temporary directory to store the pictures your camera will take. The next line mounts the SD card and makes it the same as the directory with the pictures. The third line takes a photo from the webcam and stores it on the SD card with tlapse_ and then the date and time as its name, every 60 seconds. To change the frequency of photos, simply change the 60 to any other amount of seconds.
Now, you can power down the controller, plug in your microSD, and power it up. Wait a few minutes and power it down, remove the SD, and put it in your computer and see if you can see the photos. If so, you’re all set to now string them together using a third party software. If not, look through the steps again, and if you get stuck, contact me or Eric and we’ll see if we can help.
To turn the photos into a video, I personally use GoPro Studio, which is free software. A good tutorial on making time lapses using GoPro Studio is here.
Happy time lapse’ing!