Sunday, October 18, 2015

Raspberry Pi Powered Hydroponics Version 2.0!

Intro

This is a big update and nearly everything has changed in some way. I have made an effort to simplify both the hydroponics parts and the Raspberry Pi computing parts to make things a little more robust than they had been. First I will discuss the hydroponic changes, what they are and why I made them, then get into the new Raspberry Pi changes and why I made them.

Hydroponics

The biggest change I made was to get ride of my three trough system for a simpler one large box system. The three troughs were interesting because i could swap the small cups in and out whenever I wanted but it also meant I have three water hoses and three options for leaks to happen. With a simple large box the gardening is more like you have a very small plot of land and have to pick and choose regions of your box to plant certain seeds. It also means that I only have one inlet tube and one outlet tube, which should give less opportunities for leaks to spring up. I am using the same water pump and water reservoir as before, just the plumbing has changed. 



I made the box our of a wooden palette then lined it with about 6 layers of black plastic trash bags. As you can see on the left side is the input spigot of water and the output is on the underside of the box on the right side (not shown). Planted the seeds a few weeks ago and already starting to see some sprouts!

Computing 

The major changes of this update have come on the computing side of the project. I am now using a Raspberry Pi 2, but that is largely inconsequential to the project but its worth mentioning. 

Previous posts have discussed how the addition of data to the mySQL data base every hour was hard on the SD cards and would cause them to be corrupted frequently.  In the past, to fix this, I had attached a small disk drive to the Pi so that all the reading and writing of the mySQL database and the collection of graphs that I was rendering would have some place more stable to sit. With this update I have decided that all of that was too complicated, and while the graphs were pretty cool I didn't look at them THAT often to really justify continuing with them. So I have done away with the disk drive, the USB hub to power it, the mySQL database, and the php grapher program.

In place of this I have added a second temperature sensor that I wired to the inside of the greenhouse so that I can see if the greenhouse is actually helping (spoiler alert: it is). Since the TMP36 (cheap temperature sensor) relies on voltage to determine the temperature, it was important that the control temperature sensor that sits outside the greenhouse on my window sil have the same length wiring as the one that runs inside. The increase in resistance associated with the longer wires was effecting the readings so I just made them the same length so I didn't have to worry about adjusting one or the other. I also still have the same basic light sensor I used before, except this time I convert its output to a % value which is more meaningful than some 8bit value it spits out. In my original testing I showed that you can change the range of these values based on how much light you are likely to detect with changing the resistor in its circuit. I determined that using my current resistor was a good range of light levels and 100% would be really really bright and 10% is nearly lights off. I am also still using the MCP3008 analog-to-digital convertor to convert the analog signals that the temperature and light sensors give into digital values the Pi can interoperate. 

Here is a cartoon I made of the Pi's wiring: 


I used this really great program called Fritzing to make this cartoon showing all the wiring of my Pi and the sensors! Its a free program (donations gladly accepted) http://fritzing.org/home/ . Check it out if you are interested.

The twitter code is largely the same except this time I am tweeting about the difference in the greenhouse temperature compared to the apartment air temperature. (and light levels and the Pi's core temperature) The temperature sensors are not super precise so if they are within two degrees of each other I claim the inside greenhouse compared to outside greenhouse are roughly the same. Its only if the difference if greater than 2 degrees (in either direction) that I claim one is warmer than the other. As we descend into winter I made add a line to the tweet about how big that difference is to really show off how well the greenhouse is doing but its fine for now.

All these changes have made the Pi a lot simpler, and it runs a program every hour and tweets its information. There is no storing of data or graphs so nothing is "building up" on the Pi which I hope will lead to longer term stability. Because the code is much simpler (and doesn't include a PHP graphing step) it runs MUCH quicker than the old code did. The code also includes the very small bit of logic surrounding the two temperature readings and how that changes what the Pi tweets. And as before I can't show you the Pi's twitter credentials for obvious reasons, but f you use this code that it where you would include your own credentials. (lines 122-125) Feel free to use the code however you please just remember to cite it!

And as always, follow the Pi on twitter so that t can spam you every hour! @rpiph1 12,200 tweets and growing!

Here is the simplified code: 

No comments:

Post a Comment