Auto Tank: Monitoring pH and temperature through self-built cloud service

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
Introduction

I use the Arduino-compatible ESP8266 board to connect the pH and temperature sensors and send the sensor data to the self-built private cloud service via the MQTT protocol via the Wifi connection. On the cloud, use Node-RED to subscribe to MQTT data and store it in the InfluxDB database. Grafana is used to display the sensor data historical graph and set the alarm condition. If the condition is met, the Slack message will be sent. You can also use voice to ask Siri to return the latest status of the tank.

System architecture diagram

1573805413408.png



Demo

1.Siri returns the latest status of the fish tank with voice (thanks to shih87: Siri Control of Apex (SCA) without HomeBridge)



2.Received notifications from Slack (mobile or computer app)

pH < 8.4 (for testing), get notification
1573805413481.png


pH back to 8.4 or above, get notification which is OK
1573805413550.png



3. Webpage showing historical data on pH and temperature
- Since the pH value is related with the light, on the pH chart, the white background indicates that the display light is on, and the black matrix indicates that the refugium light is on.
- On the temperature chart, the red background indicates daytime (06:00), the black background indicates night (18:00), and the left jagged indicates that the weather is cold, and the heater starts to work. I also need to adjust, the goal is to make the temperature change less than 1 degree (or 0.5 degree)
- Can add annotations, such as the vertical blue line on the pH chart
- Alert conditions can be set here

1573805413612.png


Prepare items
  1. ESP8266 board with wifi
  2. Analog pH Meter Pro Sensor
  3. Calibration Solution pH7 and pH10
  4. DS18B20 waterproof temperature sensor
  5. Breadboard
  6. Breadboard connectors
  7. Micro USB cable and power adapter
It’s low cost. The most expensive is pH electrode. I use the industrial grade, because the web page says "This pH meter is very suitable for long-term online monitoring”, so I bought it, but the pH electrode is a consumable. I will try cheaper one for the next time.
This DIY does not require welding, just inserts breadboards, and there is no good-looking housing. It is still under planning.
1573805413675.jpeg



Do It Yourself, But...
Required skills:
1. Arduino basic operation
2. How MQTT works, publish / subscribe
3. Basic instructions for Linux
4. Basic operations of Docker, Swarm
5. Node-Red basic operations
6. InfluxDB SQL syntax
If not, be enthusiasm (you can learn by yourself on Google, Youtube!)

Let’s Go!
Open source on Github https://github.com/samuelchiang/auto_tank
Follow the README will illustrate how to set it up.
 

LC8Sumi

Well-Known Member
View Badges
Joined
Dec 12, 2017
Messages
604
Reaction score
521
Location
Europe
Rating - 0%
0   0   0
Don’t put that temp sensor in salt water, it’ll rust in a week. I used mine in a plastic vial filled with hot glue.
You also want an isolated pH circuit in salt water really to get accurate readings. I went with atlas-scientific

best of luck:)

edit: I see you’ve coated the temp sensor, well done:)
 
OP
OP
samuel.chiang

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
Don’t put that temp sensor in salt water, it’ll rust in a week. I used mine in a plastic vial filled with hot glue.
You also want an isolated pH circuit in salt water really to get accurate readings. I went with atlas-scientific

best of luck:)

edit: I see you’ve coated the temp sensor, well done:)

Thanks, I coated the temp sensor with silicon, learn from the post of r2r.
Temporally I put the pH circuit far away my tank about 1.5m. I will later build a wooden house for all the sensor equipment.
 
OP
OP
samuel.chiang

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
Very nice. Thank you for sharing . The ph board has voltage isolation ?
Wow, I got the feedback from author of Reef-Pi. I have noticed this project on Github for a while.
I don't have extra circuit for voltage isolation. Should I have? Since from the USB cable into the 8266 and the pH meter board, they are all 5V.
 

Michael Lane

Well-Known Member
View Badges
Joined
Aug 11, 2018
Messages
677
Reaction score
1,123
Rating - 0%
0   0   0
Nice! I'll have to go through the source code to see what else I can learn! I've wanted to do something with MQTT and NodeRed for a while.

I think you will need isolation for the pH module. I had an Atlas Scientific module that I was very unhappy with for several years. It always worked fine on my desk, but the readings would jump all over the place in the aquarium. If you are getting stable, accurate readings, then you may be lucky for now.

If you start to notice crazy pH readings, then isolation would be my first suspicion. The typical solution is ADM3260. It seems like there may be a shortage of that chip right now, but you can also find breakout boards with it already.

This is a cool project, and I really like the architecture diagram. Very easy to understand at a glance!
 
OP
OP
samuel.chiang

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
Nice! I'll have to go through the source code to see what else I can learn! I've wanted to do something with MQTT and NodeRed for a while.

I think you will need isolation for the pH module. I had an Atlas Scientific module that I was very unhappy with for several years. It always worked fine on my desk, but the readings would jump all over the place in the aquarium. If you are getting stable, accurate readings, then you may be lucky for now.

If you start to notice crazy pH readings, then isolation would be my first suspicion. The typical solution is ADM3260. It seems like there may be a shortage of that chip right now, but you can also find breakout boards with it already.

This is a cool project, and I really like the architecture diagram. Very easy to understand at a glance!
Thanks for the keyword ADM3260. I just noticed the project https://github.com/reef-pi/pH-Board.
Compare my pH meter V1.0 with Reef-Pi pH Board, I don't have isolation for the pH module, right?
 
OP
OP
samuel.chiang

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
Smart plug socket based on Auto Tank server

Features:
  1. 8 Port plug socket, 15A Max current
  2. Remote controlled by MQTT
  3. Measure and record the voltage, current, power, energy, frequency, Power factor. Can browse with Grafana.
  4. Setting Timers, Marcos with Node-RED.

1590736170836.jpeg


AC in and "No fuse circuit breaker" for 15A current
(The measured maximum current is below 8A, which should be enough)
1590736170894.jpeg



Relay:
- 3 relays are for lights, connect with NO. This is to avoid direct power-on lights after power-on smart plug.
- 5 relays connect with NC. In this way, even if the controller fails, it can still be powered on.

1590736171036.jpeg


Components:
  1. MW RS-35-5: The 110V AC to 5V DC in the upper left corner is pulled to the power supply row on the breadboard to provide 5V 7A power supply to the relay board, EPS32 board and PZEM board.
  2. EPS32 board: This is an Arduino with WIFI. I wrote my program related to the socket here, mainly because the Auto Tank server controls each relay to switch through the MQTT interface, and uploads the power data collected by PZEM to the Auto Tank server
  3. PZEM: pzem-004t-100a, measure voltage and current through CT ammeter and parallel AC power supply, and calculate wattage and power consumption. EPS32 then read data from it through TTL (Modbus-RTU). Since there is only one CT, I hooked it up after the fuseless circuit breaker, and all the power consumption of the eight power sockets would be measured.

1590736171111.jpeg


On Auto Tank

Control panel
  1. Timer Switch: You can see the switch status of (1) main light, (2) Refugium light, and (3) 10-inch fan
  2. Manual Switch: can switch (4) Power head, (5) return pump (6) skimmer (7) chiller (8) reserved
  3. Marcos: Macro instructions, which can perform feeding, changing water, and suspending the skimmer for two hours

1590736171215.png



Dashboard for Power monitoring

You can see the voltage V, current A, power consumption W, cumulative power consumption kWh, and the status of each switch on or off

In the picture below, I put Power, Current and temperature together. It can be seen that whenever Power and Current protrudes a needle (lasting about eight minutes), which is the working time of the chiller compressor, the chiller is 1 / 4HP, corresponding to 40 gallon, noisy and hot during operation (300W can be measured here), so I will judge this time next, and turn on the exhaust fan, because I don’t want the exhaust fan to be always on. With the switch, I can save 1/5 power.

1590736171265.png


This is a flow chart of using Node-Red to pull the timer. The time to turn on and the time to turn off are all set here. Timer 3 is turned on every half hour and then off again for half an hour, and so on.

Yes, did you find it? My switch command is issued by the cloud server to the home appliances to switch, then I must think of it as safe? Or what if the internet is disconnected? I have asked myself this question for a long time. In fact, it can be done. Before quantum computers are popularized, all I need to do is implement network security well. But ... this ESP32 has insufficient support for TLS encryption and decryption, memory and computing power are limited. So in the future, the server will move to the small box of Raspberry Pi 4 and be placed in the same local network as the smart plug socket, which will be more secure. If I want to connect remotely, I can use SSH Tunneling around the world.

1590736171313.png



The following figure is the flow chart of each manual switch. Status/# is sent by the socket and received by the server, and cmd /# is sent by the server in reverse, and received by the socket. This can synchronize the state of the switchs.

1590736171366.png




The picture below is a recorder of power consumption and reset the cumulative power consumption

1590736171418.png


The following pictures are various macros
  • Feeding
    • Suspend return pump 5, powerhead 4, skimmer 6 for 10 minutes
  • Change the water
    • Suspend return pump 5, powerhead 4, skimmer 6 for 10 minutes
  • Suspend skimmer 6 for 2 hours

1590736171472.png


Finally, this is my 40 gallon tank power consumption
  • Chiller: 327W during compressor operation (only 0.7W power consumption during standby)
  • HQI main light: 148W
  • Refugium light 16W
  • Exhaust fan 36W
  • Powerhead 3W
  • Skimmer 14W
  • Return Pump 21W
24-hour power consumption: 4.47 kWh (data for 5/28, rainy and rainy days).
 
OP
OP
samuel.chiang

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
After 9 months using breadboard as prototype...
breadboard_prototype.jpg


Finally I assemble everything into a case.
IMG_8459.jpg

There are two TRS connectors for DS18B20 temperature sensor. One for water temperature, another for room temperature.
IMG_8460.jpg

IMG_8465.jpg
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Nice. Looking good :)
I think the TRS connectors short +/GND when the male connector is plugged or unplugged. This caused power cycle when we use it with raspberry Pi. Some folks (reef-pi users) moved to aviation connectors. I still use the standard TRS connector, and make sure im not plugging/unplugging when the unit is powered up. I wonder if you encounter the same issue as well
 
OP
OP
samuel.chiang

samuel.chiang

New Member
View Badges
Joined
Oct 3, 2019
Messages
7
Reaction score
13
Rating - 0%
0   0   0
Nice. Looking good :)
I think the TRS connectors short +/GND when the male connector is plugged or unplugged. This caused power cycle when we use it with raspberry Pi. Some folks (reef-pi users) moved to aviation connectors. I still use the standard TRS connector, and make sure im not plugging/unplugging when the unit is powered up. I wonder if you encounter the same issue as well
Hi Ranjib. First of all, I would like to thank Reef-Pi for this project, which inspired me a lot.
I don't encounter the same issue.
However for TRS, I think it's not waterproof.
I have tried aviation connectors (SP13) for another project, it's pretty good.
ivan.jpg
 
Back
Top