Arduinos In The Grow Room: My Project

@odam2k I thought I would be done with my project in 4 weeks. Now on week 10 I feel like I'm only 1/2 way there. I guess its good I planted before I finished my climate control project, now I just try to keep up with the plants before I kill them. Summer is coming and if the A/C isn't done before the first heat wave, they will die. If death wasn't on the line I feel like I would take long breaks from this project.
 
I've been at this since August, and honestly see no end in sight :) Yes, A/C's still need to be modded here too, summer without won't be very productive.
 
@odam2k just take a couple days off and disconnect from it, get baked, watch some youtube videos about bigfoot and preppers, laugh a little to yourself, and make sure to go way off the reservation on a subject that has nothing to do with this stuff. It helps.

:passitleft:
 
@Latitude17 That's what I've been doing, seems like weeks now...

Watched a ton of videos about truck crashes, I think there was one play list with 19 videos, all compilations of truck crashes.... Then we went to our doctors appointment yesterday, along the 401 through Toronto to the 400 and up. Every truck seemed to be just ready to blow a tire, or jump the guardrail... LOL... but we made it...

It's not so much that I can't get motivated, I do keep thinking of stuff to do, new and old, but when I sit down to do it, that's where I falter... Normally, I'm not afraid to tackle something open ended, without knowing how long it will take, or even if it's the right thing to be doing.... Now, it's like, I only want to tackle things that I can finish right away, low risk stuff... problem is, there aren't any tasks like that left...

This Auto Water feature should have been finished weeks ago, good thing I don't have any actual deadlines :) I have a great Boss! Me! LOL....

I just keep telling myself that it doesn't matter, spend just 5 minutes working on something, then leave it for a bit....
I hate stopping if for example, the program won't compile, or run, because there are still errors, it will drive me nuts till it's fixed... I think this is the root of my problem...

Anyhow, lemme put in another 5 minutes and take it one step at a time...
 
I've put in a couple 5 minute sessions, between trying real hard to watch youtube videos on bigfoot!

I almost ended up in a panic, turns out there's a flaw with my methodology regarding sensor calibration, and it means changing database tables and code, and my anxiety kicked in and I couldn't even begin to do a quick analysis of the changes required. Luckily, a couple puffs has calmed me down, but this is, or at least, was, an every day occurrence, I never gave it a second thought...

Anyhow, currently I "calibrate" each sensor so I know what values it gives for fully wet and for dry soil. As part of the key, I store the plantId as well, figuring the sensor might read differently in a different pot with different soil. That seemed reasonable...

Now, I tend to think that even moving the sensor in the same pot will be just like moving it to a new pot, so I'm going to remove the plantId from the table, since once a sensor is calibrated, it should be valid wherever it is, possibly with the system doing sanity checks on the values (compare against min/max for example)

This comes from my recent laziness, I replaced all my old sensors with the new ones, and didn't calibrate them :(
I'll do that today...

I've started my changes to the db and code, somewhat blindly, but with gusto! :)
 
I think this would be a perfect application for Blynk. I'll create a view in the db that lists the sensors, and their calibration data, display it in a Blynk table, then you select a sensor, and put the sensor in a glass of water, click the Calibrate Wet button, put the sensor in a glass with dry dirt, press Calibrate Dry, and blynk in each case sends the command to the sensor module to scan the sensor in Calibration Mode (don't save data to standard log, but just update either the wet or dry calibration number)

That process would make it VERY EASY to calibrate new (or recalibrate existing) sensors.

Just what I need, another entry on my ToDo list.... lol
 
@odam2k I'm not as far along as you with automatic watering, but I have been watching my moisture sensors and I agree that moving them changes their values. I've been thinking about instead of calibrating them that I would just figure out an algorithm that doesn't need calibration, something along the lines of if the value didn't change much in the last 24 hours that it must be dry. My sensors are in the first 2 inches of soil, so after that is dry, it seems to make sense for me to wait a while for the bottom of soil to finish drying out.
 
@odam2k I'm not as far along as you with automatic watering, but I have been watching my moisture sensors and I agree that moving them changes their values. I've been thinking about instead of calibrating them that I would just figure out an algorithm that doesn't need calibration, something along the lines of if the value didn't change much in the last 24 hours that it must be dry. My sensors are in the first 2 inches of soil, so after that is dry, it seems to make sense for me to wait a while for the bottom of soil to finish drying out.

That seems like a sensible approach. Just keep an eye on the plants too :)
As for the positioning of the sensor, that was the reasoning behind my dual level sensor, top and bottom of the pot...
I'm not sure I'll be going that route though...

I also store the min and max readings from each sensor/plant combination, and generally don't move the sensor once its in a pot, so that means the system can compare the current reading to the min and max, and determine when the reading is out of previous bounds.

I guess if this was easy, there would be lots of working examples out there :)
 
@odam2k I imagine we will each experiment and find something that works. What scares me is that when I find something that works that I might not stop, and will go on a never ending quest of improvements. Since I started this my other projects have really fallen behind :)
 
@bobinca A project like this could never be done, at least for me, since I have no idea what it's going to actually do in the end. I love projects like this, reminds me of my very early days writing shareware software. I wrote everything for my own use, and just made it available for others, and enough people liked it that I made a living for about 7 years. Not a great living, but think starving artist :) It allowed me to work from home while my daughter grew up, priceless in itself.
 
Anyhow, back to the here and now....

I've been feeling "back into it" since yesterday. I think writing here, I realized that what was holding me back was not knowing how long it will take to complete something, or knowing what steps needed to be taken. That's never bothered me before, I've never had a problem with absolutely tearing a piece of code apart, completely uncertain if I'd ever be able to fix it... but after thinking about it, I decided to just press on, afterall, that's what backups are for! :)

So, I started with a smallish project, creating a Blynk screen, and the arduino code to allow simple sensor calibration.

For each soil moisture sensor, I store the following:
Dry Reading (Raw)
Wet Reading (Raw)
AutoWater Reading (Raw)

Dry is the sensor raw reading with the probe inserted into completely dry soil
Wet is the sensor raw reading with the probe inserted into a glass of water
AutoWater is the sensor raw reading at which point the plant will be auto watered

The idea is I take my phone to the grow room, grab a sensor out of a pot, select that sensor from the list on my phone. Put the sensor into my "Dry" sample, click the "Calibrate Dry" button, it causes the proper module to scan the sensor, and save the value in the proper field rather than logging it as usual. This is so my logs don't reflect these unnatural readings... Then put the sensor in the glass of water, and hit the "Calibrate Wet" button, and the same happens... AutoWater,
I'm not sure yet if this is the best way to set this value, but when I see the plant needs watering, I can hit this button, and the current sensor reading will be used as the trigger for future automatic watering... It will in fact cause it to trigger immediately, so the plant will get watered as well...

Here's a screen shot of Blynk:

Capture.JPG


Only one sensor can be selected at a time, so selecting one unselects any others. Refresh just reloads the list.
The current selection is retained across refreshes as it is persisted in the database.
The info is quite un-user-friendly, but it works for me... I may clean it up later...
the first digit is a 0 or 1, false or true, whether this sensor will trigger auto watering
the second digit is the Sensor Raw Reading in dry dirt
the third digit is the Sensor Raw Reading in water
the fourth digit is the Sensor Raw Reading at which Auto Watering will occur (if enabled, see digit 1)
the final number on the right is the sensor id number...
 
@odam2k I also tried my hand at shareware in the 90s. I hated providing e-mail support so that side job did not last long. But in the end it did help me land my first full time programming job, so it was not a waste.

I like how you are using Blynk to creating an interface to enter configuration. Right now I'm playing around with Blynk to just show the status of everything, but I also want to try changing values, like target temperature.
 
@bobinca I read your post in your thread about using Blynk Bridge...

I have 3 "Sensor Modules", they are Wemos Mega 2560 with built in ESP8266.
If I need to communicate with a module, for example, from the Web Server which offers links to rescan specific sensors, I take advantage of the webserver on the ESP8266's. I just call a URL on the module, pass it the sensor id, and it will initiate a scan of that sensor. That means writing somewhat complicated code on both ends.

I had seen the "bridge" widget when I started using Blynk, but since I had already written the above code, I didn't bother with it, mostly because I'd rather that if I had to delete Blynk, my project will still work. I am becoming more comfortable with Blynk now, and trusting it more...

So, for the calibration, which is only available via blynk anyhow, I'm going to use the Bridge widget. It seems perfectly suited for this task.

When I select a Sensor, and click the "Calibrate Dry" button for example, the app tells the MaintenanceServer module to go to the database and load the record from tbl_sensor_calibration which has the "menuSelected" field set (only one allowed at a time) and find out which of the three "Sensor Modules" it is connected to, then using a Bridge to that module, tell it to scan in calibration mode...

This will be much simpler than doing this with http

Y'all can be so inspiring! Thanks!
 
@odam2k I like how you are using Blynk to creating an interface to enter configuration. Right now I'm playing around with Blynk to just show the status of everything, but I also want to try changing values, like target temperature.

I hadn't looked at them before, but there are text and number input widgets, etc, as well. I'm looking forward to building a "form" type page for configuration....
 
So, for the calibration, which is only available via blynk anyhow, I'm going to use the Bridge widget. It seems perfectly suited for this task.

When I select a Sensor, and click the "Calibrate Dry" button for example, the app tells the MaintenanceServer module to go to the database and load the record from tbl_sensor_calibration which has the "menuSelected" field set (only one allowed at a time) and find out which of the three "Sensor Modules" it is connected to, then using a Bridge to that module, tell it to scan in calibration mode...

Awesome, it works!

Tomorrow, I'll calibrate all the sensors, and it's going to be so easy :)

The only issue is there is no feedback to the app that the value has been updated correctly in the database, you have to hit the refresh button to verify the change. I'm sure it can be done, I just need to think about it some more...

I'll probably add one more button to the screen, and that will be to RESET all the calibration data to defaults (-1) for a sensor, but right now, it's time for a puff, then off to bed...
 
Ok, lights are on in the grow room, so armed with my phone, a cup of water, and a cup of dry dirt, I'm off to calibrate all my soil moisture sensors that are currently in use.
 
Ok, lights are on in the grow room, so armed with my phone, a cup of water, and a cup of dry dirt, I'm off to calibrate all my soil moisture sensors that are currently in use.

So I'm sitting there hitting the calibrate button, over and over, refreshing the screen, and nothing! It's not working?

Doh! Gotta install the new software on the "production" modules...

Let's give this another go!
 
Spectacular! All the new stainless steel soil moisture sensors have now been calibrated.

I realize I really do need feedback, I was able to cheat and look at the serial output on the local laptop, so I could see my debug text... It did not scan 100% of the time...

One design flaw is that requests are ignored if the module is busy (scanning all sensors, for example) I need some feedback, even if it's just success/fail. There were a few other times it seemed to ignore my request, but it was likely in the middle of something else at the time... This really needs to happen in real time, since you have to move the sensor around to the two cups, and back to the plant...

An interesting possibility now would be to do this, say, once a month, and compare the readings to see IF there are in fact any changes based on corrosion that I just can't see on the sensors themselves. Perhaps if an existing value exists, it compares it, and keeps another table with "changes" for each sensor (mostly for reporting purposes)
 
So moving the sensor in the same soil certainly does make a difference in the reading...

Pretty common across ALL the sensors...

Capture.JPG


I only saw one where it decreased...

Not sure what to make of this yet, is it going to be a problem? It could, if you set the Auto Water level to say 200, but just moving the sensor could make it jump from 200 to 400... I guess we'll see...

As I get the system doing the watering all on it's own, I WILL also be keeping my eye on it, so if this does become a problem, I'll catch it before it causes any real problems.
 
Ok, so calibration is working well, the system checks to see if a plant needs watering, if so, adds a record to tbl_plant_watering which is what will actually trigger the watering...

When it waters the plant, it will put a timestamp on the record signifying when it was watered, and sets a flag showing it has been watered.

There is still some coding left...

The maintenance server (ESP8266) will, as part of it's recurring maintenance loop, check this table, if a record exists, and it has been flagged as watered, then it will do the following:

  1. check the timestamp of the sensors most recent reading, and if the latest reading was NOT taken after the watering then skip the following steps, and check again next time
  2. If the sensor has been read since the plant was watered, check the latest sensor reading, as well as the reading that triggered the watering, and if they differ by a specified amount, plant was watered correctly.
  3. if the plant was watered correctly, then move the record from tbl_plant_watering to tbl_log_plant_watering and update the dateConfirmed field
  4. if the plant was watered, but NOT watered correctly, then send an mail/notification, and leave record unchanged, it will check again next time
 
Back
Top Bottom