Saturday, December 28, 2013

Miniature Hydroponic Test Drive

Acquired some exciting hydroponic supplies and decided to give it a go on a small scale to start testing out some ideas.

I filled my 10 gallon fish tank with 2 gallons of tap water, put in the aquarium heater and a small aquarium (80 gallon per hour) submersible pump. I used a thin plastic piece (was originally intended to be a plastic cutting board) to create a trough that the water could flow down. I used some plastic tubing to direct the water from the pump to the trough. I had planned to use two troughs which is why you see the Y splitter in the tubing, however I did not have enough seeds, and thought I would test one trough out first, especially given some worries I had about the flow rate of the small pump I was using.  The trough is supported by red plastic cups and the plastic tubing is fastened to the trough with twist ties. 





Working in a lab we have these thin plastic cards with different whole sizes in them that are trashed after the pipette tips they hold are all used up. I cut some of the orange ones up to use as water baffles in between each row of cups. 




I then cut up some plastic cups and cut slits in their bottoms so that water can flow through. I filled the cups up with perlite and added some seeds. Some of you may recognize the little brown cups, these are seed pods from an old Aerogarden kit I had. The other 6 pods can some other herb seeds. I put the top on the tank and turned its lights on! As soon as the cups were put in the water flow the perlite immediately soaked up a bunch of water. Finally I added 4 teaspoons of liquid fertilizer to the tank. (2 teaspoons per gallon was the recommendation on the bottle)





Here is a short movie showing the flow rate of the pump I am using. 




Hopefully I will have some pictures of sprouting plants in a week or two! 



Raspberry Pi File System Corruption Issues - Upgrade to an External USB hardrive

I hit the first hardware road block of using such a cheap computer like the Pi. Its SD card is great for some things and a very cheap source of memory, however it doesn't do so well if you are constantly writing it, like I was every hour with the MySQL database.

The problem was I would come in to check on the Pi, because I noticed it had stopped tweeting, and the Pi had crashed. When I tried to reboot it I ran into tons of file system corruption things when the Pi was trying to boot back up. I went through all the system checks and even tried wiping the SD card clean a few times and reinstalling everything, AND tried using a new SD card. After a week or two, every time, the Pi would crash. My problem was probably exacerbated by the poor wiring in my apartment and big users of power such as my dishwasher, combined with the AC or microwave can cause the lights to dim. These power fluctuations could have also contributed to the crashing and improper shutdown linux. 

A quick search on the google showed that the file system corruption I was experiencing is a not so rare problem people have with using a MySQL database on the SD card of the Pi. The solution is to move the whole file system over to an external USB drive. The Pi need to keep the booting program on the SD card but everything else can be moved to the USB drive and you can rewrite the boot program to tell it to boot form the USB drive and not the SD card. I also used this as an opportunity to get a lot more space and bought a 160gb USB drive. 

Since I installed this, the Pi has run uninterrupted for almost 60 days and counting. I unfortunately have lost the exact recipe I followed to transfer the file system from the SD card to the USB drive but a quick google search will give you plenty of options. I used a few different pieces from several websites. There is lots of information out there about this issue and how to utilize an external USB drive. 

Here is the Pi sitting on my table connected to the USB drive and its breadboard with all the current sensors. The drive and the Pi are powered from a powered USB hub. 


Thursday, September 12, 2013

Basic Light and Temperature Sensing

Here I use two cheap analog sensors for temperature and light:
http://www.adafruit.com/products/165
http://www.adafruit.com/products/161

And convert their analog values to digital values using an Analog to Digital convertor (ADC)
http://www.adafruit.com/products/856

To make things easy I wire these up on an external breadboard connected to the Pi using a Pi cobbler:
http://www.adafruit.com/products/914

Tutorials for installing and using these components can be found on Adafruit's website and I used them heavily. I could explain the technical details of all these components but Adafruit probably does a more elegant job and has tons of documentation so please follow the links for more information. Also the temperature sensor and the ADC are used by TONS of people so a quick google search will give lots of results as well!



Also a quick note about the light sensor:
I use a 1K resistor to change by values a bit. This resistor gives me a nice range when the light is bright. If you use a larger resistor (say 10k) it will be better at resolving lower light level differences. Play around with it and use a resistor that gives you a nice dynamic range for the light levels you are interested in sensing.

Basic Twitter Code using the Tweepy API

So this is a super simple script that allows me to tweet from the command line which is pretty cool! I call the file tweeter.py and can tweet by saying...

$sudo python tweeter.py 'Message I want to tweet'



I can't show you the sensitive information from Twitter for obvious reasons, but you should plug your information into those spots and it should work for you. You do need to visit the developer Twitter website to set up the API, link it to your account, and have they give you your appropriate numbers. Here is the tutorial I followed to get this done.

http://c-mobberley.com/wordpress/index.php/2013/04/26/raspberry-pi-connect-to-twitter-account-using-tweepy-installation-and-tweet-cpu-temperature-example/

Monday, August 26, 2013

Flickr and mySQL

I have them now which is very exciting. The idea is to mirror what Esologic.com  did and have the Pi dump its sensor data, (that I am currently just tweeting) into a mySQL database then have pChart render a graph from that data and upload it to Flickr. From there, tweepy, my twitter API, can post the link to the Flickr photo yay :)

I got the Flickr API here:
http://stuvel.eu/flickrapi

And used a apt-get command to get mySQL

Here is a great intro to mySQL that I found extremely helpful to understanding exactly what I was doing:
https://www.digitalocean.com/community/articles/a-basic-mysql-tutorial


Also it seems that the internet is very happy about how well pChart and mySQL databases play with each other so once I get pChart up and running I will have another post about that.

Wednesday, August 21, 2013

A very rudimentary drawing...


This initial idea has the water reservoir being a ~10 gallon fish tank. The tank is elevated so that the water has less distance to travel vertically to reduce the strain on the pump. The growing tubes are gutter downspouts. The "humidity chimney" is simply a pipe that vents the atmosphere from the fish tank reservoir to the atmosphere in the greenhouse to conserve and transfer humidity. Water evaporation is going to happen and so the thought is to at least direct the water vapor into the greenhouse chamber where the plants can benefit from it!


And now for some timing

I had originally planned to use Advanced Python Scheduler (APS) to run the programs that periodically check all the sensors of the hydroponic set up. However, I struggled to get APS working quite the way I wanted so it seems like it will be easier just to use chrontab instead.

Here are two awesome websites with some basic background info on how chrontab works.

http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/

http://blog.davidsingleton.org/raspberry-pi-webcam-a-gentle-intro-to-crontab/



Code coming soon!

Saturday, July 20, 2013

Light!

That wonderful stream of photons that drives photosynthesis inside the chloroplasts. Our little $0.95 photocells preformed great in their first test. In the dark of a closet they measured 500,000 Ohms and outside in the mid afternoon sun they measured 50 Ohms, a 4 log range! Very exciting.

It is reading from about 550nm to 650nm light (green-yellow range) which is what our eyes see the best. The plants however will prefer more blue (400nm-550nm) and red (650nm-700nm) which is hopefully what the LED lights will provide. But these sensors do a good job of reporting the relative intensity of the light and thats all we need from them!

In the future they will be used to monitor light levels inside the greenhouse chamber and potentially turn on the supplemental LED lights on cloudy or rainy days.

Closet: 500,000 ohms
Indoors, natural light: 1000 ohms
Indoors lights on: 1000-400 ohms
In front of an LED flashlight: 300 ohms
Outside in the midday sun: 50 ohms

It is however, an analog device. So we need an ADC to convert the signal so that the digital Pi can read it. Or we upgrade to the most expensive digital lux sensor that is more accurate and precise but about 10x more expensive. It also has a much wider range of light it can see; from visible all the way to IR.


Cheap analog sensor:
http://www.adafruit.com/products/161#Description

More expensive digital sensor:
http://www.adafruit.com/products/439


Wednesday, July 17, 2013

Some simple numbers.

Here's a simple python app to show integers versus floats.

I'm Alive! Follow me on twitter!

Using the Twitter API tweepy I can now tweet from the command line. I also learned how to tweet my processor temperature.

Tweeting will be crucial in the future as we plan to use Twitter for status updates on the hydroponics.

Follow me on Twitter!  @rpiph1 



Most of the credit goes to: Orer2ddo456 whose tutorial can be found here...

http://c-mobberley.com/wordpress/index.php/2013/04/26/raspberry-pi-connect-to-twitter-account-using-tweepy-installation-and-tweet-cpu-temperature-example/

Code to follow...

Monday, July 15, 2013

Hello World!

This blog will chronicle my attempts to get a raspberry pi to control and monitor a simple hydroponic set up. Living in an urban setting and still wanting to do a small amount of "farming" hydroponics offers the most efficient use of space/nutrients that won't slow down when it gets cold out! The idea is to do this as cheaply as possible with easily source-able and replaceable parts. The whole set up will be designed to sit inside by a window and have a footprint of ~ 2ft wide x 6ft long x 4ft high. It will hopefully also be able to tweet updates about the system on a regular basis for monitoring purposes.

The Pi will potentially monitor:
-water temp
-water level of the hydroponic reservoir
-light levels in the room
-air temp/humidity both inside and outside the greenhouse portion

This blog will have:
-pictures of the design as I work through it
-parts bought to build the green house and hydroponic parts
-part numbers of electronic monitoring components
-all the python code as it is developed

Here is some resources I have collected as I have begun to think about this problem:

PiPlanter:

Adafruit:

Phidgets- lots of sensors:

OpenSource environ control:

Atlas pH:

ET boxes:

GPIO:

Temp and Humidity Sensor:

Tweepy tutorial

Tweepy home explanations