420 Magazine Background

Arduinos in the grow room: My project

odam2k

Well-Known Member
I think I've solved this almost entirely using Sql :) This just shows how useful sql can be...

The view returns the module and pin required to trigger the relay for the light, and how many minutes until the light is to turn on, and how many minutes till it turns off, as well as what it should be now, on or off based on the schedule.

All the module has to do is issue this query every minute, and set the relay pin either high or low depending on whether the light is supposed to be on or off. It only needs to concern itself with "right now", not worry about how long until it changes although it is capable of reporting the time remaining... ...


Capture.JPG




Here's my table with the Lights configuration. A simple schedule, what time do the lights come on, and what time do they go off. Simple, same thing every day... This is why I wanted to treat lights separate from the other switches, because the schedule is quite simple...

Capture1.JPG



Here's the view which gives me those results...

Capture2.JPG
 

odam2k

Well-Known Member
The module checks every minute... If it's busy with something else, it checks as soon as possible afterward. There are no really long processes other than scanning the sensors and reporting to the MySql Server, so worse case, it might miss flipping the lights by a minute or so, acceptable in my case...

Capture.JPG
 

odam2k

Well-Known Member
Guess I better build a relay harness for the grow lights now... and I want to set up that one plant with a watering hose and let the system automatically water it when it's ready in a couple days. So I'll focus more on those things for now...

And then what?

I suppose some more changes on the web server. I'd like to get everything configurable via a web interface rather than having to edit the database directly. There's quite a bit of work to do in that respect, sort of an ongoing task...

Perhaps a break, work on my R/C Car or something completely different...
 

odam2k

Well-Known Member
Lights work with one minor issue...

If the lights are on, and the module reboots, then the relay is released, the lights go off, and once booting completes, the relay engages again and the lights come on again...

I have a feeling I'll want to use a Nano or ProMini, or maybe even an ATTINY to control this one relay so that the chances of needing to reboot it are much lower. I do reboot modules occasionally especially when I need to update the software on them, which right now during development, is often... Since I already have the code for creating I2C devices, no more time needs to be invested...

Anyhow, here's my Power Harness for the 2 400W HID lights...

Capture.JPG
 

drummer69

Active Member
I wish the HID ballast's came with aux terminal's for digital control as well . That would make things so much easier.
essentially you could remove the knob on one and replace with coupling to stepper motor. But Hey!! that's just me though LOL
 

odam2k

Well-Known Member
I wish the HID ballast's came with aux terminal's for digital control as well . That would make things so much easier.
essentially you could remove the knob on one and replace with coupling to stepper motor. But Hey!! that's just me though LOL
I never thought of that when I bought mine. Mine has an On/Off rocker switch plus a rotary knob for power level. It was a cheap one, so I don't suspect it has any type of remote capability, but I'll have a look when the lights come on in the morning.

I'm thinking maybe it's possible to use pull-up resistors on the relay signal line so that when the arduino reboots, and the logic level of the pin fluctuates (goes low until booting completes), a resistor tying to 5v should hold the level high, so when the Arduino reboots, the lights won't flicker off then on quickly, That can't be good for them. Also, now you have a problem, if the Arduino reboots at night, the pullup resistor is going to turn the lights on during a reboot, and while they won't light immediately, it still can't be good for them.

Been thinking about it, and it looks like putting a small mcu in charge of the relay is the way to go, and operate it via i2c so it's completely decoupled from the main Sensor Modules, at least in regards to reboots.

If a Pro/Mini controls the lights, then the Mega 2560 Sensor Modules, with their built in photoresistors can double check to make sure the lights are either on or off when they are supposed to be.
 

odam2k

Well-Known Member
Hey, that brings me to the next mini-project!

I need a way for the system to get ahold of me... Not passively when I go look at a web page, but actively. I have the need for a notification system...

Right now, the system is capable of Auto Watering plants, but is limited the number of pumps I have, so as we get going, the system needs to be able to notify me to water the others... Not too time critical, I suppose as long as I get the message within a couple hours...

When water in the reservoir for the watering pumps goes low, it needs to notify me, again, a couple hours, probably not too critical....

If there is a problem with the lights, a single isolated incident wouldn't be too critical, but any time the lights go on or off unnecessarily is probably hard on the bulbs, and will screw up your flowering plants if the lights keep coming on when they aren't supposed to...

Notification is required when there is a problem with the system, or Sensors malfunction and stop reporting valid data... Well, again, probably not too critical.

Other options include sending alerts to my phone or computer...

The problem is, the number one reason I have any issues is because of WiFi network problems. If the network is down, how would it contact my phone or computer? Oh I'm sure there's a way, but at what cost, in parts AND time...

So, again., I don't really have the "requirement" to support the cost of implementing something bulletproof...

Maybe just some "status" icons on the Plot Map page, the one I usually leave in my browser...

So there it is, my next Mini Project.... yep, it IS mini... :)
 

odam2k

Well-Known Member
I think I'll need to use one of my converted PC Power Supplies to supply power for my I2C devices.

These are the limits of the Arduino, and currently I'm powering my I2C devices from the Arduino 5v pin.
  • The absolute maximum for any single IO pin is 40 mA
  • The total current from all the IO pins together is 200 mA max.
  • The 5V output pin is good for ~400 mA on USB, ~900 mA when using an external power adapter. ...
  • The 3.3V output is capable of supplying 150 mA.
By the time I have a number of i2c devices online, including RTC/LCD/WaterPump Module/Dual Soil Moisture Sensors, etc, all with their own power requirements which I'm sure will add up quickly....

I'll put this on my ToDo list for now, it's dark in there... will need a harness, pretty simple, just share ground, and provide 5v instead of letting the Mega 2560 Module do it...
 

odam2k

Well-Known Member
Ok, plots and sensors... yep, back to that again, even though I said I wasn't going to bother.

I was looking at the Plot Map web page to decide how and where to put some kind of notification icons, and came up with an idea about Locations and Plots at least...

Right now, I have 2 locations, Veg and Flower - Each location has Plots, arranged in rows and columns, numbered sequentially with a PlotId. The Flower area has 3 rows, 6 columns, so 18 Plots. The rows are numbered 1, 2, and 3, and these may contain a plant, or be left empty. There is a special row, Row 0, these are Virtual Plots, they do not physically exist as a row, but for the saker of display on the web page, they can display sensor data, so may have a sensor associated with it.

You can see in this snap of the Plot Map page, the Virtual Plots are laid out in the first row. They do not have plants in them, just sensors...

The left side is Veg Tent, the right side is Flower Room except for the first row, which doesn't really matter.

Capture.JPG

So, my new idea...

Remove the Row 0 concept, and create a Location 0 instead.
Location 0, the Virtual Location
Location 0 could then have as many rows and columns as you need to display, for now, sensor data, but perhaps Notification Icons too, and who knows what else!

While I'm rejigging things for this, I'll see if I can come up with a way to display multiple sensors in a single plot.

Mmmm, more coffee....
 

drummer69

Active Member
:goodjob: yeah more coffee here too. So glad I remembered to grab coffee and creamer on the way home last night. I hate waking up a be like #$^@$# damn it got to get dressed and go to store now @#$%^@#$^ @#$@^ @##$^ It!
LOL
So maybe I will open up one of my spare ballasts today and see what magic if any I can perform on it to make it remote controlled LOL or Not!!
 

drummer69

Active Member
Well when I am complete I should be rocking 5 HID setups and a LED in all for now
I just thought that was a super cool controller though . 80 lights is a commercial set up at least right
Dang you for talking sense into me LMAO
 

drummer69

Active Member
I'm planning on leaving the LED for my clone and seedling area
3 HID's for my Veg area 3@400
2 for my flower tent 1@1000W and 1@ 600W

If I ever find complete set ups on sale in the near future I think I want to set up a separate 4x4 for testing things,strains,Frankenstein-ing LOL
So one more in there and possibly purchase a spare for emergency set up failure
 

drummer69

Active Member
I need to purchase 1 more 400 bulb and a 1000 and Ill be all lit up
I think I will order the panda black/white 50' roll online dirt cheap on monday after work
Sorry if some of these are off topic
 

odam2k

Well-Known Member
That wasn't so bad... I got rid of the concept of a Plot ID. A Plot is now a combination of a Location, a Row, and a Column.

Now, a Sensor is located in a Location/Row/Column, not a Plot.

An interesting side effect of this is I can reconfigure the garden easily,, changing the number of rows and columns in each location, all without affecting existing placements.

I'm sure there are still a few broken methods, so I still have some testing and fixing to do, but the bulk of the changes are done.
 

odam2k

Well-Known Member
Most of the final gremlins have been dealt with, I'm glad I made the change to Plots....

@DrewT just posted a thread I'm following asking for thoughts from anyone who has used a Smart Power Strip, one of those WiFi controlled Smart Outlets. Got me thinking, that will likely (never actually tried one) solve the problem with a relay, in that upon rebooting the Arduino, the relay will go to its default state no matter what your settings, only for a second, and I really don't want to be flickering power to my HID Lights if I can help it.


One of these Smart Outlets wouldn't care if the Arduino rebooted... I just need to find out how to control one from an Arduino. There seems to be a library available for the Raspberry Pi...

Another option, the relay can be held open or closed with a pullup or pulldown resistor.

Lets say you hook the Grow Lights up to the NO (Normally Open) contact on the relay.
Without plugging in the Arduino (or with it powered off) the lights would be off, because the relay is open.
When you turn on the Arduino, through the bootup process, the relay control will remain LOW, and the relay open, lights off.
Once the Arduino completes the bootup, it will set the state to whatever you tell it, and then the lights will be on or off.

So lets say the lights are ON, and you reboot the Arduino... The grow lights will turn off for a few seconds, and then back on... This is called a HOT START on your bulbs, and while your ballast should prevent hot starts, I'd rather not subject my lights to this. The Arduino shouldn't be rebooting, but it can happen, especially since I'm always installing new code on them during development, and I reboot them on purpose for various reasons.

So, why not put a pull up resistor on the control line, so that when the Arduino reboots, the weak 5v (through the resistor) is enough to keep the control line HIGH given an absence of signal from the Arduino? That would keep the lights on during a reboot... but what about if it reboots during the dark cycle? You don't want the lights coming on for a couple seconds during darkness...

I'm wondering, could you put a pullup to 5v that comes from a 110v->5vdc source, which is powered by the switched outlet?
So you have aa 5v wallwart plugged in along with your grow lights...
When the grow lights are on, and the Arduino reboots, the 5v from the walwart would hold the relay closed via its control line because the walwart has power from the outlet...
When the grow lights are off, and the Arduino reboots, the 5v line is dead (no power since the outlet is switched off) and therefore the relay remains open, and the lights off.

Will this even work?

More coffee....
 
Top Bottom