An "automatic" tomato grower featuring an Edison controller that manages lighting and watering while monitoring temperature, soil moisture, and light level. It also takes periodic pictures and strings them together in a time lapse video. All coding is in python.
This project was part of the Intel Internet of Things Incubator Round #2 in Sacramento, California. Thanks to Intel and the Hacker Lab for their sponsorship of Team Tomato.
See preliminary website here http://iot.got-skills.us/
Step 1: Making Parts for the Main Structure
The main structure was constructed from a redwood 2"x4"x6' (1.5"x3.5" actual dimensions).
A 32" piece of the 2x4 was ripped in half to form two 0.7"x3.5" pieces. These were then ripped to form six approximately 0.7"x0.7"x32" pieces. The ripping was done by cutting to about half the length of the board, then flipping the board 180 degrees and finishing the cut from the other end. That way, the hands stayed away from the saw blade.
The table saw fence was adjusted to rip the remaining 2x4 into four 0.3"x3.5"x40" pieces.
The table saw blade height was adjusted to match the fence to outer blade edge distance. Two passes for the six 0.7"x0.7"x32" pieces removed about a 0.5"x0.5" piece to form 6 "L" pieces.
Ten pieces the width of two 2x4's (7") were cut from the 0.3"x3.5"x40" pieces.
Six pieces of about 6.4" length (7" minus two widths of the 7" pieces) were cut from the 0.3"x3.5"x40" pieces.
Eight "L" pieces about 8" long were cut at 45 degrees to form a picture frame around two 0.3"x3.5"x7" pieces side by side.
Step 2: Assembling the Main Structure
A knotted bicycle inner tube around the frame pieces and a can of paint on the flat pieces applied pressure while the glue dried. Plastic wrap was used to keep the piece from sticking to the work bench.
Four 7" pieces and four 6.4" pieces were used to form the base sides. These eight pieces were glued to the 32" angle pieces and the bottom. The remaining pieces were used to form the top sides. Bicycle inner tubes around the base and top held things in place while the glue dried.
Four pieces of the 0.3"x3.5" stock were cut and attached to the outside of the base sides for mounting other parts. The base sides and bottom were lined with silicone caulking, applied while wearing a disposable glove.
Step 3: Attaching Hardware to Main Structure
Any uvc web cam will work (Logitech C310 USB 2.0 HD Webcam). Any low wattage grow light will work(Mudder® E27 5W LED Grow Light with E27 Light Bulb Socket). Any small pump will work (12V DC Peristaltic Pump and matching power supply with correct voltage and wattage).
A hole was drilled in the top for the light fixture, which was held in place by the spring it came with. The excess cord was wrapped around one of the corner "L" pieces. The switch was popped open and two small mounting holes drilled in the back cover. The switch back was mounted to the structure and the switch cover replaced.
The video camera was attached by removing the base cover, drilling a hole in the base, and attaching to the top side. Again, the excess cable was wound around an "L" piece.
The pump was mounted in a small piece of thin stock left over from making the sides. A hole was drilled in the stock piece the diameter of the pump and then the pump housing had two mounting holes for screws. The stock piece is held in place with another screw. It probably would have been better to put the hole in the top side directly.
A rain gauge to hold water (Ace Hardware) was mounted to one of the "L" pieces.
A 12V wall wart was soldered to the pump leads and the excess wire wrapped around an "L" piece.
The pump power supply, the Arduino power supply, and the light fixture were plugged into an extension cord.
Step 4: Attaching Electronics to Structure
The Arduino/Edison board was mounted on one side. Each item was connected and then mounted to insure the cable reached the iten. Two Grove relays were mounted to the side by the light switch using small screws.The display was mounted on a third side with a push button that does absolutely nothing. The temperature and light sensors were mounted to the inside of an "L" piece. The moisture sensor plug in was mounted by the Arduino/Edison board. The moisture sensor was poked into the potting soil and straddled the pump line to hold it in place.
The camera was plugged into the USB port and the micro switch flipped toward the USB port. The light sensor was connected to A0, the temperature sensor to A1, the moisture sensor to A2, the relays to D5 and D6, and the display to I2C0.
One wire was cut from the fixture, the ends stripped, and attached to the relay connected to D5. One wire was cut from the pump power supply, the ends stripped, and attached to the relay connected to D6. Probably a good idea to test the pump and light before wiring to the relays.
Step 5: Setting Up Edison
See getting started guide--get through flashing and configuring wifi.
Use the vi editor by copying vi /etc/opkg/base-feeds.conf
and pasting (use Ctrl-Shift-v to paste) at the Edison command line .
Type i to enter interactive mode.
Copy these lines
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
Do Ctrl-Shift-v to paste into vi editor.
Type a colon : then wq (for write and quit). Notice :wq at lower left of screen.
Type opkg update.
Don't do opkg upgrade!!
Install nano editor by typing opkg install nano
Update mraa and upm libraries.
Type echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
Type opkg update
Type opkg install libmraa0
Type opkg install upm
Change directory to sdcard by typing cd /media/sdcard
Create directory on sdcard by typing mkdir myprog
Change directory to myprog by typing cd myprog
Create directory in myprog by typing mkdir images
Step 6: Setting Software Up
Open terminal and SSH into Edison (type SSH email@example.com). Enter password from setup.
Navigate to project folder (cd /media/sdcard/myprog)
Download ffmpeg into folder with this command:
Unzip the file:
tar xvf ffmpeg-git-32bit-static.tar.xz
Make ffmpeg executable
chmod +x /media/sdcard/myprog/ffmpeg/ffmpeg
Test the video camera with this command:
ffmpeg/ffmpeg -ss 0.5 -i /dev/video0 -vframes 1 -s 720x480 -f image2 /media/sdcard/myprog/test0001.jpg
Type ls to see if test0001.jpg was produced.
If so test the video making command:
ffmpeg/ffmpeg -f image2 -i 'test%04d.jpg' -pix_fmt yuv420p -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k video.mp4
Type ls to see if video.mp4 was produced.
An easy way to transfer files between a computer and the Edison is to use filezilla or some other ftp program (host is IP address from wifi setup, username is root, password is from setup, port is 22).
The light relay would "jitter" with both apscheduler and crontab running separate scripts, so all the scripts were combined into one, instructableProgram.py. The pumpsettings.txt just holds the number of seconds the pump is on. The idea was to eventually have the Edison serve a webpage on the local network that could modify the program variables. The picnum.txt file holds the current number of pictures taken. It initially should hold the value 0000. To upload using ftp to a website, change the website.com, username, and password strings at the end of the program file.
After uploading the files to the myprog directory. run the script by typing python instructableProgram.py.
To make the script run on boot, copy it to the /etc/init.d directory:
cp /media/sdcard/myprog/instructableProgram.py /etc/init.d/instructableProgram.py
Make the file executable:
chmod +x /etc/init.d/instructableProgram.py
Make the file run on boot:
update-rc.d /etc/init.d/instructableProgram.py defaults