The whole goal of this week for me was to create my own Arduino version customized for Aquaponics (Aquaduino) and use it as well as my input device. The reason I'm doing this is for later use this board for my final project
One of the things that make this project special is that I´m using an ATMEGA32U4, that has FTDI integrated, so you can, after burning bootloader, program your board using an USB Mini B. The ATmega32U4 is the same microchip used on Arduino Leonardo. I based myself upon many designs out there. I used the Eagle Schematics from the Leonardo itself, from:
Aquaduino is a simplified version of an Arduino Leonardo. No reset button, just one led on pin 13, an ICSP for its first programming, some Pins but not all available. I designed it to be easily hacked.
Water is the life-blood of an aquaponic system. It is the medium through which all essential macro- and micronutrients are transported to the plants, and the medium through which the fish receive oxygen. Thus, it is one of the most important aspect to monitor for successful aquaponic food production. Five key water quality parameters have to be considered dissolved oxygen (DO), pH, temperature, total nitrogen, and water alkalinity. Each parameter has an impact on all three organisms in the unit (fish, plants and bacteria), and understanding the effects of each parameter is crucial. Although some aspects of the knowledge on water quality and water chemistry needed for aquaponics seem complicated, the actual management is relatively simple with the help of simple test kits. Water testing is essential to keeping good water quality in the system.
For this first version of Aquaduino, I envision to start monitoring:
Dissolved oxygen is the water quality parameter that has the most immediate and drastic effect on aquaponics. Indeed, fish may die within hours when exposed to low DO within the fish tanks. Thus, ensuring adequate DO levels is crucial to aquaponics. However monitoring DO levels is very important, it is quite challenging because accurate DO measuring devices are very expensive or difficult to find . It is often sufficient for small-scale units to instead rely on frequent monitoring of fish behaviour and plant growth, and ensuring water and air pumps are constantly circulating and aerating the water. In a next Aquaduino iteration, I will include it.
Before jumping on Eagle, I sat down with our local Guru to draw on a piece of paper, what I will need to add//remove on the top of Arduino Leonardo to make it work. We also decided to include the outputs on the same board. For more info about outputs, please check the Week 14 assignment
There you go, the beast!
I found this image which is very helpful, knowing what is what in your ATMEGA32U4. Thank you apighixxx.com.
As you can see, the grey frame is the pin scheme exactly as they are in Arduino Leonardo, making it easy for you to program it afterwards with Arduino IDE.
As I mentioned above, I started the Aquaduino based on FABLEO schematic removing reset Button, some LEDs and several pins. The reason behind it is to simplify the design keeping only crucial elements.
Apart of removing components, I simplify the numbers of pins connected to the Microcontroller to connect the 4 sensors mentionned above. Each sensor will have it's respective 3 Pins header including VCC and GND.
Looking at the ATMEGA 32U4 PinOUt diagram, I allocate 2 analog Pins (i.e. A0-PF7- and A1 -PF6) for the pH and EC sensors.
When it comes to the EC and pH sensors provider, I use the ones that Open Agriculture initiative from MIT Media Lab is using as described on their respective Bill Of Materials on Github. These sensors have been designed specially for Arduino controllers and has built-in simple, convenient and practical features. It enables a simple connections according to the following diagram and after uploading the program, you will be able to measure the pH and EC values easily.
When it comes to pH sensor I used this Analog pH Meter Pro model
When it come to digital input it is good to add a pull-down resistor between the middle pin of the sensor and the 5v line.
EXPLAIN WHY
To monitor the water T°C sensor I will use the DS18B20 water proof sensor. According to the litterature, the value of its respective pull-down resistor shoudl be a 4k7 (4700 ohms). As we don't have it in the fab Lab, I will use a 4k9 (4900 ohms).
To monitor the air T°C and humidity I will build a DHT22 Temperature and Humidity Sensor that need a 4k7 (4700 ohms) pull-down resistor. According to the litterature, the value of its respective pull-down resistor shoudl be a 10k (10 00 ohms).
Partlist exported from C:/Users/LuizHenrique/Documents/eagle/Luizino/luizino02.sch
Before starting to route the traces on the board, it is important to set up the correct Design Rules which are usually based on the drill diameter used to mill the traces. In my case I will use a 1/64 (i.e. 16 mill).
The Thermal insulation parameter is used when substracting pad shapes from signal polygons.
Looking at how the Fab Leo was routed, I tried several design before arriving to Trial #3.
In Eagle polygons are used to make big copper areas on a PCB that aren’t necessarily traces. We use them all the time to fill blank space on a PCB with copper connected to ground. In a sense, it allow you to simplify the number of traces on your board.
I learn a lot looking at the following tutorial on Polygons and ground fills for PCBs in Eagle
As I'm working with vias, I will need to pass 1mm diameter connection to bridge the top and bottom part of the board, so I need to make sure that my drill diameter is 1mm large. To do this I've used the Change / Drill option on the left hand side bar
The distance between the ATEMAGA 32U4 pins is 0,4 mm that is slighty lower than the 16 mill diameter of the 1/64 drill (i.e. 0,4064)
So the respect the Design Clearance Rules, I need to reduce the width of traces connected the pins
Before we send it off to Fab Modules there are a few tools we can use to check our design for errors. This tutorial on Sparkfun has been of a great help
As you might already know, to mill our boards we are using fabmodules.org, and for that I exported my files as PNG, one of the formats that FabModules opens. You might want to save it in very high resolution (around 700dpi) so your traces get very precise once fabmodules converts it.
To mill the bottom part of the board it is important to remember that will need to flip your board so does your design :)
I will use the SMR-20 Rolland to mill this board. Before cutting you need to set up the XYZ home to zero. Then you are ready to go.
It look gooooood!
...and that's how it went:
When I plug the Aquaduino into my computer via the mini USB cable, I get an error message telling me that the board is drawing too much power and that the computer is shutting down the USB port. It means that I should have a short cut somewhere on your board.
First, I did a visual inspection of the board and reflow any solder joints that look cold (not shiny and smooth).
Then, get out the multimeter and check all the connections to make sure that:
After putting back the MCU and pluguing it back, the LED turn green ! Aquaduino is powered !
To Burnload the ATEMAGA32U4, I used Arduino IDE to program it, plus my FabISP. Once the Aquaduino board was recognized, in Arduino IDE, select Tools menu, Board: Arduino Leonardo (Leonardo Board has the same ATMEGA32U4), Then Tools again -> Burn Bootloader.
New surprise, it didn't work and receive the following message
Using the terminal and the following command
avrdude -c usbtiny -P usb -p m32u4
I tried to communicate with the MCU and get the following message
And what I should get is the following
The one wire Digital Temperature Sensor - DS18B20 from Maxim ,formerly Dallas, (that cound be found on Github) is a great chip for measuring temperature in wet environments. Luckily, there is a Dallas Temperature library for the arduino which makes using this sensor very easy.
Just download a copy of the library. In it you will find two folders. Drag and drop the DallasTemperture folder into your arduino/libraries folder. If you dont already have the OneWire library then you will need to copy that folder into the libraries folder also.
Next, load up the sketch below and upload it to your Arduino board. Using the Dallas Temperature Library makes getting the temperature easy.
When you have uploaded the sketch, click on the Serial Monitor and you should see output like the following. The temperature is in degrees C
The code is directly taken from Wiki page of DFRobotics PH meter where I bought the pH probe
NOTE: If you want to measure the pH value of other solution, you must wash the pH electrode first! The power supply is closer to +5.00V, the more accurate pH reading you could get.
The sample code I used for testing the PH meter and get the sensor feedback from the Arduino Serial Monitor could be found on the Wiki page of DFRobotics PH meter
Adafruit have a DHT11//DHT12 library and example code that makes it easy to test the DHT11 and get values to display on the serial window of the Arduino IDE.
In the example sketch the temperature and humidity variables are defines as "float", i.e. they have decimal places. This can be changed to an "int" to remove the decimal places as they aren't needed in this project.
Upload the sketch and check the results in the serial window. You should see the temperature as whole rather than decimal numbers.
You access and download all the files generated during this week from my google drive:
This week assignment turns into a 2,5 weeks to masterize the entire workflow from the first draw until the board
was working. Along the process I can't remember all the issues I faced, but
learning by failures it one of the best way to learn.
At the end, what a relief when it's working ! . A next step is to connect an LCD display and see all these data on it.