Arduinos In The Grow Room: My Project

Had to change the details of when it writes to the cache files. I was ending up with them being overwritten by empty data :(

In any case, it seems to be working reliably now.

Here's a log of the Switch Module booting up when I've changed the password on the MySql user so it has no access.

You can see it states that both the moduleConfig and the lightConfig were loaded from cache, and not from MySql

You can also see the delay while it waits out the Hot Start delay, which I've set at 5 minutes.

I'll set this up in my clone booth, I've got a couple seeds germinating, and will be doing more clones. I'll set the light to 18/6, it will be a good test for this. I'll monitor the light with a photoresistor to ensure it's actually working when I'm not looking :)

Code:
Opening port
Port open
[M0] 2019/5/3 09:56:16 > Grow by Wire
[M0] 2019/5/3 09:56:16 > Switch Module
[M0] 2019/5/3 09:56:16 > Free Memory: 4.48KB
[M0] 2019/5/3 09:56:16 > Mega 2560 Code Compiled on May  3 2019 at 09:theband:55
[M0] 2019/5/3 09:56:17 > ESP8266 Code Compiled on May  3 2019 at 09:cough:51
[M0] 2019/5/3 09:56:18 >   MAC Address: CC:scratchinghead:E3:0C:7C:82
[M0] 2019/5/3 09:56:18 >   IP Address : 192.168.1.23
[M0] 2019/5/3 09:56:18 >   RSSI       : -65dBm (70%)
[M3] 2019/5/3 09:56:19 > moduleCfg loaded from cache
[M3] 2019/5/3 09:56:19 > Module has Switches: 0, and Lights: 1
[M3] 2019/5/3 09:56:19 > Module setup() Complete
[M3] 2019/5/3 09:56:26 > LightCfg loaded from cache
[M3] 2019/5/3 09:56:26 > Light #1 [HPS 400W Flower] is ON
[M3] 2019/5/3 09:56:26 > Delay for 244 more seconds to prevent Hot Start
[M3] 2019/5/3 09:rasta:17 > LightCfg loaded from cache
[M3] 2019/5/3 09:rasta:17 > Light #1 [HPS 400W Flower] is ON
[M3] 2019/5/3 09:rasta:17 > Delay for 193 more seconds to prevent Hot Start
[M3] 2019/5/3 09:rocker:22 > LightCfg loaded from cache
[M3] 2019/5/3 09:rocker:22 > Light #1 [HPS 400W Flower] is ON
[M3] 2019/5/3 09:rocker:22 > Delay for 128 more seconds to prevent Hot Start
[M3] 2019/5/3 09:59:22 > LightCfg loaded from cache
[M3] 2019/5/3 09:59:22 > Light #1 [HPS 400W Flower] is ON
[M3] 2019/5/3 09:59:22 > Delay for 67 more seconds to prevent Hot Start
[M3] 2019/5/3 10:00:17 > LightCfg loaded from cache
[M3] 2019/5/3 10:00:17 > Light #1 [HPS 400W Flower] is ON
[M3] 2019/5/3 10:00:17 > Delay for 13 more seconds to prevent Hot Start
[M3] 2019/5/3 10:01:16 > moduleCfg loaded from cache
[M3] 2019/5/3 10:01:22 > LightCfg loaded from cache
[M3] 2019/5/3 10:01:22 > Light #1 [HPS 400W Flower] is ON


That sort of wraps up another project...

I think I know what I'm gonna work on next, stay tuned to find out...
 
Before I can wrap up that project, I still have some work to do. I have the Light controller working very well, but this is the Switch Module, and there is a whole piece that just controls switches based on sensor input.

Lights are controlled by a timer, and switches by sensors. Eventually, I plan on creating a virtual sensor which is actually a timer :)

The code is there, and was working for the Switches, which can be relays, transistors, motor controllers, almost anything, but because all this code was shared on the Sensor Module, it had access to local sensors. When I split the code apart, I removed all the sensor code from the Switch Module code because this module has no sensors.

So now I have to modify the Switch code to be able to get sensor data from a specific sensor on a specific Sensor Module in real time. I could just read it from the database, but that data can be up to 30 minutes old, not good enough for temperature or humidity control...

I think I'll use Blynk Bridge to query the correct module, passing it the correct sensorId, and the sensor module will scan that sensor, and pass back all possible readings (Calc and Raw).
 
Check out some youtube videos of giant legal grows, they use PLC's and SCADA systems to automate and keep an eye on everything....fans, water, heat, temp, etc Its basically a heavy duty version of what you made for thousands of plants at a time.
 
Check out some youtube videos of giant legal grows, they use PLC's and SCADA systems to automate and keep an eye on everything....fans, water, heat, temp, etc Its basically a heavy duty version of what you made for thousands of plants at a time.


Well, my little project started so simply, and has grown so big now.

The problem with a project like this, there's no way to do a fresh install, or at least, it's not documented, as things change so rapidly. I supposed I could figure it out, but it will be a pain in the ass. The whole thing is developed in LIVE mode, with changes to code and database schema happening all the time.

I supposed if I ever consider it finished, I'll figure out how to install it :)
 
Got a bit of a problem...

Remotely triggering a sensor read, and waiting for the response is not a good idea.
If the Sensor Module is busy (scanning sensors, etc) then it will not respond to the request, and even if it does, there are so many layers...

The Switch Mega 2560 sends a request to the Switch ESP8266 via xml, the ESP sends a request to the ESP of the Sensor Module, which then creates an XML request and sends it to the Mega, which reads the sensor, then sends the response back to the ESP, which sends the response back to the Switch ESP via Blynk, then the Switch ESP sends the response back to the Switch Mega...

Code:
Sending Request

----> XML Via Serial Ports
==>  Blynk Bridge via WiFi Network)

   Switch Module           Sensor Module
 _______________          __________________
|               |        |                  |
____       ____          ____          ____
|Mega| --> |ESP |  ===>  |ESP |  -->   |Mega|
------     ------        ------        ------



Code:
Receiving Response

<---- XML Via Serial Ports
<==  Blynk Bridge via WiFi Network)

   Switch Module           Sensor Module
 _______________          __________________
|               |        |                  |
 ____       ____          ____          ____
|Mega| <-- |ESP |  <===  |ESP |  <--   |Mega|
------     ------        ------        ------
 
I could go ahead with using Blynk Bridge to get the sensor readings, but it seems too prone to not getting a response in a timely manner.

One alternative would be to increase the frequency for the sensor to be scanned. For example, if I want to control a fan, based on a temp sensor, say #9, I would configure sensor 9 to scan every minute. This code already exists, and in fact, the temperature sensors are already scanning every minute. I just turn on a flag so they are persisted to the database, and then the Switch Module can get the info from there.

I created a view so when the Switch Module fetches the Switch Configuration (which switches we need to check) it also joins the sensor log table to include the latest calculated readings from the sensor defined to control this switch, so no queries to another module, or even additional queries to the database. Everything it needs comes in one query...
 
Opening port
Port open
[M0] 2019/5/4 03:sleep:25 > Grow by Wire
[M0] 2019/5/4 03:sleep:25 > Switch Module
[M0] 2019/5/4 03:sleep:25 > Free Memory: 4.10KB
[M0] 2019/5/4 03:sleep:25 > Mega 2560 Code Compiled on May 4 2019 at 03:skeptical:35
[M0] 2019/5/4 03:sleep:26 > ESP8266 Code Compiled on May 4 2019 at 02:nomo:28
[M0] 2019/5/4 03:sleep:27 > MAC Address: CC:scratchinghead:E3:0C:7C:82
[M0] 2019/5/4 03:sleep:27 > IP Address : 192.168.1.23
[M0] 2019/5/4 03:sleep:27 > RSSI : -70dBm (60%)
[M3] 2019/5/4 03:sleep:29 > Module has Switches: 1, and Lights: 1
[M3] 2019/5/4 03:sleep:31 > Module setup() Complete
[M3] 2019/5/4 03:sleep:32 > Light #1 [LED Clone Booth] is OFF
[M3] 2019/5/4 03:sleep:34 > Turning Window Box Fan On (28.0C)

And there we have it...

I'll move this into the grow room tomorrow and hook it up to the Clone chamber light, and the window fan used to cool the entire room.

but for now, I think I'll go get some sleep...
 
In a moment which must have been like that when peanut butter and chocolate first went together, I had an idea...

Combine two great things...

What are those two great things?

The DIY3 Stainless Steel soil moisture sensor, and the Dual soil moisture sensor, to make a Dual Stainless Steel Soil Moisture Sensor....

Here it is compared to the old dual sensor. Right now it's naked, but you can see how it is put together... I just cut the wires on the old one and screw them into the new one, and nothing else needs to change, it's still an i2c sensor thanks to the arduino pro/mini

1789622
 
Done... now to go stick it in some soil.... I have one large pot right now, so this will be perfect...

1789710
 
Final wrap up of the Switch Module...

I kinda like mounting on a piece of wood, it's a lot cheaper than a project box, and it keeps everything organized and in one neat package.

1790158




A final touch, in the Blynk app, I can now see the status of the lights and switches...


1790163
 
It's time to unveil the next project...

With summer just around the corner, and my cloning success returning (at least using jiffy pellets) it's time to get the DWC Cloner set up. The problem I had last summer was the water getting too hot, and then the cuttings would rot before they could root...

So, this year, I'm gonna have a go at making a water chiller to keep the water temp within a few degrees of 21C (70F) IF I can... It can get HOT in here and last year the water temp was up around 30C

So, I ordered an Aluminum Water Cooling Block, just an aluminum block with channels cut in it, and the water flows in one nipple, through the channels, and out the other nipple.

The aluminum block is cooled using 4 TEC1-12706 (6A) Peltier Plates, that's over 200 Watts (almost 25 Amps) of cooling power... The peltier plates get very cold on one side, and very hot on the other, so I have two HUGE heat sinks, and 2 muffin fans to cool the hot sides.

1790223



The fans, and the Peltier Plates run on 12v, but with a current draw of up to 24A, it's gonna need a lot of power...
This PSU out of an old Home Theater Server should do the trick, with power to spare!


1790212




To get the PSU to come on, you have to short the green wire to ground, this is usually used to detect that it is plugged into a motherboard.

The 12v wires are the yellow ones...

1790257




Time to make up a wiring harness for all those wires on the chiller, it just needs one power connector.
 
Actually, I'll power the Peltier Plates separately from the Fans. That way I can put a relay on the Peltier Plates power to turn them on and off, and the fans can stay on all the time to cool the peltiers which will still be very hot once the power is turned off to them. I may add a relay to the fan power as well, then I can just let it run for say 5 minutes after powering down the peltiers, we'll see... I will also have a pump to circulate the water through the cooling block, this could be on all the time, and in fact, might be a good idea to keep the water flowing, one less thing to go wrong...
 
I've been thinking about how I measured the air flow out the duct vent from the tent when I was checking to make sure the Air Intake Light Baffle wasn't too restrictive. I used an anemometer, a small hand held device that has a little fan that the wind blows and spins, and that tells it how fast the wind is blowing...

1790331



Too bad I can't tap into it and read it from the arduino...

Then I thought, all I need is a D/C Fan, like a Computer muffin fan...

1790332


The fan is driven by a direct current motor...
A D/C motor is also a generator. If you spin the blades, you can measure voltage on the wires.

So, why can't I mount a fan at the mouth of the duct, and measure the voltage it generates, and use that to at least know when the fan is running, and approximately what speed?

Another DIY Sensor idea :) the GBW Duct Airflow Sensor.. good candidate for being an i2c device...

Just saving this here for a rainy day...
 
The sound of the crickets is killing me, I think it's time to break out the ear buds and put some tunes on....
 
So, stay tuned, there's lots more to come, and if you are reading this, why not say Hi, or at least "like" this post so I know you're there...

Wow, huge response to that request...

Ok, yes, that was sarcasm...

Perhaps I'll switch to posting random short stories from my childhood, nobody will even notice... well, 'cept you, the person reading this, right now... but, I won't know, so....
 
First one.... This one is related to cannabis...

When I was in high school, in about grade 10 science class, the teacher was not in the class room yet, and there was a lantern battery there for whatever reason, and some wire... I took a small chunk of hash, wrapped the bare wire around it a bunch of times, and then hooked the wire up to the battery terminals. Seconds later, the wire got red hot, and we were passing it around doing "battery tokes" Teacher arrived just as the wire melted through and we were done...
 
Here's a family picture...

Top Left, Sensor Module #1
Top Right, Sensor Module #2
Bottom Left, Switch Module
Bottom Right, AutoWater Module

1790625


The reservoir for the Autowatering system is bottom left...
All 4 modules are plugged into USB on the laptop so I can monitor the Serial output if I need to while debugging. I can also update the Mega 2560 software using a batch file that uploads the compiled code from across the network, and the software on the ESP8266 is all updated using OTA.

I know, it's still a mess of wires, but it's still in development, and as a whole system, will be connected using custom wiring harnesses, eventually with custom PCB's.
 
So the Switch module is now LIVE, it is controlling the LED light in the clone booth, and once it passes this test, I will be setting it to control the 400W MH Veg light.

The Switch module is also now controlling the Box Fan in the window used to pull cool air into the room (during winter when A/C not available). This comes on and off based on sensor readings which are configurable.

It's exciting to see some of this hardware move into the grow room, it's been in development for so long...
 
Back
Top Bottom