420 Magazine Background

Arduinos In The Grow Room: My Project

odam2k

Well-Known Member
Are you relying on only the sensor data for watering? When designing my system I'm trying to think of as many backup plans as possible. I worry about a faulty sensor and was thinking of have a configurable min/max time between watering, each plant would have have a configurable amount of water, that way veg and bloom can have separate reasonable values. If a min or max was used then of course I would like it to e-mail me.
I keep min and max as well for each moisture sensor, but I also keep a DRY and WET value for each sensor (wet=in water)
My min and max are of historical readings, so the lowest its been, and the highest, so I see that's not the same as you're talking about.
For my automatic watering, I have a flag which I have to manually set to allow the system to water based on the sensor, AND I also store an Auto Water level. Because min and max can be thrown off by a faulty sensor reading, I decided that I would "approve" auto watering once I determined the value based on recent levels when I hand watered. Make sense?

I was going to add a time limit, so it can't water more than once in a specific time, but I'm not sure I need that. I am taking precautions in case it does overwater... The floor under the pots is plastic lined with a lip, like a small pool :)

For each "switch" (which is the relay controlling the water pump) I can configure the ON time, so once I've determined how long it takes to pump my normal amount of water, I just plug that number in, and every plant gets exactly what it needs, and can be adjusted...

I'll be honest with you, it's a lot easier to just look at the plants and decide if they need watering :)
 

odam2k

Well-Known Member
Are you relying on only the sensor data for watering? When designing my system I'm trying to think of as many backup plans as possible. I worry about a faulty sensor and was thinking of have a configurable min/max time between watering, each plant would have have a configurable amount of water, that way veg and bloom can have separate reasonable values. If a min or max was used then of course I would like it to e-mail me.
Here's a link to my post in this thread where I talk about my worries of auto watering, about half way down...

 

bobinca

Active Member
Thanks again for sharing. I'm also a programmer with 20 years experience. I will try to document my journey in another thread, but that takes a good amount of effort to follow through on, which is why I really appreciate your effort keeping this thread going.

I know what you mean by software estimates. I find that in our head we estimate the normal/happy path for the software. Its all the details and errors conditions in the end that get us. I feel that when you think you are 90% done that you are in fact only half way there for a finished product.
 

odam2k

Well-Known Member
Woah, don't know what happened there, but all of a sudden my code for the ESP8266 on the Modules was causing watchdog timeout reboots. I had only made a few changes since my last backup, so I just restored last nights file, and will redo the changes. They were all related to watering plants, most of the work I did was on the phone app itself.
 

odam2k

Well-Known Member
Woah, don't know what happened there, but all of a sudden my code for the ESP8266 on the Modules was causing watchdog timeout reboots. I had only made a few changes since my last backup, so I just restored last nights file, and will redo the changes. They were all related to watering plants, most of the work I did was on the phone app itself.
Ah, stuffing a 585 character string into a 400 character buffer will do that :(
 

odam2k

Well-Known Member
Ah, stuffing a 585 character string into a 400 character buffer will do that :(
That was a single SQL query string :( Imagine how big the dataset was!

It was the select query used when the Module requests a list of it's sensors. There were about 30 fields in the query, so I split it into two queries, each loading half the sensor record. Because the query is only executed every 5 minutes or so, having it run twice is not going to have any impact on speed.
 

odam2k

Well-Known Member
Ah, stuffing a 585 character string into a 400 character buffer will do that :(
The weird part was, I discovered this when I added one more field to the query., 7 characters long. That means previous to my change, this had been stuffing approximately 578 bytes into a 400 char buffer. Yey everything was working just fine! Obviously the buffer was overwritten, there must have been empty memory beyond the buffer. Adding the 7 characters probably didn't kill it, it was probably other changes that ended up counting on some of that empty memory space.

Anyhow, I should use snprintf so I can keep from trying to stuff too much in.
 

odam2k

Well-Known Member
Strangeness... The Blynk app seems to stop receiving anything from the Blynk Server after a while...

I run the debug output on my serial screen, and it flashes by with its information, then eventually stops, and that's when I no longer receive any updates.

No messages, errors, anything, and the rest of my program continues to run...



Found the problem before I even saved this post...

Seems the arduino's were losing their connection to the Blynk Server.

Had to change:
Code:
        Blynk.run();
to:
Code:
    if (Blynk.connected()) {
        Blynk.run();
    }
    else
    {
        if (strlen(moduleCfg.blynkAuthCode) > 0)
        {
            Blynk.begin(moduleCfg.blynkAuthCode, wifiSSID, wifiPassword, blynkIPAddress, blynkPort);
        }
    }
That will check the connection and reconnect if it is lost...
 

odam2k

Well-Known Member
That would be better written as follows:

Code:
    if (strlen(moduleCfg.blynkAuthCode) > 0)
    {
        if (Blynk.connected())
            Blynk.run();
        else
            Blynk.begin(moduleCfg.blynkAuthCode, wifiSSID, wifiPassword, blynkIPAddress, blynkPort);
    }
 

Latitude17

Well-Known Member
If that's in your loop, it will come back to bite you later. The most solid way I've found is setup a timed routine to handle the Blynk connection state. In setup() do something like this:

Code:
   connectTimerId = blynkTimer.setInterval(30000L, checkBlynkConnection); // check Blynk connection every 30 seconds
   ...
   // non-blocking Blynk setup
   Blynk.config(auth, BLYNK_DEFAULT_DOMAIN, BLYNK_DEFAULT_PORT);
   Blynk.disconnect(); // skip connecting to the Blynk server until checkBlynkConnection timer fires
   ...
   // this allows setup() to continue/exit and the main loop() to begin without blocking
   blynkTimer.setTimeout(2000L, checkBlynkConnection); // in  2 seconds, do initial connection check
   ...
That will allow your main loop to stay clean, here's mine:

Code:
// Main processing loop.
void loop()
{
    blynkTimer.run();
    Blynk.run();
}
 

odam2k

Well-Known Member
Thanks @Latitude17 I'll have a closer look, and make those changes today...

I just spent the last 4 1/2 days sick in bed with the flu :( I was dizzy and nauseous the entire time, but luckily evaded most of the other symptoms, probably because I had the flu shot.

My plants are doing amazing! It's almost like they grow better when you just leave them alone to do their own thing rather than fuss over them. I have lots of "cuttings" to take from the veg tent, and the flower area is just bursting with buds now.

Gotta get used to sitting up after lying down all that time, it makes me feel pretty woozy, guess I gotta get some blood pumping uphill again...

Anyhow, I'll be back shortly, and slowly get back into things... going to go lie down again...
 

odam2k

Well-Known Member
If that's in your loop, it will come back to bite you later. The most solid way I've found is setup a timed routine to handle the Blynk connection state. In setup() do something like this:
I came across your post on the Blynk forum from a year and a half ago regarding this, it helped put it in context. I suppose I should have a good read of the documentation again... Thanks for the pointers!
 

odam2k

Well-Known Member
One good thing came from being sick... For the past 5 days I haven't smoked, and last week, I'd sit down and smoke 2 joints no problem... Now, 2 puffs and that's all I need! I'm gonna save a lot of smoke over the next little bit :)
 

odam2k

Well-Known Member
Alright, hopefully that's it for being sick! I just couldn't shake it, I can't believe how much I've slept!

It will take me a day or two to get back up to speed, but at least I can sit in front of the computer now without getting nauseous.

The good news is, the software seemed to run just fine without any attention, and having the gui from Blynk allowed me to just point to the "icon" and the wife would go water the right plant... almost AutoWatering :) It's amazing how quick things seem to grow when you aren't looking in on them every couple hours :)
 

Latitude17

Well-Known Member
It will take me a day or two to get back up to speed, but at least I can sit in front of the computer now without getting nauseous.
Glad you're on the mend! Overload with some Zinc and Vitamin C for a day or two.

Speaking of getting sick... for the first time since Hurricane Maria, I've had a Mega2560 just die. Investigation showed a mosfet burned out - like it shorted - but I have no clue how or why. It's just been sitting there running 24/7 for over 2 years without so much as a sneeze. That bastard.

Upside is, it forced me to port over to an ESP8266 and make some much needed but always procrastinated updates.
 

odam2k

Well-Known Member
Interesting how google works placing ads on your screens based on what you've been up to... Noticed a tiny little link on one of my news pages, and came across this.



You have to put in an email address and name etc to download the guide, but it does look quite detailed, and may be of interest to some of you... Even though it's not on my own radar, it won't hurt for me to give it a read too...
 

Latitude17

Well-Known Member
Interesting how google works placing ads on your screens based on what you've been up to
Get yourself a PiHole. :reading420magazine:

With your moisture sensors, have you managed to figure out a good way to avoid corrosion? Many of the capacitive sensors I have still aren't the best production quality. I'm wondering if some sort of happy medium could be found with a coated probe.
 

odam2k

Well-Known Member
Get yourself a PiHole. :reading420magazine:

With your moisture sensors, have you managed to figure out a good way to avoid corrosion? Many of the capacitive sensors I have still aren't the best production quality. I'm wondering if some sort of happy medium could be found with a coated probe.
First I need a Pi :)

Top of my ToDo list after being down and out for nearly 2 weeks I want to pull my probes and check them for corrosion, it's been a while. I'll post when I do...
 

odam2k

Well-Known Member
With your moisture sensors, have you managed to figure out a good way to avoid corrosion? Many of the capacitive sensors I have still aren't the best production quality. I'm wondering if some sort of happy medium could be found with a coated probe.
These new ones, using the stainless steel rods, have been in the soil for a month now, and when I pulled them out just now, they look just like new. No noticeable corrosion at all. The readings are stable, not like the deteriorating accuracy of the galvanised nails over time. I need to pick up some more of the screw terminal blocks I used to hold the rods, but I think I'll replace all my other moisture sensors with these... Including my dual level sensor, which suffers from using the galvanised nails. (The picture below is of a brand new sensor, but other than some dirt on it, it's just as shiny)

I found some nice stainless steel rods I have left over from my days of flying model helicopters. The Big ones had these nice stainless steel pushrods for the tail rotor, and they seem like something worth experimenting with. This is probably the simplest DIY version of a moisture probe that I've made so far. No soldering, just cut two pieces of the rod, and screw it together with the terminal block... I'm not worried about electrolysis from the power, as that will be quite limited. I think these will stand up to general corrosion just from being in the moist soil much better than the galvanized nails... If they can maintain their conductivity over time, then we have a winner...

Nice looking sensor :)
1731630
 
Top Bottom