[SOLVED] Nextion 3.2 touch. two digits 24h Digital clock with RTC 1307 and DHT22

i was really struggling with this one. used tons of displays and i got most of the working fine. but. with nextion. there was a poroblem, since the RTC module i used ds1307 made strings 1 % 2. not 01 % 02. And since the nextion displays are a bit different there it was really tricky.

Usually you just print a extra zero before the single numbers with a small void. but that didnt work here.

myNextion.setComponentText("fukt", String(event.relative_humidity)); this is how you send info. it becomes something like 37,4 since the dht22 deliver that.

but the constant two digifts i had to do this, after trying about 10 other things....

if (tm.Hour == 1) {myNextion.setComponentText("tim","01");}
if (tm.Hour == 2) {myNextion.setComponentText("tim","02");}
if (tm.Hour == 3) {myNextion.setComponentText("tim","03");}
if (tm.Hour == 4) {myNextion.setComponentText("tim","04");}
if (tm.Hour == 5) {myNextion.setComponentText("tim","05");}
if (tm.Hour == 6) {myNextion.setComponentText("tim","06");}
if (tm.Hour == 7) {myNextion.setComponentText("tim","07");}
if (tm.Hour == 8) {myNextion.setComponentText("tim","08");}
if (tm.Hour == 9) {myNextion.setComponentText("tim","09");}
if (tm.Hour > 9) {myNextion.setComponentText("tim", String(tm.Hour));}

and the same for minute, month and date, year is printed 2018 as standard.

Nextion_32_RTC_2digit_DHT22.ino (3.9 KB)

Nextion_32_RTC_2digit_DHT22.ino (3.9 KB)