This article is a project about TDS Monitoring in the Aquarium With ESP32, I will measure the TDS value in the fish tank, to monitor the water quality.
I have an idea to build a smart aquarium by improving my fish tank. It sounds very difficult for it: monitoring the water, automatic water changing, automatic feeding, and so on. Those functions are required for a smart aquarium.
Now I plan to do the first step -- monitoring the water quality. The water contains a lot of impurities, contaminants, and chemicals. Checking the TDS in water is the easy way to monitor the water quality.
Total dissolved solids (TDS) represent the total concentration of dissolved substances in water. TDS is made up of inorganic salts, as well as a small amount of organic matter. The TDS level is how much of the total dissolved solids are present in the water. The unit of TDS level is PPM, and 1 PPM TDS represents that it has 1 mg dissolved solids in 1L water.
The fishes need a stable environment that has the same level of TDS and PH as the original habit in aquariums or tanks. Different fishes require water with different TDS. 400PPM~450PPM TDS in the water are recommended for most freshwater fish living. If the concentrations too high would cause the death of fish and permit a high volume of algae bloom. The low level of TDS in the water will affect fish growth. In a word, if the TDS climbs above normal levels, you may need to help the small fish…
Testing the water conductivity is a common way to measure the TDS in the water. The dissolved solids can improve the water conductivity that the more dissolved solids and the better water conductivity. And TDS measurement will indicate if the minerals, salts and other compounds are building up over time.
I purchased a kit for measuring the TDS, it is made up of the TDS probe and converter. The converter measures the water conductivity by the TDS probe and converts the result to the voltage signal.
For the controller part, I had to prepare one to receive the result and a display to show the TDS level. The ESP32 3.5" TFT touch screen is my best choice, it is based on ESP32 and has a 3.5 inch capacitive touch screen.
Besides, the ESP32 3.5 inch LCD screen has WiFi connectively, that I can even update any of my result to the internet, that I may need as the project going. So it is suitable to connect the TDS converter because it has an expansion for sensors/Actuator, convenient for my project:
Connect the TDS probe to the TDS convertor board. And connect the converter and ESP32 with the following connection. The TDS converter board outputs analog voltage, so any pin that has A/D on the ESP display interface is OK, I used the IO36:
ESP32 <------> Converter 3V3 <------> VCC GND <------> GND IO36 <------> A0
Then power the ESP32 with the USB cable.
I have programmed the ESP32 with Arduino for measuring the TDS, and the code is available in Makerfabs Github.
ESP32 had to receive the voltage signal that the TDS converter output, and calculated these with the specified formula.
tdsValue=(133.42*compensationVolatge*compensationVolatge*compensationVolatge - 255.86*compensationVolatge*compensationVolatge + 857.39*compensationVolatge)*0.5;
For driving the display, it is required to install the library TFT-eSPI.h. Refer to the example (TFT_ring_meter) included in the library, I programmed it and got some beautiful shown.
xpos = 480 / 2 - 160, ypos = 0, gap = 15, radius = 170; // Comment out above meters, then uncomment the next line to show large meter ringMeter(value, 0, 1000, xpos, ypos, radius, "ppm", BLUE2RED); // Draw analogue meter
There are many pictures in my previous projects by programming with this example on the ESP32 3.5 inch TFT touch screen..
After the programming, I tried to test the tap water TDS, the output was 144PPM, which seems reasonable. I used some tape to fix the display and converter on the tank wall, and placed the TDS probe to the water for measuring. This is a little risky in the testing, that the probe is waterproof while the PCBAs are not.
Tested TDS in the fish tank, the result reached a shocking number out of the range. It was above 999PPM. seems I not only had to change the water for the fish tank, but also need to wash it. To avoid the huge change of TDS that may not be good for fish, I take some dirty water back to it, the TDS measuring is 653PPM.
This TDS monitoring can remind me to change the water of the tank manually. For changing water automatically, it is required some water pumps and valves controlled by the controller to be assembled into the tank, it is the next step for building the smart aquarium. Keep hearing from us...
If you have further questions about TDS Monitoring in the Aquarium With ESP32, or need turnkey PCBA solution, please feel free to contact service@makerfabs.com.