Arduino Controlled Grow and PC Program - Work In Progress

AdvancedNewbie

Well-Known Member
This is what I've got so far... Damn, I want my touch screen.

[video=youtube;0HeIQbyVDoM]http://youtu.be/0HeIQbyVDoM[/video]

Edit: Lol, just noticed the 'C[zero]2' and that music was unintentional, but seemed to work out pretty good.
 

ommpCaregiver

Active Member
The user interface I have been working on is displayed on any computer via X forwarding. So the command to view the interface is like : 'ssh username@hostname -X greenhouse' --- username@hostname is obvious, -X forwards the X session for created a GUI on a remote machine when all the process memory is on the beaglebone remotely, and 'greenhouse' is the program name that is launched at a terminal.
I am writing this version (my 5th or 6th time writing this program now...) in python as big programs in C++ become hard to manage memory leaks and I end up spending more time keeping pointer/refrence registers in my mind ( like thinking ahead in chess) rather than the actual algorithm or design pattern I am implementing. Also a C or C++ program needs to be compiled for the specific chip arch that is being targeted, by using python, my code does not need to be compiled as it moves from beaglebone to raspberryPi to atom n450 processors, the user just needs to use openembedded or yocto (both bitbake based cross-compiler toolchains) to build their linux kernel and a filesystem with python ( which the recipes are well supported). Right now there are a lot of loose ends in my python codebase, and I want to get it to a working v0.1 (temp controlled relays with temperature hysterisis and such, also pin mux) before I push it to the github tree.

Those little nokia screens are cool, we have a bunch of them at our local hackerspace.. I thought about putting an industrial strength touchscreen on the front of my junction box, but decides against it, as it makes NEMA 4 compliance much more difficult, as well as the cost of replacing broken screens from the field would deter some farmers. However there are some cheap units for prototyping available here: http://andahammer.com/ or ask around for a TI EVM dev board ( usually like the Zoom and am335x-evm ) as I have seen a few of these being given away to people that have a use for it.

Is the temp and RH coming from same sensor ( looks like DHT-11 )? I used to use the white version of those (DHT-22) but there isn't a driver for them in linux, so I have sourced sensors that use i2c instead.

I have for sure decided to use the m305e from dcs-inc as a c02 sensor, they are cheap, powered over 5v, provide spi and analog out as well as an on board relay trigger ( the sensor has a pic16f876a micro with all the set point control logic built in). I also pulled one from a broken 'Green Air Products spc-1' and I fixed the sensor (which Green Air would not do, even when I went to their factory to talk with their tech who refused to help me, and then I tried to talk to the owner about the help I recieved and he told me he didn't want customers that did not have $300 to fix a $600 controller that is barely over a year old ( more about the point of shitty support over money) and then he called me a "stupid kid" (I am 29 and not stupid) and told me to leave) -did I mention to buy Titan controls over Green Air if you have a choice... But yeah, I now have a working m305e and am compiling my kernel for spidev support as I type this..

Also to stear you further away from the darkside... Microsoft will not survive the tale of time. Every child born into this earth inherits all of the work people have done to create the Linux kernel and all GNU source code, this is free for them to build upon, use in whatever way their imagination can find a use for. On the contrast, every child born into this earth must pay for Microsoft's secret, they are not free to build a racecar with the wheel of the OS, they are charged ( kept in slavery due to the difference in the amount of money it takes for a human to live, vs the revenue streams of big corporations to keep the masses in a state of slavery ). By using and buying into Microsoft products (and apple or any other highly proprietary lock-in type vendor) you are supporting the idea of slavery and helping to eliminate the middle class common people, dooming your grandchildren into a life of forced slavery under the guise of 'freedom' (and since every one is thinking with atoms extracted from McDonald's cheeseburgers, they are 'asleep'). The choice is yours (this also applies to your career as a programmer) - the human community of honesty, openness, and love; or the corporate shareholders with their greed, secrets, and fear. IMO the working environments (and not your desk or box) in a Linux shop are much more human (sustainable and responsible) than my past experience working in shops using (any part of) the Microsoft stack. I understand the learning journey (I compiled my first source in Visual Studio), and am just trying to help shine some light on a path as we wander through the maze in the dark.
 

AdvancedNewbie

Well-Known Member
That's some deep input right there... haha.. I understand that about MS and I actually run both. I'm not sure, but I believe I could compile this for use in linux, so long as the anything to do with the serial port still works... Hmm. But meh, the code for the arduino outputs serial data, so all's good there; just need to interpret the info after that. And yeah, these nokia screens are pretty sweet for $5. The temp and humidity are from the DHT-11 (right now) but I've ordered a more precise temperature sensor. Good for now.
 

AdvancedNewbie

Well-Known Member
Big Update coming soon. Firmata is scrapped and it's much easier to add I2C, onewire, DHT, etc... sensors and the individual sensors have their own database tables that are now handled by a SQL server. "Historical" working good. You can select any range of days you want and see the graph, in which you can then zoom up on the graph. Now the arduino is not dependent on the computer, but does receive timesync message and logs data when the computer is on. Here's some screenshots:

Diagnostics Screenshot.jpgHistory Screenshot.jpg
 

AdvancedNewbie

Well-Known Member
I have just ordered a different Ethernet shield as the one I have now wasn't compatible with the new arduino IDE and has very old libraries. It's much easier to program a W5100 Ethernet shield, and so I should be able to program SQL INSERT commands to be sent via Ethernet and the arduino will be able to log to the SQL database when the program isn't running. The Ethernet shield also has a SD card slot which will log data while the computer is off, and sync the data when the computer is back on either through Ethernet or manually updated directly off the SD Card.
 

AdvancedNewbie

Well-Known Member
Alpha 15 up

- No more Firmata
- New Arduino code with custom serial communication (Arduino can be ran independently now)
- Cleaned up Export to HTML
- Datalog to SQL Server Database
- Scrapped graphs in Labs
- New History tab allows you to select a date range to view datalog data in graphs.
- No more 'Adding Devices', instead the program looks for sensor names in serial communication message.

Download link in signature
 

lorenzop

Member
nice work. I've been working on a similar project for a few years. mine's more of a solution for all needs. I have a standardized protocol for communicating with the arduino over usb or either of the ethernet shields. I even made a minecraft plugin to control the outputs from redstone in-game. the app I made is written in visual basic 6, which has its own issues, but I recently started work on the next major version, which will be written in java, and will run native on windows or linux with a client/server model, and with plugins.

would you be interested in teaming up for any part of these projects? one thing I'd like to do is start a wiki website for information on computer automated gardening. schematics and howto's to building many device needed, and different options and alternatives for everything.
 

AdvancedNewbie

Well-Known Member
nice work. I've been working on a similar project for a few years. mine's more of a solution for all needs. I have a standardized protocol for communicating with the arduino over usb or either of the ethernet shields. I even made a minecraft plugin to control the outputs from redstone in-game. the app I made is written in visual basic 6, which has its own issues, but I recently started work on the next major version, which will be written in java, and will run native on windows or linux with a client/server model, and with plugins.

would you be interested in teaming up for any part of these projects? one thing I'd like to do is start a wiki website for information on computer automated gardening. schematics and howto's to building many device needed, and different options and alternatives for everything.
I'm definitely down for the wiki, as it might grow some public interest and it would be interesting to see some other ways of doing things.
 

Peragro

Member
I've been kicking around the idea of automation for a long while now. I like where this seems to be headed. My "dream" is to have a touchscreen interface on the outside of the cabinet, electronic locking with biometric "key", SMS or MMS (webcam) in case of break-in or other calamity, way-over-temp (150F?) "kill switch" (with smoke detection/fire suppression); and the arduino wouldn't "need" contact with a computer after initial setup except when offloading a whole grow of data. I only have one PC and I don't want it connected to the grow 24/7.

I figure that time synch might be possible via atomic clock (on whatever frequency they're broadcasting). There must be hardware/code for that but I'm falling asleep and don't want to confuse myself further by searching for it. I hope you understand...

I do have a question: How would one go about making the Arduino control fans in a manner similar to the Titan Controls Mercury series? If you haven't seen those, they have day/night settings and "idle" the fan (at 25%~60% of full speed) until the temperature gets above a certain point (then it goes full blast). My problem with them is that the settings are imprecise (dial-based) and I want near-laboratory-grade control of the environment (which would end up giving "real" data about how strains/phenotypes respond to certain conditions). One thing they TC Mercury does that's really cool is turn off the fan entirely if the temperature is too low (thereby using the waste heat from the lamp to heat the grow space).

Since my lamp cooling fan is separate from my exhaust fan, I'd need to be able to control both (which would mean buying two expensive controllers). I figure the Arduino can do it, I just can't think of how right now. Using PWM to control a DC fan would be easy as pie. Unfortunately, I use 120 VAC fans (and have no plans to buy new ones just because I can't figure out how to make them do what I'd like them to do). I guess I could use two circuits for each fan; one would have a rheostat and the other would be "wide open". The Arduino would switch back and forth between them via relays. And if I wanted day/night I'd need a photocell and two more circuits/rheostats. I'm not sure but it seems like this could be done with less than $90 in parts (above the cost of the Arduino itself). You guys seem more knowledgeable than I am; what do you think?
 

AdvancedNewbie

Well-Known Member
I do have a question: How would one go about making the Arduino control fans in a manner similar to the Titan Controls Mercury series? If you haven't seen those, they have day/night settings and "idle" the fan (at 25%~60% of full speed) until the temperature gets above a certain point (then it goes full blast). My problem with them is that the settings are imprecise (dial-based) and I want near-laboratory-grade control of the environment (which would end up giving "real" data about how strains/phenotypes respond to certain conditions). One thing they TC Mercury does that's really cool is turn off the fan entirely if the temperature is too low (thereby using the waste heat from the lamp to heat the grow space).

Since my lamp cooling fan is separate from my exhaust fan, I'd need to be able to control both (which would mean buying two expensive controllers). I figure the Arduino can do it, I just can't think of how right now. Using PWM to control a DC fan would be easy as pie. Unfortunately, I use 120 VAC fans (and have no plans to buy new ones just because I can't figure out how to make them do what I'd like them to do). I guess I could use two circuits for each fan; one would have a rheostat and the other would be "wide open". The Arduino would switch back and forth between them via relays. And if I wanted day/night I'd need a photocell and two more circuits/rheostats. I'm not sure but it seems like this could be done with less than $90 in parts (above the cost of the Arduino itself). You guys seem more knowledgeable than I am; what do you think?
http://www.aaroncake.net/circuits/dimmer.asp This little circuit would be a step in the right direction. You would just need to interface it with the PWM output from the arduino. This circuit is good up to 350W and most of those inline fans seem to be around 150W.
 

lorenzop

Member
http://www.aaroncake.net/circuits/dimmer.asp This little circuit would be a step in the right direction. You would just need to interface it with the PWM output from the arduino. This circuit is good up to 350W and most of those inline fans seem to be around 150W.
nope nope, let me clear this up for you both. the pwm feature of the arduino will only work with DC fans. it will not work with a triac on an AC line. the PWM of the arduino is relatively high frequency, while the AC line is much lower at 50-60hz. if you do manage to safely hook it up to that PWM signal, you'd end up with a fan that only runs on high no matter what the PWM is set at, except for off. it has to do with the way triacs work. now, more importantly is safely. incase you don't know, NEVER connect an arduino directly to a dimmer circuit like that one. besides it being to high of voltage and frying the arduino, if you touched any part in that circuit, you'd get a nasty shock or much worse.

that said, I'll tell you my ideas/plans for a fan speed controller. the way that dimmer circuit works, the knob (pot, trimmer, variable resistor, whatever you wanna call it) varies the resistance of the power that charges a capacitor. when that capacitor charges to a triggering point, the triac activates and turns on. this is technically PWM, but the method it does this with isn't compatible with the arduino, as the timings are very different. anyway, the faster the pot lets the capacitor charge, the sooner and longer the triac will be on, and in turn, the faster the fan spins. a relatively simple way to interface this with an arduino is to have a few relays, say high medium and low. medium and low could be 2 separate pots/knobs you could adjust to whatever speed you'd like, and high would just bypass the pots or bypass the entire dimmer circuit. hope some of that makes sense to you, but above all, be safe when working with electricity!
 

AdvancedNewbie

Well-Known Member
No, I wasn't thinking of PWMing directly to the dimmer circuit, but you can match up the PWM signal from your arduino using the signal from a zero cross detector and some how control a relay... or something along those lines. But you can just control the dimmer circuit with a digital potentiometer. The AD5171 is 64 position with "5 kΩ, 10 kΩ, 50 kΩ, 100 kΩ end-to-end resistance" and using it is as described here (it uses the I2C Wire Library). There is another that is 256 position for Resistor Values (kOhms): 10, 50, 100 and using that is as described here and it uses the SPI library.
 

Peragro

Member
<snip> a relatively simple way to interface this with an arduino is to have a few relays, say high medium and low. medium and low could be 2 separate pots/knobs you could adjust to whatever speed you'd like, and high would just bypass the pots or bypass the entire dimmer circuit. hope some of that makes sense to you, but above all, be safe when working with electricity!
That's exactly what I was thinking of doing a few posts ago. I'd want to link the relays to temperature (at the canopy or at the exhaust). I'm thinking of using at least four temperature sensors (Reservoir - temp/pH/TDS; Roots or Intake - temp/RH; Canopy - temp/RH; Exhaust - temp/RH) and I'm still working on a flow chart to trigger climate control stuff according to their readings (res cooler, "swamp cooler", electric space heater, fans). I'm still deep in the "design" stage, drawing diagrams and doing a little bit of math here and there... I really like the Arduino concept but I haven't written code since middle school (BASIC - and not the "visual" kind). Trying to "keep up" with this thread is stretching that atrophied brain meat a little - so thanks for that...

EDIT: Woah. Those digital potentiometers are neat stuff. A little much for me to wrap my head around at the moment (being bedtime and all) but definitely cool. It looks like my previous comment about finding inexpensive AC speed controls on eBay got cut off. I've seen the same ones at hydro stores for way more money. IIRC, they can get noisy but there's an internal trimpot that's supposed to take care of that. I'm not sure how well they'll work but I'm guessing they'll have at least one useful component that's worth the purchase price...
 

lorenzop

Member
No, I wasn't thinking of PWMing directly to the dimmer circuit, but you can match up the PWM signal from your arduino using the signal from a zero cross detector and some how control a relay... or something along those lines. But you can just control the dimmer circuit with a digital potentiometer. The AD5171 is 64 position with "5 k&#937;, 10 k&#937;, 50 k&#937;, 100 k&#937; end-to-end resistance" and using it is as described here (it uses the I2C Wire Library). There is another that is 256 position for Resistor Values (kOhms): 10, 50, 100 and using that is as described here and it uses the SPI library.
a circuit like that looks like it'd work great. much finer control than what's needed, but better than what I previously suggested. my only concern, is it shielded and safe to use with high voltage. I could assume it is, but I wouldn't dare plug it in without knowing for sure. any kind of high voltage feeding back into your computer equipment would be disastrous. I'm personally more comfortable using relays cuz I can physically see the control circuit is separated from high voltage, nothing hidden inside a chip and datasheet.

advancednewbie, do you happen to know java? I was up in the air for a long time on which high level language I'd learn next. mono/.net was an option for me, but I'm pretty happy with java so far. I'm only about a week into development on my app, but a few of the major parts are already working well. I wrote up a post on my website about what I have and what's planned, but I don't wanna post the link on your thread without your permission. development seems to go much faster than with anything I've done before. the hardest part is figuring out the libraries. btw, I'd still like to do that electronics wiki, but haven't had a clue where to start. you inspire me. I think I'll start on it right now.
 

Afistakis

Member
Is anyone still here? I am still working on controls for my RDWC system and such. Just wondering if anyone wants to see?
 

Afistakis

Member
I have built an 8 site RDWC a la undercurrentDWC or WoodsmanEh, equipped with a 1/4hp chiller, 950 gpm mag drive pump, 8.5k btu ac, 240w air pump, 3kw digital lighting, cool mist humidifier, and exhaust fan with charcoal filter. I am currently controlling the Turbo Clone with an arduino unit doing a simple 1min on 4min off timer. I am currently working out the data logging through ethernet shield for dual temp humidity sensors in the flower tent to control the humidifier based on vapor deficit numbers. I am also working on a web page to display all of this on 30 second updates. Basically a stripped down version of the control the world idea. The nute chiller, ac and humidifier are all digitally controlled stand alone and the lights and exhaust fan are on timers so that limits the necessity of integration.

I planted some sweet Blue Dream from clone 10 days ago and i can add some pics of those beauties also. The environment is stable so far but I really want to be able to data log the Ph and ppm along with any other piece of data I can get my hands on. I also have a light intensity meter I want to integrate.

I definitely could use some help on the arduino to data base and web programming but I am learning on the fly. So far so good. I feel like a kid at a radio shack again!
IMAG0490.jpgIMAG0488.jpgIMAG0496.jpgIMAG0493.jpgIMAG0499.jpg
 

sm00thslp

Member
MAN! Your doing what I had thought of a couple years ago! I got too excited and haven't read all posts yet, but I sure will. I've been waiting on the extra cash to start programming with arduino. I only have a simple automated-controlled grow box idea, but everything would tie into my VPN. Send me text messages if shit ain't working, or plants need water, etc etc etc.; but it would actually water itself.

I have a little experience with MySQL and PHP if I could at all be of help man.
 
Top