DIY AI-coded ESP32 based aquarium controller

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
Hello all,

I am in the process of setting up a new tank (120 x 50 x 40 cm) (approximately 48 " by 20" by 16"). As part of the preparation, I want to make my own aquarium controller using an ESP32. My coding skills are limited, so I went ahead and talked with our dear friend ChatGPT until I got a working sketch. I'm fairly happy with the result so far, but I'm sure the code can be optimized a lot. For instance, I am looking into splitting the code in different files.

At the moment the controller does the following:
Features:

  • Auto-top off based on three float switches (low switch, high switch and reservoir switch) and timer functions
Monitoring:

  • 3 Dallas ds18b20 probes for temperature monitoring (Sump, Display tank and room temperature)
  • 1 analog pH sensor module (ph-4502c), with calibration option
Control:

  • 12 relay control
Webserver:

  • Simple webpage displaying sensor readings, relay control buttons and pH calibration option
Schermafbeelding 2024-10-18 204259.jpg


E-mail allert:

  • Automatic e-mail alert when ATO reservoir is low

Any input and/or help is greatly appreciated!

Github page: https://github.com/Odaller/ESP32Reefcontroller
 
OP
OP
R

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
hey @Mark Whitaker, thank you. Any general advice is appreciated, like how to make the code more performative - I have the feeling that it's quite bulky now. But if it works...

Or suggestions to add stuff?
 
OP
OP
R

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
[UPDATE]:
Added a DHT sensor to monitor room temperature and humidity.

Added extra safety feature for ATO pump: shuts off after 1 minute runtime and has to be manually reset using a button on the webpage.

Added extra warning e-mails for each error: ATO reservoir low, Pump runtime exceeded. Possible to add more if needed (e.g. temperature or pH range warnings).
 

sloppy

New Member
View Badges
Joined
Nov 14, 2024
Messages
2
Reaction score
0
Location
USA
Rating - 0%
0   0   0
What ESP32 board are you using, I have been wanting to build something like this for a while. Want to integrate it in to home assistant.

Can you list all your hardware and where you got it form?
Do you know if there is a sensor for salinity?
 
OP
OP
R

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
What ESP32 board are you using, I have been wanting to build something like this for a while. Want to integrate it in to home assistant.

Can you list all your hardware and where you got it form?
Do you know if there is a sensor for salinity?
At first I used something like this: https://devices.esphome.io/devices/AC-DC-ESP32-Relay-x4
But I'm going to switch to a MH-ET live mini kit because of the smaller footprint. I'm not going to use 12 relays, so it's OK.
Maybe I'm going to use a ESP32-S3 version, but then the code will need to be adapted I think.

I still need to solder everything together, but most parts are sourced via Aliexpress or Banggood or other similar sites.

When everything is soldered together, I'm going to write up a BOM and post it here. I'm thinking about home assistant too - then the code will need to change I guess. For now, it's a standalone controller.

I looked for a salinity sensor as well. This one seems to be OK: https://www.dfrobot.com/product-1797.html
But those sensors are quite sensitive for electrical currents, and I don't think it will be useful to keep in the tank full time. Salinity is not very volatile anyway, so I would not use it.
 

sloppy

New Member
View Badges
Joined
Nov 14, 2024
Messages
2
Reaction score
0
Location
USA
Rating - 0%
0   0   0
Do you think the relay board will handle the current of heaters? It says ten amps but I wonder how long they will last.
Im sure someone has tested them.
 
OP
OP
R

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
I have not tested them myself. I connect my appliances through the "normal closed" loop. This way the relay only needs to be triggered if you want to switch something off. Heaters are normally continously on, and use their internal thermostat to regulate them. I would only use the relay to cut them off if the temperature keeps rising uncontrollably - which would seem as a heater failure.
 

shoedy

Community Member
View Badges
Joined
Jun 10, 2022
Messages
64
Reaction score
12
Location
Amsterdam
Rating - 0%
0   0   0
If you want to build your own aquarium controller, you'd be much better off to use a combination of Home Assistant with the Esphome addon and using the esp32 devices for sensor interfacing. It is a lot more powerful that way, with the added benefit of having web and mobile clients.
 
OP
OP
R

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
If you want to build your own aquarium controller, you'd be much better off to use a combination of Home Assistant with the Esphome addon and using the esp32 devices for sensor interfacing. It is a lot more powerful that way, with the added benefit of having web and mobile clients.
Yes, that's my next goal. I have to get started with Home Assistant first. In the meantime, this small controller will do.
 

Bio

New Member
View Badges
Joined
Sep 23, 2023
Messages
8
Reaction score
2
Location
usa
Rating - 0%
0   0   0
I tried using the standalone relay boards but wanted power monitoring the approach i took was using the sonoff s31. I flashed them with esphome and added them to home assistant that way you get full control and power monitoring and they have a 15 amp relay in them.
https://www.home-assistant.io/
 

kboogie

Well-Known Member
View Badges
Joined
Aug 6, 2021
Messages
879
Reaction score
553
Location
Boynton Beach
Rating - 0%
0   0   0
If you want to build your own aquarium controller, you'd be much better off to use a combination of Home Assistant with the Esphome addon and using the esp32 devices for sensor interfacing. It is a lot more powerful that way, with the added benefit of having web and mobile clients.
I kind of do this. I use Home Assistant and some smart strips and a few zigbee and BLE sensors. I haven't integrated probes with an ESP32 but I have several spares laying around so I might try.
 
OP
OP
R

Ronnyking

Community Member
View Badges
Joined
Feb 9, 2017
Messages
44
Reaction score
37
Rating - 0%
0   0   0
I tried using the standalone relay boards but wanted power monitoring the approach i took was using the sonoff s31. I flashed them with esphome and added them to home assistant that way you get full control and power monitoring and they have a 15 amp relay in them.
https://www.home-assistant.io/
What do you use as the main server? A raspberry pi?
 

Bio

New Member
View Badges
Joined
Sep 23, 2023
Messages
8
Reaction score
2
Location
usa
Rating - 0%
0   0   0
What do you use as the main server? A raspberry pi?
I run home assistant on unraid in a vm but will be moving it onto its own system later on but not a raspberry pie. i use esp32 boards for my controllers
Screenshot from 2024-11-23 21-08-14.png
 
Last edited:

TOP 10 Trending Threads

HOW DO YOU ADJUST YOUR CUC AS ALGAE DISAPPEARS?

  • Capture and re-home CUC

    Votes: 4 6.3%
  • Increase white light/hours in tank to spur algae growth to feed CUC

    Votes: 5 7.9%
  • Feed nori to support CUC

    Votes: 25 39.7%
  • Feed herbivore pellets to support CUC

    Votes: 19 30.2%
  • Allow attrition to balance CUC and algae

    Votes: 29 46.0%
  • Provide macro algae to feed CUC

    Votes: 6 9.5%
  • Introduce CUC predators

    Votes: 1 1.6%
  • Other (please explain)

    Votes: 5 7.9%

New Posts

Back
Top