0"96 OLED Screen doesn´t show anything

Hello everyone,
My problem is that my screen shows everything when I upload this code below but doesn´t show any data when I try to upload my 2nd code I posted. The main difference between the 2 codes is that 1st shows data in intervals( changes states) and 2nd code changes states when button is pushed. Both codes worked before but now the 2nd stopped suddenly

1st code that works on screen is in attachments because the message is too long otherwise

2nd code that doesnt work on screen:

#include "Adafruit_Sensor.h"
#include "Adafruit_BMP280.h"
#include "Arduino.h"
#include "DHT.h"
#include "U8g2lib.h"
#include "RTClib.h"
#include "nRF24L01.h"
#include "RF24.h"
#include "JC_Button.h"

RTC_DS3231 rtc;

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10 
#define DHTPIN 2     
#define DHTTYPE DHT22

Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);
int temt6000Pin = 0;

const byte
pin_SW1 = 3;
Button myButton(pin_SW1, 20, true, true);

int nSW1_state = 0;
int menu_state = 0;
int draw_state = 0;
unsigned long previousMillis = 0;
long interval = 3000;

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

char daysOfTheWeek[7][12] = {"Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Cetvrtak", "Petak", "Subota"};
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
const int pinCE = 7;
const int pinCSN = 8;
RF24 radio(7, 8);
byte address [5] = "00001";

struct package
{
  float temperature;
  float pressure;
  float humidity ;
  float light;
};
typedef struct package Package;
Package data;


void setup(){
  u8g2.begin();
  myButton.begin();

  Serial.begin(9600);
  rtc.begin();
  dht.begin();
  
  
  bmp.begin();
  radio.begin();
  radio.setChannel(150);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
}
void loop() {
  unsigned long currentMillis = millis();
  if (radio.available())
  {
    radio.read(&data, sizeof(data));
  }
  nSW1_state = digitalRead(pin_SW1);
  myButton.read();
  if (myButton.wasPressed() ) {
    u8g2.firstPage();
    do {
      switch (menu_state)
      {
        case 1: drawIndoor(); Serial.println("indoor"); break;
        case 2: drawOutdoor(); Serial.println("outdoor"); break;
        case 3: drawDate(); Serial.println("date"); break;
        default:  drawIndoor(); break;
      }
    } while (u8g2.nextPage());
    if (nSW1_state == LOW) {
      (menu_state < 3) ? menu_state++ : menu_state = 0;
    }
  }
  else if ( myButton.pressedFor(3000) ) {
    if (currentMillis - previousMillis > interval) {
      previousMillis = currentMillis;
      do {
        Serial.print("loop");
        switch (draw_state)
        {
          case 0: drawIndoor(); break;
          case 1: drawOutdoor(); break;
          case 2: drawDate(); break;
        }
      }
      while (u8g2.nextPage() );
      draw_state++;
      if (draw_state > 2) {
        draw_state = 0;
      }}}}
void drawIndoor(void) {
  float volts = analogRead(A0) * 5.0 / 1024.0;
  float amps = volts / 10000.0;
  float microamps = amps * 1000000;
  float lux = microamps * 2.0;

  int value = analogRead(temt6000Pin);

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.setCursor(30, 9);
  u8g2.print("Unutarnja");

  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.setCursor(0, 23);
  u8g2.print("T= ");
  u8g2.print(dht.readTemperature());
  u8g2.print(" *C");

  u8g2.setCursor(0, 37);
  u8g2.print("H= ");
  u8g2.print(dht.readHumidity());
  u8g2.print(" %");

  u8g2.setCursor(0, 51);
  u8g2.print("P= ");
  u8g2.print(bmp.readPressure() / 100);
  u8g2.print(" hPa");

  u8g2.setCursor(0, 65);
  u8g2.print("L= ");
  u8g2.print(lux);
  u8g2.print (" lx");
}

void drawDate()
{
  DateTime now = rtc.now();
  u8g2.setFont(u8g2_font_helvR14_tf);
  u8g2.setCursor(20, 14);
  u8g2.print(now.day(), DEC);
  u8g2.print(".");
  u8g2.print(now.month(), DEC);
  u8g2.print('.');
  u8g2.print(now.year(), DEC);
  u8g2.print('.');
  u8g2.setCursor(20, 60);
  u8g2.print(daysOfTheWeek[now.dayOfTheWeek()]);
  u8g2.setCursor(20, 42);
  u8g2.print(now.hour(), DEC);
  u8g2.print(':');
  u8g2.print(now.minute(), DEC);

}
void drawOutdoor() {
  if (radio.available()) {
    radio.read(&data, sizeof(data));
  }

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.setCursor(30, 9);
  u8g2.print("Vanjska");

  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.setCursor(0, 23);
  u8g2.print("T= ");
  u8g2.print(data.temperature);
  u8g2.print(" *C");

  u8g2.setCursor(0, 37);
  u8g2.print("H= ");
  u8g2.print(data.humidity);
  u8g2.print(" %");

  u8g2.setCursor(0, 51);
  u8g2.print("P= ");
  u8g2.print(data.pressure);
  u8g2.print(" hPa");

  u8g2.setCursor(0, 65);
  u8g2.print("L= ");
  u8g2.print(data.light);
  u8g2.print (" lx");
}

Unutarnje_mjerenje.ino (4.37 KB)

 u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.setCursor(0, 23);
  u8g2.print("T= ");
  u8g2.print(dht.readTemperature());
  u8g2.print(" *C");

for this bit of the sketch, try

u8g2.setCursor(10,10); u8g2.print("T= "); u8g2.setCursor(10,50); // move the second number to align with the T= u8g2.print(dht.readTemperature()); u8g2.setCursor(10,70); u8g2.print(" *C");

If I am not mistaken, you the first number is the stating column of the text the second number is pixels down from the top.

second, you need to state the cursor point for each thing.

also, if the call to get the temperature does not work, put it into a float before you call the OLED.

if this works it might look like

T- 23.6 *C

if you get the display to put up these, then try

u8g2.setCursor(10,10); u8g2.print("T= "); u8g2.setCursor(50,10); // move the second number to align with the T= u8g2.print(dht.readTemperature()); u8g2.setCursor(70,10); u8g2.print(" *C");

Still doesn´t work . The problem isnt in setCursor but in something else that I cannot figure out.
This is a code that displays data on screen but it doesn´t have commands that make pressing Button change screeens (menu)

#include "Adafruit_Sensor.h"
#include "Adafruit_BMP280.h"
#include "Arduino.h"
#include "DHT.h" 
#include "U8g2lib.h"
#include "RTClib.h"
#include "nRF24L01.h"
#include "RF24.h"

RTC_DS3231 rtc;

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11 
#define BMP_CS 10 
#define DHTPIN 2     
#define DHTTYPE DHT22 

Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);
int temt6000Pin = 0;

int draw_state = 0;
unsigned long previousMillis = 0;
long interval = 5000;

#ifdef U8X8_HAVE_HW_SPI 
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif 

char daysOfTheWeek[7][12] = {"Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Cetvrtak", "Petak", "Subota"};

 
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);


const int pinCE = 7;
const int pinCSN = 8;

RF24 radio(7, 8);
byte address [5] = "00001";

struct package
{
  float temperature;
  float pressure;
  float humidity ;
  float light;
};
typedef struct package Package;
Package data;

const int buttonPin =3;
const int ledPin=4;

int buttonState = 0;         // current state of the button
 int push = 0;
 int prevbuttonState=0;

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
 
  Serial.begin(9600);
  rtc.begin();
   dht.begin();
  u8g2.begin();  
  u8g2.clear();
 if (!bmp.begin()) {  
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
   }
  radio.begin();
  radio.setChannel(150);
  radio.openReadingPipe(0,address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
}


  
 void loop(){
 
if(radio.available())
{
  radio.read(&data, sizeof(data));
}
 buttonState = digitalRead(buttonPin);
Serial.print("buttonState:");Serial.println(buttonState);

if (buttonState != prevbuttonState) {
  if(buttonState == HIGH){
    push=push+1;
    delay(10);
  }
}
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    u8g2.firstPage();
  do{
     switch (draw_state ) {
     if(push==1){
  case 0: drawOnlyDate();
  break;
     }
     else if(push==2){
  case 1: drawOnlyIndoor();
  break;
     }
     else if(push>=3){
  case 2: drawOnlyOutdoor();
  break;
     }
     push = 0;
     }
  } while ( u8g2.nextPage() );
    draw_state++;
    if(draw_state >2){
      draw_state=0;
    }
  }
  }




void drawOnlyDate(void)
{
  DateTime now = rtc.now();
  u8g2.setFont(u8g2_font_helvR14_tr);
    u8g2.setCursor(20,14);
    u8g2.print(now.day(), DEC);
    u8g2.print(".");
    u8g2.print(now.month(), DEC);
    u8g2.print('.');
    u8g2.print(now.year(), DEC);
    u8g2.print('.');
    
    u8g2.setCursor(23,60);
    u8g2.print(daysOfTheWeek[now.dayOfTheWeek()]);
    u8g2.setFont(u8g2_font_helvB24_tn);
    u8g2.setCursor(28,42);
    u8g2.print(now.hour(), DEC);
    u8g2.print(':');
    u8g2.print(now.minute(), DEC);

}
void drawOnlyIndoor(void) {
   float volts = analogRead(A0) * 5.0 / 1024.0;
float amps = volts / 10000.0; 
float microamps = amps * 1000000;
float lux = microamps * 2.0;

  int value=analogRead(temt6000Pin);

u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.setCursor(30, 9);
  u8g2.print("Unutarnja");
  
  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.setCursor(0, 23);
  u8g2.print("T= "); 
  u8g2.print(dht.readTemperature()); 
  u8g2.print(" *C");
  
  u8g2.setCursor(0, 37);
  u8g2.print("H= "); 
  u8g2.print(dht.readHumidity()); 
  u8g2.print(" %");
  
  u8g2.setCursor(0,51);
  u8g2.print("P= ");
  u8g2.print(bmp.readPressure()/100);
  u8g2.print(" hPa");
  
u8g2.setCursor(0, 65);
   u8g2.print("L= "); 
  u8g2.print(lux); 
  u8g2.print (" lx");
}

void drawOnlyOutdoor(void){
  if(radio.available()){
radio.read(&data, sizeof(data));
}

u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.setCursor(30, 9);
  u8g2.print("Vanjska");
  
  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.setCursor(0, 23);
  u8g2.print("T= "); 
  u8g2.print(data.temperature); 
  u8g2.print(" *C");
  
  u8g2.setCursor(0, 37);
  u8g2.print("H= "); 
  u8g2.print(data.humidity); 
  u8g2.print(" %");
  
  u8g2.setCursor(0,51);
  u8g2.print("P= ");
  u8g2.print(data.pressure);
  u8g2.print(" hPa");
  
u8g2.setCursor(0, 65);
   u8g2.print("L= "); 
  u8g2.print(data.light); 
  u8g2.print (" lx");

}

I only use u8g2.print() for variables. I use

usg2.drawStr(x,x, “txt”); for strings.

u8g2.firstPage()[
do{
  u8g2.drawStr(0,65,"L= "); 
  u8g2.setCursor(20,65);
  u8g2.print(lux); 
  u8g2.drawStr(50,65," lx");
}
while (u8g2.nextPage() ) ;

it came out a little nicer : 25 and 65

u8g2.drawStr(0, 37,"H= "); u8g2.setCursor(25, 37); u8g2.print(dht_rh); u8g2.drawStr(65, 37," %");

void drawOnlyIndoor(void) {
float volts = analogRead(A0) * 5.0 / 1024.0;
float amps = volts / 10000.0;
float microamps = amps * 1000000;
float lux = microamps * 2.0;

  int value=analogRead(temt6000Pin);

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.drawStr(30, 9, "Unutarnja");

  u8g2.setFont(u8g2_font_helvB12_tf);}
void drawOnlyIndoor(void) {
float volts = analogRead(A0) * 5.0 / 1024.0;
float amps = volts / 10000.0;
float microamps = amps * 1000000;
float lux = microamps * 2.0;

  int value=analogRead(temt6000Pin);

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.drawStr(30, 9, "Unutarnja");

  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.drawStr(0, 23, "T= ");
  u8g2.setCursor(15, 23);
  u8g2.print(dht.readTemperature());
  u8g2.drawStr(30,23, " *C");

  u8g2.drawStr(0, 37,"H= ");
  u8g2.setCursor(20, 37);
  u8g2.print(dht.readHumidity());
  u8g2.drawStr(50, 37" %");

  u8g2.drawStr(0,51,"P= ");
  u8g2.setCursor(20,51);
  u8g2.print(bmp.readPressure()/100);
  u8g2.drawStr(50,51, " hPa");

  u8g2.drawStr(0, 65, "L= ");
  u8g2.setCursor(20, 65);
  u8g2.print(lux);
  u8g2.drawStr (50,65, " lx");

}

upon further review.

move the do{ and the }while out of the switch case and put then at the beginning (and end) of the call to write to the display in each function for the display.

you should add // this might be your problem with it not responding to button presses

prevbuttonState = buttonState ; //set prevbuttonState for next time through the loop. } // end void loop

so that the next loop though you compare the old button state.

for

void drawOnlyOutdoor(void){ if(radio.available()){ radio.read(&data, sizeof(data)); }

this might be better off to send an error if the radio is not available. ??

Thank you so much, it worked!
Now I have another thing that I wanted to try but it doesn´t quite work.So my idea is to make data show like this after pressing the button every time :
1.Indoor
2.Outdoor
3.Date
4. All that in loop with 5 sec delay

buuut the problem is that on the Loop part it only shows a small bottom part of the screen even though I can see that the data is changing from indoor->outdoor->date
Any ideas how to fix? this is the code

#include "Adafruit_Sensor.h"
#include "Adafruit_BMP280.h"
#include "Arduino.h"
#include "DHT.h"
#include "U8g2lib.h"
#include "RTClib.h"
#include "nRF24L01.h"
#include "RF24.h"
#include "JC_Button.h"

RTC_DS3231 rtc;

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10 
#define DHTPIN 2     
#define DHTTYPE DHT22

Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);
int temt6000Pin = 0;

const byte 
pin_SW1 = 3;
Button myButton(pin_SW1, 20, true, true);

int nSW1_state = 0;
int menu_state = 0;
int draw_state = 0;
unsigned long previousMillis = 0;
long interval = 3000;

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

char daysOfTheWeek[7][12] = {"Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Cetvrtak", "Petak", "Subota"};


U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

const int pinCE = 7;
const int pinCSN = 8;
RF24 radio(7, 8);
byte address [5] = "00001";

struct package
{
  float temperature;
  float pressure;
  float humidity ;
  float light;
};
typedef struct package Package;
Package data;


void setup() {
  myButton.begin();

  Serial.begin(9600);
  rtc.begin();
  dht.begin();
  u8g2.begin();
  u8g2.clear();
  bmp.begin();
  radio.begin();
  radio.setChannel(150);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
}
void loop() {
  unsigned long currentMillis = millis();

  if (radio.available())
  {
    radio.read(&data, sizeof(data));
  }

  nSW1_state = digitalRead(pin_SW1);
  myButton.read();

  if (myButton.wasPressed() ) {

    u8g2.firstPage();
    do {
      switch (menu_state)
      {
        case 1: drawIndoor(); Serial.println("indoor"); break;
        case 2: drawOutdoor(); Serial.println("outdoor"); break;
        case 3: drawDate(); Serial.println("date"); break;
        case 4:  
        unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    u8g2.clear();
    u8g2.firstPage();
        do {
      switch (menu_state)
      {
        case 0:drawIndoor(); u8g2.clear();break;
         case 1: drawOutdoor(); break;
         case 2: drawDate(); break;
         default:  drawIndoor();  break;
         }
        } while (u8g2.nextPage());
         draw_state++;
    if (draw_state > 2) {
      draw_state = 0;}}break;
        default:  drawIndoor(); break;
      }
    } while (u8g2.nextPage());
    if (nSW1_state == LOW) {
      (menu_state < 4) ? menu_state++ : menu_state = 0;
    }

  }
  else if ( myButton.pressedFor(3000) ) {
    if (currentMillis - previousMillis > interval) {
      previousMillis = currentMillis;

      do {
        Serial.print("loop");
        switch (draw_state)
        {
          case 0: drawIndoor(); break;
          case 1: drawOutdoor(); break;
          case 2: drawDate(); break;
        }
      }
      while (u8g2.nextPage() );
      draw_state++;
      if (draw_state > 2) {
        draw_state = 0;
      }

    }
  }
}

void drawIndoor(void) {
float volts = analogRead(A0) * 5.0 / 1024.0;
float amps = volts / 10000.0;
float microamps = amps * 1000000;
float lux = microamps * 2.0;

  int value=analogRead(temt6000Pin);

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.drawStr(30, 9, "Unutarnja");
 
  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.drawStr(0, 23, "T= ");
  u8g2.setCursor(22, 23);
  u8g2.print(dht.readTemperature());
  u8g2.drawStr(59,23, " *C");
 
  u8g2.drawStr(0, 37,"H= ");
  u8g2.setCursor(22, 37);
  u8g2.print(dht.readHumidity());
  u8g2.drawStr(59,37, " %");
 
  u8g2.drawStr(0,51,"P= ");
  u8g2.setCursor(22,51);
  u8g2.print(bmp.readPressure()/100);
  u8g2.drawStr(68,51, " hPa");
 
  u8g2.drawStr(0, 65, "L= ");
  u8g2.setCursor(22, 65);
  u8g2.print(lux);
  u8g2.drawStr (68,65, " lx");
 
}

void drawDate(void)
{
  DateTime now = rtc.now();
  u8g2.setFont(u8g2_font_helvR14_tr);
    u8g2.setCursor(24,14);
    u8g2.print(now.day(), DEC);
    u8g2.print(".");
    u8g2.print(now.month(), DEC);
    u8g2.print('.');
    u8g2.print(now.year(), DEC);
    u8g2.print('.');
    
    u8g2.setCursor(23,60);
    u8g2.print(daysOfTheWeek[now.dayOfTheWeek()]);
    u8g2.setFont(u8g2_font_helvB24_tn);
    u8g2.setCursor(22,42);
    u8g2.print(now.hour(), DEC);
    u8g2.print(':');
    u8g2.print(now.minute(), DEC);
}
void drawOutdoor() {
  if (radio.available()) {
    radio.read(&data, sizeof(data));
  }

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.drawStr(30, 9, "Vanjska");

 u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.drawStr(0, 23, "T= ");
  u8g2.setCursor(22, 23);
  u8g2.print(data.temperature);
  u8g2.drawStr(59,23, " *C");

  u8g2.drawStr(0, 37,"H= ");
  u8g2.setCursor(22, 37);
  u8g2.print(data.humidity);
  u8g2.drawStr(59,37, " %");

  u8g2.drawStr(0,51,"P= ");
  u8g2.setCursor(22,51);
  u8g2.print(data.pressure);
  u8g2.drawStr(68,51, " hPa");

 u8g2.drawStr(0, 65, "L= ");
  u8g2.setCursor(22, 65);
  u8g2.print(data.light);
  u8g2.drawStr (68,65, " lx");

}

I have another thing that I wanted to try but it doesn´t quite work.So my idea is to make data show like this after pressing the button every time :
1.Indoor
2.Outdoor
3.Date
4. All that in loop with 5 sec delay

buuut the problem is that on the Loop part it only shows a small bottom part of the screen even though I can see that the data is changing from indoor->outdoor->date
Any ideas how to fix? this is the code

#include "Adafruit_Sensor.h"
#include "Adafruit_BMP280.h"
#include "Arduino.h"
#include "DHT.h"
#include "U8g2lib.h"
#include "RTClib.h"
#include "nRF24L01.h"
#include "RF24.h"
#include "JC_Button.h"

RTC_DS3231 rtc;

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10 
#define DHTPIN 2     
#define DHTTYPE DHT22

Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);
int temt6000Pin = 0;

const byte 
pin_SW1 = 3;
Button myButton(pin_SW1, 20, true, true);

int nSW1_state = 0;
int menu_state = 0;
int draw_state = 0;
unsigned long previousMillis = 0;
long interval = 3000;

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

char daysOfTheWeek[7][12] = {"Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Cetvrtak", "Petak", "Subota"};


U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

const int pinCE = 7;
const int pinCSN = 8;
RF24 radio(7, 8);
byte address [5] = "00001";

struct package
{
  float temperature;
  float pressure;
  float humidity ;
  float light;
};
typedef struct package Package;
Package data;


void setup() {
  myButton.begin();

  Serial.begin(9600);
  rtc.begin();
  dht.begin();
  u8g2.begin();
  u8g2.clear();
  bmp.begin();
  radio.begin();
  radio.setChannel(150);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
}
void loop() {
  unsigned long currentMillis = millis();

  if (radio.available())
  {
    radio.read(&data, sizeof(data));
  }

  nSW1_state = digitalRead(pin_SW1);
  myButton.read();

  if (myButton.wasPressed() ) {

    u8g2.firstPage();
    do {
      switch (menu_state)
      {
        case 1: drawIndoor(); Serial.println("indoor"); break;
        case 2: drawOutdoor(); Serial.println("outdoor"); break;
        case 3: drawDate(); Serial.println("date"); break;
        case 4:  
        unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    u8g2.clear();
    u8g2.firstPage();
        do {
      switch (menu_state)
      {
        case 0:drawIndoor(); u8g2.clear();break;
         case 1: drawOutdoor(); break;
         case 2: drawDate(); break;
         default:  drawIndoor();  break;
         }
        } while (u8g2.nextPage());
         draw_state++;
    if (draw_state > 2) {
      draw_state = 0;}}break;
        default:  drawIndoor(); break;
      }
    } while (u8g2.nextPage());
    if (nSW1_state == LOW) {
      (menu_state < 4) ? menu_state++ : menu_state = 0;
    }

  }
  else if ( myButton.pressedFor(3000) ) {
    if (currentMillis - previousMillis > interval) {
      previousMillis = currentMillis;

      do {
        Serial.print("loop");
        switch (draw_state)
        {
          case 0: drawIndoor(); break;
          case 1: drawOutdoor(); break;
          case 2: drawDate(); break;
        }
      }
      while (u8g2.nextPage() );
      draw_state++;
      if (draw_state > 2) {
        draw_state = 0;
      }

    }
  }
}

void drawIndoor(void) {
float volts = analogRead(A0) * 5.0 / 1024.0;
float amps = volts / 10000.0;
float microamps = amps * 1000000;
float lux = microamps * 2.0;

  int value=analogRead(temt6000Pin);

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.drawStr(30, 9, "Unutarnja");
 
  u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.drawStr(0, 23, "T= ");
  u8g2.setCursor(22, 23);
  u8g2.print(dht.readTemperature());
  u8g2.drawStr(59,23, " *C");
 
  u8g2.drawStr(0, 37,"H= ");
  u8g2.setCursor(22, 37);
  u8g2.print(dht.readHumidity());
  u8g2.drawStr(59,37, " %");
 
  u8g2.drawStr(0,51,"P= ");
  u8g2.setCursor(22,51);
  u8g2.print(bmp.readPressure()/100);
  u8g2.drawStr(68,51, " hPa");
 
  u8g2.drawStr(0, 65, "L= ");
  u8g2.setCursor(22, 65);
  u8g2.print(lux);
  u8g2.drawStr (68,65, " lx");
 
}

void drawDate(void)
{
  DateTime now = rtc.now();
  u8g2.setFont(u8g2_font_helvR14_tr);
    u8g2.setCursor(24,14);
    u8g2.print(now.day(), DEC);
    u8g2.print(".");
    u8g2.print(now.month(), DEC);
    u8g2.print('.');
    u8g2.print(now.year(), DEC);
    u8g2.print('.');
    
    u8g2.setCursor(23,60);
    u8g2.print(daysOfTheWeek[now.dayOfTheWeek()]);
    u8g2.setFont(u8g2_font_helvB24_tn);
    u8g2.setCursor(22,42);
    u8g2.print(now.hour(), DEC);
    u8g2.print(':');
    u8g2.print(now.minute(), DEC);
}
void drawOutdoor() {
  if (radio.available()) {
    radio.read(&data, sizeof(data));
  }

  u8g2.setFont(u8g2_font_t0_13b_tf);
  u8g2.drawStr(30, 9, "Vanjska");

 u8g2.setFont(u8g2_font_helvB12_tf);
  u8g2.drawStr(0, 23, "T= ");
  u8g2.setCursor(22, 23);
  u8g2.print(data.temperature);
  u8g2.drawStr(59,23, " *C");

  u8g2.drawStr(0, 37,"H= ");
  u8g2.setCursor(22, 37);
  u8g2.print(data.humidity);
  u8g2.drawStr(59,37, " %");

  u8g2.drawStr(0,51,"P= ");
  u8g2.setCursor(22,51);
  u8g2.print(data.pressure);
  u8g2.drawStr(68,51, " hPa");

 u8g2.drawStr(0, 65, "L= ");
  u8g2.setCursor(22, 65);
  u8g2.print(data.light);
  u8g2.drawStr (68,65, " lx");

}

A guess. You have a 128x64 display but your library is 128x32 by default.

No need for a second thread.

Threads merged.

Please work on your description of what you want to do.

Press the button, have it step through each of 3 menus (maybe more in the future)
then go dark.

Display each for 5 seconds.

Here is your code with some of what I see as cleaning it up without altering it too much.

What I did was to move all the bits of the display into each function so that of the display call in not in one function and other parts in a different function.

I was not sure why you had multiple timing, this why your description of what you want is so important.

I do not have your parts or your libraries installed, so could not verify that it will compile.

some notes :
#1) your timing is so short, 5 seconds, no need for a long, just int would work.
#2) this assumes the display only works after you press the button and then steps through each screen for 5 seconds, then goes dark.
#3) you may have had a long button press that did something, not sure, took it out.
if you want something else it should not be hard to do.
#4) you have a radio call, then display. I suggest you have a ‘radio not working’ if the radio does not return a signal.

I only added a few declare lines before setup() and nothing changed in setup() then cleaned up loop()
and each of the 3 functions for the display.

I do not see any need for the denounce library if all you have is one button press.

also, a second button press ‘should’ start all over again.

#include "Adafruit_Sensor.h"
#include "Adafruit_BMP280.h"
#include "Arduino.h"
#include "DHT.h"
#include "U8g2lib.h"
#include "RTClib.h"
#include "nRF24L01.h"
#include "RF24.h"
#include "JC_Button.h"

RTC_DS3231 rtc;

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
#define DHTPIN 2
#define DHTTYPE DHT22

Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);
int temt6000Pin = 0;

const byte
pin_SW1 = 3;
Button myButton(pin_SW1, 20, true, true);

int nSW1_state = 0;
int menu_state = 0;
int draw_state = 0;
unsigned long previousMillis = 0;
long interval = 3000;
int duration = 5000;
int then ; // could be long if needed
byte idle ; 

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

char daysOfTheWeek[7][12] = {"Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Cetvrtak", "Petak", "Subota"};


U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

const int pinCE = 7;
const int pinCSN = 8;
RF24 radio(7, 8);
byte address [5] = "00001";

struct package
{
  float temperature;
  float pressure;
  float humidity ;
  float light;
};
typedef struct package Package;
Package data;


void setup() {
  myButton.begin();

  Serial.begin(9600);
  rtc.begin();
  dht.begin();
  u8g2.begin();
  u8g2.clear();
  bmp.begin();
  radio.begin();
  radio.setChannel(150);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
}
void loop() {

  nSW1_state = digitalRead(pin_SW1);

  // read the switch value and if pressed the first time
  // it will change the menu_state
  if ( nSW1_state == HIGH ) {
    idle = 0 ; // allows the timer and menu to run
    if (oldSwitch != nSW1_state ) {
      menu_state = 1; // only does on first press
      then = millis() ; // starts timer
    }
  }

  if (idle = 0 ) {  // runs menu and timer

    switch (menu_state)
    {
      case 1: drawIndoor(); Serial.println("indoor"); break;
      case 2: drawOutdoor(); Serial.println("outdoor"); break;
      case 3: drawDate(); Serial.println("date"); break;
      case 4:
    }  //  ===========  end switch case ===========

    // +++++ timing +++++++
    timeout = ( millis() - then) ;
    if (timeout > duration ) {
      menu_state++;  // increments menu
      then = millis();
    }

    if (menu_state = 4 ) {
      idle = 1 ;
      //  if you want to clear the screen
      u8g2.firstPage();  do {
      } while ( u8g2.nextPage() );
     
    }

  } // ========== end of idle ========


  oldSwitch = nSW1_state ;
}//  ===========  end loop ===========


void drawIndoor(void) {
  float volts = analogRead(A0) * 5.0 / 1024.0;
  float amps = volts / 10000.0;
  float microamps = amps * 1000000;
  float lux = microamps * 2.0;
  int value = analogRead(temt6000Pin);

  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_t0_13b_tf);
    u8g2.drawStr(30, 9, "Unutarnja");

    u8g2.setFont(u8g2_font_helvB12_tf);
    u8g2.drawStr(0, 23, "T= ");
    u8g2.setCursor(22, 23);
    u8g2.print(dht.readTemperature());
    u8g2.drawStr(59, 23, " *C");

    u8g2.drawStr(0, 37, "H= ");
    u8g2.setCursor(22, 37);
    u8g2.print(dht.readHumidity());
    u8g2.drawStr(59, 37, " %");

    u8g2.drawStr(0, 51, "P= ");
    u8g2.setCursor(22, 51);
    u8g2.print(bmp.readPressure() / 100);
    u8g2.drawStr(68, 51, " hPa");

    u8g2.drawStr(0, 65, "L= ");
    u8g2.setCursor(22, 65);
    u8g2.print(lux);
    u8g2.drawStr (68, 65, " lx");
  } while ( u8g2.nextPage() );

} // end draw indoor

void drawDate(void)
{
  u8g2.firstPage();
  do {
    DateTime now = rtc.now();
    u8g2.setFont(u8g2_font_helvR14_tr);
    u8g2.setCursor(24, 14);
    u8g2.print(now.day(), DEC);
    u8g2.print(".");
    u8g2.print(now.month(), DEC);
    u8g2.print('.');
    u8g2.print(now.year(), DEC);
    u8g2.print('.');

    u8g2.setCursor(23, 60);
    u8g2.print(daysOfTheWeek[now.dayOfTheWeek()]);
    u8g2.setFont(u8g2_font_helvB24_tn);
    u8g2.setCursor(22, 42);
    u8g2.print(now.hour(), DEC);
    u8g2.print(':');
    u8g2.print(now.minute(), DEC);
  } while ( u8g2.nextPage() );
}




} // ======== END drawdate


void drawOutdoor() {
  if (radio.available()) {
    radio.read(&data, sizeof(data));
  }

  /*  there should be a response if radio
   *   is not available.
   *   
   *   u8g2.firstPage();  do {
   *   u8g2.drawStr(5, 20, " Radio Not Available ")
   *   } while ( u8g2.nextPage() );
   */

  u8g2.firstPage();
  do {

    u8g2.setFont(u8g2_font_t0_13b_tf);
    u8g2.drawStr(30, 9, "Vanjska");

    u8g2.setFont(u8g2_font_helvB12_tf);
    u8g2.drawStr(0, 23, "T= ");
    u8g2.setCursor(22, 23);
    u8g2.print(data.temperature);
    u8g2.drawStr(59, 23, " *C");

    u8g2.drawStr(0, 37, "H= ");
    u8g2.setCursor(22, 37);
    u8g2.print(data.humidity);
    u8g2.drawStr(59, 37, " %");

    u8g2.drawStr(0, 51, "P= ");
    u8g2.setCursor(22, 51);
    u8g2.print(data.pressure);
    u8g2.drawStr(68, 51, " hPa");

    u8g2.drawStr(0, 65, "L= ");
    u8g2.setCursor(22, 65);
    u8g2.print(data.light);
    u8g2.drawStr (68, 65, " lx");
  } while ( u8g2.nextPage() );
} // =========== end outdoor