Final project

My final project is an automation system for adjusting of pH and nutrients in hydroponics solution by utilizing pH and load measurements to control peristaltic pumps.

The background behind the idea for final project is presented in Week 1: Principles and Practices. The idea is to measure hydroponic solution pH and the total weight of the solution and to utilize peristaltic pumps to control the solution pH and nutrient levels, by adding fertilizers and pH control agents in the solution. Whole system is going to operate in 12 V system where solar panel is used to charge the battery, which is needed for the operation.


Presentation slide

presentation

Presentation video



Bill of materials (BOM)

BOM

Short description for the need of hydroponic nutrient solution automation.
In hydroponic systems hydroponic nutrient solution is used to feed the plants. There is no soil, but just a growth medium such as rockwool or lightweight expanded clay aggregate (LECA). I use both of these. The plants are planted in rockwool cubes and the rockwool cubes is placed in the LECA bed. Plants grow their roots in there and the growth medium has to be wetted with hydroponic nutrient solution, which has correct pH (5.5-6.5) and desired nutrient balance. Plants will suffer and they do not grow in poorly controlled hyroponic system, but they will grow extremely fast and produce good crop in well controlled systems. I have done the hydroponic nutrient solution by hand earlier, but I decided to make automation system for the solution mixing. This way I can rely that the pH in the system stays in the desired range all the time. Rockwool tends to increase pH in the beginning of its use and also the plant roots increase the pH slowly. With this automation of pH and nutrient adjusting, I hope to be able to leave the plants without human care for a long periods of time and for example not to worry about the state the plants are after a vacation. The nutrient adjusting is more vital when the system is connected to water intake, but pH has to be controlled all the time. There are tons of information on the hydroponics in the Internet, but Wikipedia article serves as a good starting place for more information.

Final project evolution part by part
I had an idea for the final project since the beginning. I never knew how much work it would take to finish it completely based on my initial plan.

Planning
During the Computer-Aided Design week, I started to sketch how the final product could look like. In the Applications and Implications week I go through the final project plan and its details. Only a few weeks ago in the Project Development week, I was still very optimistic about my schedule, but real world hit me hard and I couldn't finalize the final project as fast as I had hoped.


Vessel for hydroponic nutrient solution
The storage vessel for solution is the first thing to design, because it is the heart of the project and acts as a support for other designs. During the computer-aided design week I designed the storage vessel, which contained holes for the mounting of pH-EC meter and bottle stand for nutrients and pH agent.

Storage vessel

But as the time went on the design evolved and reality started to show its face and I desided to go with an acrylic box for the water and a support structure for it. I made 3D modeling of the support structure for the box. It is a simple structure and I made simple joints to save time. The process on the structure design can be found from the Wildcard week documentation.

Acrylic box
I started to create acrylic box for the hydroponic nutrient solution, but it proved to be more problematic than I thought. The box is created with Inkscape boxmaker. I created a simple tabbed box of 3 mm acrylic. I used 0.10 mm kerf. It was tightly fit. I created a test box and used acetone to weld it, but acetone didn't work like it should and the acrylic didn't dissolve enough, and box didn't hold water. All of the welding was done in a fume chamber. Luckily, Eino had some acrylic glue, which could be used to seal the box water tight. But it turned out that the acrylic glue didn't work as well as I hoped.

Support

Then I went for toluene and acetone.

Support

I dissolved acrylic pieces in acetone and toluene and waited for several hours for them to dissolve a little. Toluene created clear bonds and it affected through the whole material, but it was very slow to dry. Acetone dissolved acrylic slowly, the bonds were superficial and when the box was filled with water the bonds would brake from the force. So I connected the walls together at first with acrylic glue, then fixed the holes with acetone and finally used toluene to make the bonds strong.

Support

Support

It was quite hard to make the box water tight and strong. I would recommend to buy PE plastic box from store and save a lot of time and money.

Support

Support structure
The acrylic box bent a lot when filled with water and it required a support structure. I decided to support it from the parts, which were generally problematic in other words the long sides, which formed u-like shape when the box was filled.

Support

I created an assembly for the CNC router and created pockets for the joints, metal plates, load cells and for the PCB for weight measuring. I used 5 mm flat end 2 flute milling tool for the whole milling operation.

Support

I simulated the job, before cutting it to see that it should run smoothly. I set the feedrate to 80 %, which corresponds to 250 mm/min and spindle to 80 % as well, which corresponds to 7000 r/min.

Support

I had to change the order of the parts, because I made a mistake with bottom layer in pockets. I used the stock bottom, when I should have used the pocket face. I fixed that and everything run smoothly afterwards.

Support

I used belt sander to sand all the edges, filed the joints to fit and put everything together.

Support

Support

I used wood filler to make the surface even and painted it. First with base coat and then with grey spray paint.

Support

Support

Ariduino or the brains of the machine
The machine needed brains for the operation, so I did a board with an ATmega328P microcontroller. I like to call this board "Ariduino". This board was originally made in Input devices week and I modified it a little to add micro usb connector for powering it, fixed the serial communication pins to RX-TX and TX-RX from my original RX-RX and TX-TX connections and changed pH meter and EC meter pins (1 pin for each instead of two) and added needed pin for the thermometer. I also added more space for pin headers, because they were very close to each other. The final board design looks like this:

Support

Support

PH meter
At first, I designed the pH-EC meter to be a moving system. I wanted to design it to make the meter part to move up and down and also front and back. This part was also designed to contain the storage solution bottle (cap is fixed on the pH-EC meter) for the pH and EC meter.

pH-EC

After I presented this design to Bas, he said that maybe I should make a small vessel where the pH meter is stored and peristaltic pumps are used to pump water in the vessel when measurements are needed and fill it with storage solution when measurements are over. I chose to start working on that, because it is a bit easier. I did two vessels for this purpose during the Wildcard week with vacuum forming.

Wild1

I ended up never needing those, because it doesn't seem to effect much on the pH meter. The recommendation was that the pH meter should be calibrated every 1 to 1.5 years either way and it should be replaced when it cannot be calibrated anymore.

It turned out also that the storage solutions for the pH and EC sensors should be completely opposite from each other. PH sensor should be stored in buffer solution (saturated KCl solution, which I knew from before), but the EC sensor should be stored in a solution with as low ion concentration as possible i.e. distilled water. Distilled water is the worst possible storage liquid for the pH meter and high salinity solutions will consume EC electrode quite quickly. It was intersting though that I found combined pH and EC electrodes, which were supposed to store in combined electrode storage solution. I ended up buying an EC meter, which is meant for on-line measurements and should be able to last about 1.5 years before calibration. I couldn't finish the EC meter before the final project presentation.

One of the most interesting parts of the whole final project is pH meter. I found in dfrobot a guide for a pH meter building. I used their schematic except I changed the charge pump to LM2660 from TC1121COA. I created the schematic and then made the assembly on board.

pHBoard

PHBoard2

It was very interesting process and this had more components on it than the previous ones that I had made. It made the process more time consuming and more prone to errors. To get the -5 V and 5 V to my schematic correctly, I had to rename the lines connected to those. It was straight forward, after I realized what needed to be done. I collected all the components for the soldering and soldered the whole thing together.

PHBoard2

PHBoard2

At the first try, one of my ground lines was not connected to right place in the OP amp, which caused negative voltage and an error. I added a jumper wire to that pin.

PHBoard2

After that was fixed, everything went smoothly. I programmed Ariduino board (Input devices week) based on the dfrobot's guide. Basically I removed everything else from their guide except the method to read the analog pin. Their code didn't fit for my electrode and I had to create my own calibration equation. I connected the electrode to the system and used Ariduino board to make calibration and adjustment for my pH meter. I measured voltage with three different pH buffer solutions 4.01, 7.00 and 12. The voltages were 1.758 V, 1.924 V and 2.100 V, respectively. Based on those values, I drew a curve and created a fitting curve and extracted an equation for the pH measurement. The calibration curve was a bit curved and at first I didn't understand why, but I found an article about pH meter calibration. In there it was stated, that neutral values are hard for common glass pH electrode and there is always lower values than should be and perfect linear calibration curve is not expected. Theoretically the optimal calibration curve is 59 mV/pH and with my electrode it was only 42.75 mV/pH, which is really low and I can declare that the pH electrode is very poor quality. Well, I'm not really surprised...

pHcalibration

With 4.01 pH calibration solution, the measured value was 4.03.

PHBoard2

With 7.00 pH calibration solution, the measured value was 7.00.

PHBoard2

With 12.00 pH calibration solution, the measured value was 11.99.

PHBoard2

It was fun and provided a feeling of success. The error was small enough for my use. In real life, the pH measurement step size could be 0.5 and it wouldn't be a problem for the plants.

Bottle holder
My first draft of the bottle holder contained a holder for three 350 ml bottles. Two bottles for nutrients and one bottle for pH agent. The shelf for the bottles is attached to a mount and to keep the bottles steady.

Bottle holder

Bottle

The bottle cap has threadings in it and hole in the center, where silicon tubing is added. Peristaltic pump is used to dose the amount of nutritions and pH agent to solution through that hole.

Cap

I chose to do the bottle rack in completely different way. I cut simple rack with laser that can fit the original bottles. It didn't make sense to me to create bottles for the nutrients and the phosphoric acid, because acrylic for example is much worse material for that purpose than the bottles meant for it. Now I can buy large 5 l canisters of fertilizers and fill these old bottles and create less waste. I made only a hole for the tubing in the bottle cap.

BottleRack

The first assembly of the machine looked like this.

Assembly

The whole machine ended up looking quite different.

Assembly

Peristaltic pumps
I started to work on the peristaltic pumps early on, because I knew that without those the project wouldn't be worth anything. I was looking online for existing pumps and based on those I started to create my own pump. I did first design of the peristaltic pump rotating part during the 3D Scanning and Printing week. Then I did the first casing design during Molding and Casting week. The peristaltic pump seemed to be the hardest task. At first, I tried to make my completely own design, but it had problems with the whole structure and sturdiness. I made the bearings from 3D printed plastic and also the axles as well. It broke almost instantly.

PeristalticPumpv1

I lost my self confidence momentarily after that failure and since I only had stepper motors with very short shaft, I decided to order ones with higher torque and longer shafts, so I could use it as an axel for the pump. I used Karim Lakras project as a basis for the design. I printed the pump from the thingverse and as all of the projects from there, this didn't work as well. It didn't have any fixing method for the rotating part and it slide. The rotating part was also too small and the bearings didn't press the tube hard enough. The rotating part was too thin with one set of bearings and the middle part was too thin for everything to fit inside. I had to make so many corrections to the existing plan that it might have been faster to use my own design. The dimensions were incorrect and stl files crooked and the triangle in the middle was poorly made and broke down easily.

So I started to correct these errors. I realized that I have to make bearing axles of metal and the rotating part should be firmly connected to the motor axle with screws. I changed the rotating part to this kind of solution by Ralf. I made the parts thicker and added holes for the screws, which go to motor axel and also places for nuts to make it firm.

RotatingPart

I changed the dimensions on the part where tubing runs to make it fit with double bearings. I also changed it to be made of two parts to make the tube insert easier.

TubingPart

I also added support structure below stepper motor to make it possible to fix it to surface. The cover that protects the tube was dimensioned in a way that everything can rotate.

Support

During the Interface and Application Programming week, I calculated the amount of 85 % phosphoric acid, which is required to lower the pH of unbuffered water from 7 to 5.5 and the result was 0.01938 ml. To increase its demand to 1 ml, the phosphoric acid needs to be diluted to 1.5 % solution. This level is high enough to be pumped with my pump design, which pumps about 0.13 ml in each body of fluid. With tap water (pH 8.3) it turned out that I need about 0.1875 ml of phosphoric acid (85 vol-%) per liter of tap water to lower the pH to 6. Basically with this number it is very easy to change fresh tap water pH to 6. With rain water you have to be much more careful and rain water also is many times a little acidic itself.


The pumps are controlled with a board that was designed and made in the Output devices week. That board has an ATmega328P microcontroller in it. It is used to control four RepRap stepper drivers A4988, which are connected to one board, which has all the necessary connections to run four different stepper motors. It was originally designed and made in the Output devices week as well, but it was later modified to add enable pins and a capacitor for the motor power supply. The enable pins were needed to power down stepper motors when they are not needed. The final design looks like this.

Support

Support


Support

I calibrated the pumps with a simple test. I measured the amount of water from 5 full rotations with primed tube. The result was consistently 2 ml, which corresponded to my calculations for this pump. My colleagues were enthusiastic about my pump and ordered several units for the future research purposes.

Support

Load sensor
After I put the structure together, I started to work on the weight measurements. I found a nice how to make a bathroom scale guide for Arduino. In there was presented all the connectins, verification methods for load cells and calibration and measurement codes for the Arduino. I bought the load cells and HX711 board to save some time. The board only cost 1.5 euros, so I probably saved money as well. I connected them together based on the drawing from Instructables.

ScaleArduino
Connections for the load measurement. (DegrawST, 2018)

I put the load cells in their places.

Support

Kati had a nice idea for what to use to take the load off the osb board directly. She suggested that I could use old failed boards. I cut the bords in size and fit them in their places in the osb board. They fit tightly and didn't require any glue.

Support

I applied the calibration code for my system and to my surprise the only thing I needed to change was calibration_factor from -7050 to -7000. I used pieces of aluminum to calibrate the scale.

Support

Support

At first, I used pieces which total weight was 4676 g and this resulted in calibration factor of -7940.

Support

I incresed the weight to about 5100 g and the calibration factor changed to -7090.

Support

Finally I increased the weight to 8975 g and it resulted in the calibration factor of -7000.

Support

Then I set the weight test programs calibration_factor to -7000 and tested different weights. 5573 g showed 5.7 kg and I was happy with the result.

Support

. After I got everything together, I used water to calibrate the scale. It proved to be easier and the weight location didn't affect the results. The final calibration factor was -9420, when I added 10 litres of water to the system. Of course the added pumps, pH meter and the acrylic box lid had its effect on the final result.

Support


Code
Coding was really easy for the machine, because I had done almost all of the work during other assignments and could directly use load sensor code for Arduino. I made code for the temperature sensor during Input devices week. Even though I didn't use it for the final project yet, it is already implemented in the code. During the Output devices week, I created basic code for the stepper motor based on the Dejan Nedelkovski's code I found from howtomechatronics.com. Then I modified the code for four stepper motors during the Networking and Communications week. It also contains the code for the networking between my motor controller board and Ariduino. I just combined the codes for the load and pH measurements and created logic based on the idea behind the automation.

Support



PH and load are measured all the time. When the pH is above 6.5, phosphoric acid is added to solution and when the load is increased by 0.2 kg fertilizers are added to solution. Ariduino board sends a message via serial communication to stepper controller board, which then operates the peristaltic pumps based on the need for the pH agent or fertilizers. When the EC measurement is added to machine it is used to check electrical conductivity of the solution to estimate the need for water change. With green and red leds it is going to be indicated if the salinity level is acceptable for hydroponic solution.


Putting things together
Ariduino board is connected at this stage to pH meter, load meter and motor controller board.

Support

I designed a simple mdf box for electronics with Inkscape box maker. I made necessary holes for cables and added space below the boards to make screws fit with nuts. The box looks a bit spaceous at the moment, but it requires space for the EC meter board and solenoid valve controls. I didn't add the temperature sensor at this stage, because it is only needed for the EC measurements. It was made during the Input devices week and tested as well. It has to be made waterproof (I will try to use resin) and tested carefully for a long period of time before added to the system. I don't want it to fry my system.

Support

I made holes for the pumps on the lid of the acrylic box, pH electrode station and two holes for the tubing. One for the inlet and one for the outlet.

Support

The pumps are connected to fertilizer and pH agent bottles with tubing through the bottle cap. I had only one of the larger bottles empty, but those are used for the actual system.

Support

I bought a power supply (3-12 V and max 1.5 A) to run the pumps, but I didn't cut the wire yet, because I want to make sure that it is good for the final placement before it is dedicated for this use only. It worked nicely with the system. During my test runs I ran the system about 5 hours without any problems and I ran different scenarios, which are possible in the actual use.

To finalize the look, I braided stepper motor cables and used wire shrink wrap with electrical tape to create nice bundle of wires. Stepper motor wires, pH electrode wire and load sensor wires are all bundled together and a cable clamp is used to remove pressure from the pin headers. They need to be longer and the electronics box cannot be under the storage vessel, because the electronics box cannot lie on ground, because it can get wet during rain. I place the electronics on a stand and the storage vessel is going to be on the ground. The FTDI wires are covered with a small and simple box design.

Boxing

Greenhouse at my parents place is powered with 12 V solar panel system.

GreenHouse

The machine is placed in the corner of the greenhouse. It seems to integrate well with the greenhouse. The load sensor wire is about 20 cm too short and it has to be changed before the machine is put to operation. The messy looking motor power wires are removed once the machine is in its place and dedicated power supply is changed to power the stepper motors.

GreenHouse



Project is licensed with Creative Commons License Attribution 4.0. The licensing is studied and presented in more detail in the Invention, Intellectual Property, and Income week.

Reflection on the final project and the future of my fabrication
I enjoyed working with the machine that was related to my long term hobby - hydroponics. I had planned doing something similar for a long time and since we built a greenhouse at my parents place last autumn, I decided to make it work with hydroponics as well. As my parents don't seem to realize that something else than water is needed to operate hydroponic system since there are no nutrients in the growth medium and the pH is basically the same as the water pH and not like in typical soil where pH is automatically adjusted by the soil type. I built the hydroponics system there, but to ensure the operation, I wanted to add pH and nutrient control as well as the pumping. This made the project really important and interesting for me and now I have a chance to upscale this prototype to actual greenhouse size. Peristaltic pumps are big enough for a much larger scale, because the pumping amounts are not very big and pH measurements are really important. I will add the EC meter with temperature sensor to the system and I will add green and red leds to tell the user, if there is some problems with pH or salinity. This project has taught me really much and has given me so many ideas for the future. I might be a little bit too enthustiastic at the moment. The grandness of the plans grow... Fab Academy has opened my diy possibilities and given me things to do for several years.

The files used in the assignment are shared below:
Ariduino board
Ariduino schematics
Ariduino traces
Ariduino outline
Motor controller board
Motor controller schematics
Motor controller traces
Motor controller outline
StepperBoard board
StepperBoard schematics
StepperBoard traces
StepperBoard holes
StepperBoard_outline
pH meter board
pH meter schematics
pH meter traces
pH meter outline
SupportStructure.zip, Autodesk Inventor files for the support structure and STL files of all parts and the structure
AcrylicBox.zip, svg and pdf files for the acrylic box laser cutting
ElectronicsBox.pdf, pdf file for the electronics box laser cutting
ElectronicsBox.svg, svg file for the electronics box laser cutting
pHmeterHolder.pdf, pdf file for the pH meter holder laser cutting
pHmeterHolder.svg, svg file for the pH meter holder laser cutting
BottleRack.pdf, pdf file for the bottle rack laser cutting
BottleRack.svg, svg file for the bottle rack laser cutting
PeristalticPump.zip, Autodesk Inventor file for the peristaltic pump and STL files of all parts and the whole pump
ScaleCali.ino for scale calibration
pHmeter2.ino for pH meter calibration
FinalProject14062018.ino main code for Ariduino
motors14062018.ino main code for motor controller