Arduinos In The Grow Room: My Project

Welcome... I'm only posting headlines here these days with links to my blog, hopefully you'll be able to find things there that are simply just buried in messages here. The site is still in it's infancy, but, as with my automation project, logging is the first, and most important task :)

I certainly understand how frustrating this can be, I'm not immune to that, but when I get frustrated, I simply switch to another task. Figuring out how to get some of these cheap pieces of hardware working can be a real challenge with so many versions, and so many people with different ways of going about it... I think the most frustrating was the ESP8266, especially the one built into the Mega board. I had so many problems, it was rebooting all the time, nothing worked... It was so unreliable, I was going to give up on it and order some Ethernet shields. Of course, I eventually got it working, and now, I never have an issue with them, and they are extremely reliable...

Unfortunately, with my bad memory, sometimes going back to something can be like starting over, so keeping it all written down is an excellent way to help me ease my way back in. That's one reason I switched to the blog, it allows me to organize things. I can still keep the flow of thoughts in the blog section, but also capture important information in pages that can be linked to the main screen menus. Still tons of work to be done there, but that's just one of the simple tasks I can switch to when something else has me frustrated.

I just love working away through the night, with my ear buds in, listening to Metallica, full blast. Their style of "speed metal" actually seems to help me type faster, and certainly to a rhythm :) I don't like their "punk" sounding stuff, but I've picked about 15 of their songs for my playlist, which I tend to play over and over, and over, and over.... lol

My wife has let me take over the dining room for my work space, and I have a small allowance to spend each month on stuff I need. Being on disability, we are on a very fixed budget... but this is important for my mental well being :)

I used to be into R/C big time, had planes, helicopters, multi copters, boats, sailboats, cars, trucks, etc... Sold 90% of it all when I could no longer do it due to health reasons. So now, one of my other projects is to try to create an autonomous vehicle I have a 1:6 scale VW Beetle I'm working with. Big, huge frustrations trying to get a digital compass to work, but finally, it seems to be working properly :)

So, every day I learn something new, and forget something old... a constant exchange of information, and without keeping it all online, I'd simply forget, and that would make things so frustrating, I'd not be able to continue... I still have to go back and look at my schematic every time I need to make another voltage divider :)

Glad to have you along, if you have any questions, I do get notifications for this thread...
 
Awesome, thanks for the welcome! Do you have your code on Git that I can peruse and try to get a pulse on where you're at? Your explanation of the ESP hit the nail right on the head. I had so many problems trying to transition my code to ESP and being such a novice not able to find easy answers set my blood to almost a boil. HERE's my sketch BTW. 2 DHT22's, 3 submersible pumps (relays) and 8 peristaltic pumps (12v TIP120 circuits) and the front end was Blynk. I tried the SQL, but couldn't wrap my brain around setting up the server.

It's cool you're into RC. I just started with that myself and built a RC lawn mower, well mostly built. I'm having an alignment issue with the drive motors and the driven 10.5" wheels. #25 roller chain sucks! The unit uses a Sabertooth 2x32 motor driver. There's a bunch of DIY RC mowers on YouTube to get a better idea. It's a cool functional project that is mostly complete. I just gotta do some more cutting, grinding, welding and hammering and it will be complete.
 
Something rings a bell here, I saw a post somewhere (didn't actually read it) someone was having problems doing OTA updates on the ESP8266 and they needed to do them because it was going to be installed on a mower. What a coincidence, was it you? I don't remember where I saw it...

I haven't shared my code yet because at the moment, I couldn't even tell you how to install it, or even have a good written overview, or explanation of how it fits together. I am working on it though... I'm not against sharing it, but I'm not ready to commit to the time required to properly support it and respond to questions... (just being honest)

I'll send you a private message...

Once you get the R/C part going and you tire of having to sit there and steer it, you should try making it autonomous, let it go cut the grass on it's own... lol

My other blog has the r/c stuff on it, it's basically for anything else arduino related that I'm playing with...
Arduino Adventures


I'll check out your code tonight hopefully....
 
No worries about code sharing. I just wanted to get an idea of what you had going on, but I'll figure it out in time, at my leisure. My RC mower is literally just the regular RC transmitter/receiver combo and the servo signals are interpreted by the motor driver as it has an onboard IC to handle that. I saw a video where a guy incorporated a gyro sensor to make his mower drive perfectly straight lines over a contoured yard, I hope to figure that one out. For the record, I have about a half dozen ESPs and none of them are being used. They were cheap enough to buy multiple, but shortly after getting them I went into melt down, lol.

I'll check out your arduino adventures thread, plus also peruse your domain to get a better idea of what you have in your grow setup. Who knows, maybe something will inspire me to dust the stuff off and connect things etc etc etc. I have everything I need, and a 3D printer to keep it neatly together, but no desire at all to play with them toys lately.
 
Just checked, so far I've written just shy of 21,000 lines of code for the arduinos, plus a couple thousand lines of windows code...

:nomo: WOW! :reading420magazine:
 
I have a good friend who runs a 3d printing business, but he moved a couple hours away when he started it :(

I'm sure eventually I'll have one, kinda like a cell phone, eventually everyone will have em...
 
For the record, I have about a half dozen ESPs and none of them are being used. They were cheap enough to buy multiple, but shortly after getting them I went into melt down, lol.


I have 2 (strange, I thought I had more) of the standalone ESP-01 modules plus all the Mega's have one built in. The two standalones are a Web Server and my Maintenance Module. I just ordered 4 more a week ago, $1.46 Cdn with free shipping... Wow eh? All that power for less than a cup of coffee....

I make my own "cradle" for them with a reset button and a mode button, plus the resistors, and I leave them plugged into a USB hub for power plus I can monitor the serial output any time.
 
How are you activating the pullup w/o declaring INPUT_PULLUP? (I forget proper syntax)
 
I am, I do a

pinMode(54+AnalogPinNumber,INPUT_PULLUP);

just before testing the sensor. When I'm finished testing, I do a

digitalWrite(54+AnalogPinNumber,LOW);

which was the secret to disabling the pullup,
and then finally setting

pinMode(54+AnalogPinNumber,INPUT);

Then I go on to take a reading of the valid sensor, or skipping a missing one.

The 54+AnalogPinNumber is because AnalogPinNumber is 0-15, and if you look at the value of the constants A0 through A15, you will see they range from A0=54 to A15=59

I store AnalogPinNumber in an INT, and store 0 through 15, so to use it as a digital pin (using pinMode and digitalWrite I must adress it with the proper pin #. A0 = 54, where as 0 = 0, not 54. Make sense?
 
Make sense?

No, but I was just questioning what I saw on your blog entry. I didn't see the INPUT_PULLUP. My very limited code skills has been on the back burner for about a year, and your code seems to be fairly complex, more so than any of mine was. Also, is this for a soil moisture sensor? I would think the web would have plenty of documented projects with functioning circuits and code. That's the approach I took when building my project, to find a similar project and get to hacking out what I could and do my best bringing it all together.
 
I took a different approach than most. Grab a coffee and a joint, this is fairly long :)

:nomo: :lot-o-toke:

Everything is configurable, nothing is hard-coded into the program.

As the user, I can add "sensor types" in the database, such as "DIY3-SOIL" which is my current version of the soil moisture sensor, or "PHOTO" which is just a photo-resistor. If I make a new soil moisture sensor, I add it to the sensor table, enter the sensor type, and it assigns a sensor id to it, and I can then assign it to a module (where is it plugged in) and a location, or plot...

The one part I haven't quite figured out yet is how to make the calculations configurable... Right now, I still have to hard-code the calculations for each sensor type. For example, a soil moisture sensor is easy, just map it's raw value into a percentage (actually, I've made it a lot more complicated, but that's basically it) where a thermister has fairly complex math that must be done. I need a way to script the math... That's one of the RARE things I've hardcoded. Unfortunately, that means as a user, to add a new type of sensor that needs a different calculation type, the code has to be modified to accomodate it.

Here are some sensor types:

1867020



and then some sensors:

1867021


You can see the sensorTypeId ties this sensor back to the sensor type. This is all user configurable in the database.

Now you assign a sensor to a Sensor Module:

1867022


PortNumber is basically the Pin number, again, we configure a port number to be specific pins:

1867023


A Module has 16 analog "ports" and 53 digital "ports"

In addition to a pin assigned to read the sensor, you may also define a power pin, a digital pin that we can switch HIGH and LOW to provide 5v to the sensor. (must be under 40ma MAX) I'm working on a proof of concept to use this to control a transistor, which will switch an external 5v power source, allowing for a more stable voltage, and higher current.

So for each port number you define, you configure which pin reads the sensor, it can be analog, digital;, or even an i2c device, plus you specify the pin to provide power, and whether to toggle that power on only when the sensor is being read. This prevents excessive electrolysis corroding the sensor in the case of soil moisture sensors.

Now that the module knows it has a sensor to read, it has all the info it needs to read it. Now we just need to know where that sensor is. I have defined locations as configurable:

1867024


Each location has a grid defined, how many rows wide (columns) and how many rows deep (rows). Each of those "plots" can hold one plant. This is how I know where to find a particular plant. Just like assigning a sensor to a location, you also assign a sensor to a plant, and a plant to a location...

1867026


Virtual location is something I created because on my web page, I have a banner type thing across the top and can pop sensor info in there, like so:

1867025


The orange is telling me the sensor has not been read for longer than a specified time. In this case, these are on my development module, and it is not plugged in and running at the moment...

So now that we have a sensor mapped to a module to read it, and a to a plant so we can make use of the reading, and we have assigned the plant to a location....

The web page can display this for each location:

1867027


There's a lot of information there, plus you can click on one of the "plots" to see this:

1867028


This is the history of readings, you can clearly see when it was watered...


Plants are added as you go:

1867030


So, if you made it this far, you see, the code has to be very generic so that it can handle all these variable configurations, and that was the most challenging part of this project. You are only looking at a very small part of the system here... there are aver 50 database tables.

While I'm now more open to the idea of actually releasing all the code, when I started, this was just for me, never planned to release anything, so hard coding would have been easiest, but as a software engineer with 40 years experience, I knew it had to be configurable, even for my own use.

So, to answer your question about why didn't I just grab someone else's code and make it work for me, the answer is that I wanted to be innovative. I started my programming career with a stint as a fairly successful shareware author, so know the appeal of innovation. I love the challenge of doing things my own way... There was some discussion early on here in another thread I think, about whether to roll your own or not, and while using someone elses code can save you time initially, in the long run, you still need to be as familiar with it as if you wrote it, so that you can fix bugs, or make changes to it. If you simply rely on others, they may not update their code going forward, and then you need to find something else, or write your own anyhow...

Unfortunately, this complexity has left me with a software system that I don't even know how to install from scratch, as it was entirely built in place.... This is something I need to figure out, and document, before I can even think of releasing the code as Open Source.
 
I didn't see the INPUT_PULLUP.




The code now looks like:
1867047




In the blog post, look for:

I removed the pinMode settings in setup() and just before the above code to test the sensor, I added the following line:

pinMode(54 + sensorCfg[sensorIndex].analogPin, INPUT_PULLUP);
 
Latitude helped me a lot with my code

Yeah, he helped me with the Blynk stuff, so I recognize some of the style in your code. In fact, he is the reason I finally started playing with I2C, and Blynk, and probably some other stuff I've forgotten.

So did you ever get it doing what you wanted? Was it one particular thing that caused you to quit, or just endless roadblocks kinda thing?

Sure you don't want to try again? :)
 
Yeah, he helped me with the Blynk stuff, so I recognize some of the style in your code. In fact, he is the reason I finally started playing with I2C, and Blynk, and probably some other stuff I've forgotten.

So did you ever get it doing what you wanted? Was it one particular thing that caused you to quit, or just endless roadblocks kinda thing?

Sure you don't want to try again? :)

As is now, I just want to focus all of my time into my plan to rebuild my grow, and dismantling the old, but in a seamless way so the grow continues. I am also switching from hydro to soil after 6 years in hydro, so that's a little unnerving. So yeah, definitely not starting in with the electronics just yet. I'm content to peak in here and enjoy your setup from the sidelines.

About your thermistor situation, HERE is the list of thermistors that have already been coded for in the Marlin Firmware that is used on about 80% of the world's 3D printers. There is a Generic10kohm, but there are also many others in case you own a certain brand. I know you don't like jacking code, but I can't imagine that PID code is at all straight forward. Obviously, this is just a list and to navigate to the correct .h file(s) you would need to locate parental directories, then find your way from there, but I didn't know you were also an experienced coder of many years, and I know you can find your way around in the library.

Perhaps what burned me out is when Latitude suggested I get a 3D printer to print a plumbing valve that my project needed to advance for fully automated hydroponics. When I got into CAD to design said valve, I didn't like any of the point-n-click apps, I took right to OpenSCAD and is 100% code based designing. So I've tried various types of valves that could be articulated with a mini servo, but the printing process is too imperfect on a micro level and that doesn't make for a good pipe fitting maker. Perhaps I could have dedicated more months to perfecting any of the various ideas I've tried and printed, I didn't want to extend more brain power. So knowing that I could not advance my project w/o that coupled with all of the other problems I was having migrating my project from one Mega to several ESP8266 boards, the combined experience brought my mind to it's knees. So I put the brakes on everything, full stop across the board. Open mental process explorer and get to force stopping processes to prep for defrag and reboot. I have a lot of miles on my mind and mostly failure from every mile, it all takes a toll while trying to remain positive for the obvious reason.

Months later I found new hobbies to remain constructive. I mostly mastered hydroponic nutrients and make my own formulations by targeting certain elements in the solution. The new room will have a dedicated AC unit and I can finally wrap my head around VPD. My grow will become more productive and simpler to manage at the same time. My long term goal is to start a 3D printing/CNC business. That's a very fun hobby when you can afford to spend time building things. I may one day dust off the Arduinos and connect any of my gear, but not anytime soon.

Sorry for the rant. Sometimes I can't shut up.
 
About your thermistor situation,

I was just using that as an example, but you helped make my point, there are different calculations for different sensors. I cannot possibly include every calculation that could be required for any sensor, now and in the future. What I mentioned was trying to find a way to script the math. For example, if I had a sensor that I had to divide the reading by 6 to get the final result, that would be different than any other sensor I had. How can I add that sensor to my already compiled program. Well, lets say I had a text file with the following line

VALUE=READING/6

and we have code that can read that text file, and do the math, so if the READING was 600, then VALUE would be 100, and this is the result we would get from this "scripting engine".

I'm pretty sure we used to be able to do this on Unix, but that was over 30 years ago.

Something rattling around in my head, maybe the answer will appear magically :)
 
Something rattling around in my head, maybe the answer will appear magically

and rattle it has... I think I may have an idea that might work, something sort of like the way I configure switches. The database holds the "choices" and the code interprets it...

switchName [WINDOW FAN] - the name/description of the switch
controlSensorId [01] - which sensor do we use to determine when to switch on/off
switchDigitalPin [6] - which pin controls the switch
controlSensorCalcValueToUse [1] - a sensor has 3 calcvalues - which one shall we look at
switchHighWhenSensorIs [GREATER THAN]- GREATER THAN, LESS THAN, EQUAL, etc
sensorHighValue [25] - this is the value which the sensor is compared to using the previous statement
switchAnalogHighValue [] - if the switch is on an analog pin, what value do we set when it should be high
switchHighDurationSeconds [0] - if >0 then switch high for this many seconds, then switch low (toggle)

Same for setting the switch LOW (off)
switchLowWhenSensorIs
sensorLowValue
switchAnalogLowValue
switchLowDurationSeconds

If we use the data I put in square brackets [] we can see that the switch behaves as follows:

The [WINDOW FAN] on Digital Pin [6] will turn ON when Sensor [01] value [1] is [GREATER THAN] [25]

So if sensor 1 measures temperature, it says the fan will come on when the temperature gets above 25C

Using the same logic, I can set the temperature to turn the fan off...

It doesn't have to be a fan,
it could a a humidifier or dehumidifier is the sensor is a humidity sensor,
or a water pump if the sensor is a depth sensor for my reservoir,
or turn the lights on in a room when I enter if the sensor is a PIR sensor,

There are so many possibilities with this kind of configuration, and it can all be done without having to recompile the software.

I have something similar for the grow lights, however, they are all time based, not sensor based, so it is a completely separate but similar issue with its own configuration, same with servos, as in my automatic clone misting.


So I'm tossing around ideas similar to this, let's see if I can make it work...
 
Back
Top Bottom