Aquarium Controller questions - approach?

Hi Friends,

So - I'm trying to make a simple (I think?) aquarium controller.

I would like it to turn the lights on and off using a set of relays (via an RTC module) at a specific time while also measuring aquarium temperature (via a DS18B20), flow rate (via a Hall Sensor from Digiten) and possibly pH. I would like the sensors to display on a 16x4 LCD.

I have a little bit of experience with arduino and programming. I have gotten okay with millis and understand that delay is the worst thing in the world.

What I am having trouble with is how to run the timer code while getting and displaying the info from the sensors. The multitasking is hurting my brain.

I am not asking anyone to code for me, but if someone was willing to point me in the right direction, I would love them forever. Should I start figuring out interrupts? What is the path forward?

Thanks in advance. I love this community and have learned a lot from all you fun people.

What I am having trouble with is how to run the timer code while getting and displaying the info from the sensors.

That is the purpose of the loop() function. Each time through loop() the code checks whether it is time to do something and if so then it does it, reads the sensors etc, etc. It does not hang about waiting for something to happen.

Take a look at the examples in Several things at the same time

millis() will give you the time in milliseconds.
You must declare a long integer variable by "long timerStart = millis();" when you start the timer.
then in the function loop you must use this like if statement: "if (millis()-timerStart > 3000)" millis()-timerStart gives you the time passed from you declare timerStart valuable in milliseconds, 3000 means 3 seconds you can change it. But don't forget to NOT declare the timerStart in the loop functions first part and if you want to restart the timer instantly when the timer ends you must "timerStart = millis()" in the if statement. If you don't want to restart the timer you must "timerStart = 100000000" to avoid if statement repeats in every loop.

You must declare a long integer variable by "long timerStart = millis();" when you start the timer.

It would be better to use an unsigned long for all timing variables because they will never be negative and that is what millis() returns.

Hi

Don’t confused yourself with milis.
In your poject I dont think you need it.

use code like if time is this then turn off light
if temp is > 30 then do this.

As a new start do 1 thing 1 at a time when you see things working then add another function. To start with, try DS18B20, this will help you understand more as I assume you would add a relay as well.

Google around there are many Arduino Aquarium controller projects out there.
Some are even available for purchase as a kit.
Some use a text LCD display, some use a graphic LCD, some use WiFi for a web interface.
I would look at some of those and start with the one that is closest to what you want to do.

--- bill