Merging pieces of code fails

Hello,

First I need to say that I’m a noob in programming, so have patience.

I want to build a small wether station based on an Arduino UNO R3 and a couple of sensors that will display the values on a 1602 LCD display (I2C interface). |The sensors I’m using are a DHT22 for temperature and humidity and a BMP280 (I2C interface) for atmospheric pressure.
For this I used sketches found online that I have edited to mach my requirements. So far all is working good.

However, I wanted to also add a clock to my small project using an rtc ds3231 (I2C interface) and a TM1637 display.

After putting together some code for the clock part, I tested and is working fine. After this I wanted to combine the two project parts. I hooked all the components together and I tested by uploading each part of the code individually. Again all was working just fine.

The last part was to merge the code so I have all the components working on the same time. Here I hit a lot of problems related to the code. Even if it compiles only with some warnings after uploading nothing will work anymore. I’m not sure if the problem is in the code itself when it’s put together or if in the way I have merged it.

I have attached all the versions of the code, maybe you can point me in the right direction.

Thank you!

01_Functional code for sensors and 1602 display.txt (2.57 KB)

02_Functional code for watch only.txt (1.52 KB)

03_Draft for sensors and warch, together.txt (3.82 KB)

I'm guessing you added that last ~20 lines to 03_Draft... because that code doesn't even compile and everything before that looks good.

First off, you need to declare your variables 'hh' and 'mm' (probably as int)
Second, you should really use curly braces with your if() statements since it appears your else clause is multiple lines, but only the first one is really part of your if/else. If you auto format inside the IDE (Ctl-T), you will see what I mean. Here's the last little bit cleaned up

  int hh = now.hour();
  int mm = now.minute();

  tm1637.point(POINT_ON);
  if ((hh / 10) == 0) {
    tm1637.display(0, 17);
  } else {
    tm1637.display(0, hh / 10);  // hour
    tm1637.display(1, hh % 10);
    tm1637.display(2, mm / 10); // minutes
    tm1637.display(3, mm % 10); //
  }
  delay(500);
  tm1637.point(POINT_OFF);
  if ((hh / 10) == 0) {
    tm1637.display(0, 17);
  } else {
    tm1637.display(0, hh / 10);  // hour
    tm1637.display(1, hh % 10);
    tm1637.display(2, mm / 10); // minutes
    tm1637.display(3, mm % 10); //
  }
  delay(500);

And finally, read the intros to this group and use code tags for your code rather than attaching them. It makes it easier for people to actually help you.

Thanks a lot for the help. I'll give it a try later.
Regarding the code tags I'll use them from now on.

Best!

Update:

I have tested and the code is still not working. What I have found out is that there is a single command that is causing the issue and that command is tm1637.display. Everythink works without it but is I use that one just a single time everything breaks.
I think that there myght be an incompatibility between the libraries (I'm not even sure if that's possible.

Any other thoughts from you guys?

Thanks!

the tm1637.display function takes either one or two arguments. If you post your code that doesn't work, we could look at it and possibly identify the problem rather than guess