Updated: June 8, 2019
All software for this project is developed using Microsoft Visual Studio 2017 as my IDE. Code for the Arduino and compatible boards is written in c++ and compiled using the Visual Micro plugin for Visual Studio. Code for the Windows pieces of the project are written in C#, a language I've used for many many years in my career.
Visual Micro is a plugin for Microsoft Visual Studio (with C++ installed). Visual Micro helps you create Arduino compatible cross-platform programs for hundreds of different Arduino compatible micro-controllers. Visual Micro is available for free for most users.
I've been a professional Software Engineer for my entire career (35 years) and probably the number one thing I learned is to write your code so other people can read it. Those other people may someday include yourself, looking at the code, scratching your head, wondering, why did I do that? or What is that doing?
Execution speed is NOT a priority here, accuracy is. Accuracy is easier to achieve when you can easily understand what your code is doing, especially if you have to debug it.
- I tend to overuse white space, it makes things easier to read, and generally doesn't affect the size of the compiled binary.
- I avoid coding shortcuts as they tend to complicate your code.
- I use long variable names, again, this lets me use meaningful names, and long variable names have no effect of the size of the compiled code.
- I avoid the use of Strings except in very limited cases. Strings, once you start manipulating them, end up using a LOT of memory, so use char arrays instead.
- Whenever I have literal strings in the code (has quotes around it, like "this") I always use the F( or PSTR( macros to put the strings into Flash memory (the code space rather than the data space).
GrowByWire also requires a MySQL Server (which I run on a spare laptop) to store all the data it collects from the sensors. Other modules can then use this data to determine actions that need to be taken, water a plant, turn on a fan, etc.
For visualizing the data, there is a web server, which is also used to configure certain aspects of the system, such as where plants are located, where sensors are located, and where are they plugged in.
Also for visualizing the data, a Blynk local server, and client on my smartphone. From my phone I can also instigate actions on other modules.
I've also used a number of 3rd party libraries for the Arduino platform, and each will be listed within the description of the individual module software, where used.
Sensor Module software
First and foremost, we must collect data about the grow. Without this data, we could not make decisions about what needs to be done. We monitor the following conditions:
- Soil Moisture Level
- Light Level
All data collected is stored in a MySQL Database.
Maintenance Module software
Web Server Module software
Switch Module software
Auto Watering Module software
I2C Water Depth Module software
I2C Dual Level Soil Moisture Sensor software