Aquarium controller. Separate parts work, combining them doesn't?

Hello guys,

In order to give you some idea of my problem, my learning process and what I tried, let me explain. Hopefully its not too long...

For the last 2 months i've been busy building my aquarium computer. Since many others have made this, I've tried to copy as much from other projects. Maybe some know the Iaqua project. Mine however, will be simpler. The idea is to have a simple interface in which I can control my temperature and pH/CO2 through a 3.2'' TFT.

Since i'm new to Arduino i've started easy with some led tutorials and 16x2 LCD tutorials with an Arduino Uno. Next step was to make my DS18B20 temp sensor work on the 16x2 LCD, together with time (DS3231). That worked, however, after a while the LCD started showing weird characters. Tried to solve that, but did not succeed.

Since this was part of my learning progress in understanding Arduino I decided to stop trying to fix something that would probably not be a problem on a TFT screen and move on to the next stage: making my pH sensor work. That worked and using calibration buffer solutions I calibrated my pH sensor in the serial monitor.

Since i wanted to control temperature and my pH via CO2, I needed to be able to turn them on and off, depending on the sensor readings. Therefore I needed to understand how relays work. So, figured that out with a simple led setup, which wasn't to hard compared to some previous strugles.

Next stage was to learn how to use the TFT screen, touch and SD card slot. Switched from an Uno to a Mega because of the TFT. Took me a while to find the right library for SD card and what screenname I should use in the arduino code (ILI9341_16) for my TFT. It appeared I got the wrong TFT shield, which took me a while to realise lol :grinning: Got a new one and got everything to work. Ok, when i figured that all out I tried some tutorials like the Button tutorial.

Then I started to develop the layout of the screens. Just a 'homescreen' with time, temperature and pH readings and a 'Settings button'. The setting button brings me to my settings menu in which i can choose between Temperature and pH or go back to homescreen. Temperature and pH setting screen are both the same in which i want to show the current temp/pH and a temp/pH-threshold i can set to turn on the heator or CO2. This worked partly. I could jump through the different screens, but was not able to set the temp/pH treshold the way it should. I could change the value, but it would not show the new setting unless i got back a page and re-entered the settingscreen of either temperature or pH.

Ok, so on this moment I got all my seperate projects parts to work (except for the temp/pH setting):

  • I know how my temp sensor works and how to get readings on LCD and serial monitor,
  • I know how my pH sensor works and how to get readings on serial monitor,
  • I know how to get the time on LCD and serial monitor,
  • I know how my TFT and touch screen work.

So, I figured I should still continue simple, integrating one part at a time, using the working codes i already got.

However, here is were I cant figure out how to continue. First, displaying time on TFT, using the DS3231 library. No success. I tried different libraries, still no success. Took me a couple of days before I decided to park this problem and continue with other parts. pH i get to work, partly. It shows on the homescreen, but wont update. My temperature worked, then it stopped. I did not even got my temperature, time or pH to read in the serial monitor :fearful: :cry: Also, at some point my touch screen doens't work anymore and i cannot get through my menu. When i reload the Button-example, my touch screen does work?

So, back to the basics and retried everything on the Uno. On the Uno i CAN read my time/temp and pH through serial. At this point im stuck and I don't know what to test/try anymore. I even ordered a second Mega (since the first one was quite old and i got it from a friend, thought it might somehow be broken), but it didnt help.

I've been google-ing on these problems for a few weeks now, trying to get it to work. I just can't stand it that i seem unable to figure this out. However, i have to admit now that i am stuck and unable to figure it out without help. So, I really hope someone here has some idea how to continue?

Since my text with code is too long for a post, I'll place the code in the next post.

[edit] hm, my code exceeds the max of 9000 characters. I'll try posting in multiple posts i guess...not sure if that is nessecary.

douPel:
However, here is were I cant figure out how to continue. First, displaying time on TFT, using the DS3231 library. No success.

Sounds like another piece that needs to be debugged first and working for integration.

.

ieee488:
Sounds like another piece that needs to be debugged first and working for integration.

.

Your absolutely right. However, how come that using the same code on an Arduino Uno and Mega, i can read the time through serial monitor on the Uno, but not on the Mega? Is there a difference in programming between the Uno and Mega that I am not aware of?

[edit] code:

#include <DS3231.h>


// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);


void setup() {
    
  rtc.begin();
  Serial.begin(115200);
 
  //rtc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(10, 49, 20);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(21, 3, 2018);   // Set the date to January 1st, 2014
}

void loop() {


//Serialmonitor. Verwijder // bij void setup. De bautraid van 9600 kan niet samen openstaan met het lcd, dan werkt het lcd niet.      
  Serial.print("Tijd: ");
  Serial.println(rtc.getTimeStr()); 

  delay(1000);

}

i can read the time through serial monitor on the Uno, but not on the Mega?

You can't read something on the serial monitor that the Arduino didn't write. It is silly to talk about what YOU can, or can not do. We are here to help you with what the Arduino can, or can not, do. SO, describe THAT.

You are aware, aren't you, that the SDA and SCL pins are in different places on the Mega and the UNO?

Check that ds3231 for the kinda battery it has. Cr's are not rechargeable and if your module has a charge circuit it could blow up.

Sorry for the late reply! Thank you for your suggestions guys.

PaulS:
You can't read something on the serial monitor that the Arduino didn't write. It is silly to talk about what YOU can, or can not do. We are here to help you with what the Arduino can, or can not, do. SO, describe THAT.

Haha, yes, ofcourse. I did not realise that :slight_smile:

You are aware, aren't you, that the SDA and SCL pins are in different places on the Mega and the UNO?

I am aware of that. Still, both on the Uno and Mega, the pins are named SDA and SCL.

jokefox:
Check that ds3231 for the kinda battery it has. Cr's are not rechargeable and if your module has a charge circuit it could blow up.

I did replace the battery at some point. Since the RTC did not continue the time from what I set it, I figured the battery must be dead and thus replaced it. Following Paul's earlier comment, I should say that the Uno can still output the right time of the DS3231 in serial monitor, while the Mega can not. So I think it's safe to say that the battery is not the problem.

[edit] I feel like a complete idiot :-[ !!!!! . Since the Mega was pretty cramped with the TFT screen, and all my switching and hassling around with the sensors, I powered and grounded my prototype board with pH and DS3231 via my Uno and ran the SDA and SCL wires to the Mega. For some reason I did not think it would really make any difference. At the same time I don't know why I did not try it, just to eliminate the possibility of it being the solution or not... Now that I powered and grounded the DS3231 through the Mega, the Mega does output the time in the Serial monitor. :stuck_out_tongue_closed_eyes: I hope you can laugh at this noobie-mistake instead of writing me off like a hopeless case, i've been scratching my head for three weeks lol.