Help with BMP Pressure readings

Help! I am using a AHT20+BMP280 sensor with ESP8266 or ESP32 controllers with OLED screen. I can display everything correctly on the OLED - Temperature, Humidity, and Barometric Pressure. The problem I am having is I want to add a Highest/Lowest temperature, pressure, humidity readout on the fourth line. I have managed to get it to work with High/Low temperature readings so far. My problem arises when trying to assign the Barometric Pressure reading to a variable to keep track of the High/Low. I get 'nan' which I believe stands for "not a number"??? I think this may have something to do with the output being a 32 but unsigned integer???
Sloppy code below - I have tried many things. How do I turn that 32 bit integer into a decimal number I can store in a variable??? Any help???

#include <Adafruit_AHTX0.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>


Adafruit_AHTX0 aht;


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define BMP_SCK  (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS   (10)

Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

// #define I2C_SDA 06
// #define I2C_SCL 05
// Define pins for mini?  Didn't work?

//HiLo Variables

float HI_TEMP = 0;
float LO_TEMP = 0;
int COUNTER = 0;
uint32_t BP_READING = 0;
uint32_t HI_BP = 0;
uint32_t LO_BP = 0;
float HI_HUM = 0;
float LO_HUM = 0;


void setup() {
  Serial.begin(115200);

Serial.println("Adafruit AHT10/AHT20 demo!");

  if (! aht.begin()) {
    Serial.println("Could not find AHT? Check wiring");
    while (1) delay(100);
  }
  Serial.println("AHT10 or AHT20 found");


  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000); // Pause for 2 seconds
  // Clear the buffer.
   display.clearDisplay();
  testscrolltext();
  // Clear the buffer.
  
  //display.setRotation(2);
  //Rotate Display???

  display.clearDisplay();
  display.setTextSize(2);
  display.print("   HELLO!");

  display.display();

  delay(1000);
 
  while ( !Serial ) delay(1000);   // wait for native usb
  Serial.println(F("BMP280 test"));
  unsigned status;
  //status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
  status = bmp.begin();
  if (!status) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
                      "try a different address!"));
    Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
    Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
    Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
    Serial.print("        ID of 0x60 represents a BME 280.\n");
    Serial.print("        ID of 0x61 represents a BME 680.\n");
    while (1) delay(10);
  }

  /* Default settings from datasheet. */
  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */


}
 void testscrolltext(void) {
  display.clearDisplay(); // clear the display screen of the OLED
  display.setTextSize(3); // Draw 2X-scale text
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  //display.println(F("Welcome"));
  delay(2000);
  display.clearDisplay(); 
    
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);


HI_TEMP = ((temp.temperature*9/5)+32);
LO_TEMP = ((temp.temperature*9/5)+32);

BP_READING = bmp.readPressure()/3386;
delay(100);
HI_BP = bmp.readPressure()/3386;
delay(100);
LO_BP = bmp.readPressure()/3386;
delay(100);

BP_READING = bmp.readPressure()/3386;


Serial.println(F("BP_READING= "));    
Serial.println(BP_READING);

Serial.println(HI_TEMP);
Serial.println(LO_TEMP);
Serial.println(HI_BP);
Serial.println(LO_BP);
Serial.println(BP_READING);

}
void loop() {
  
  COUNTER = COUNTER + 1;
  if (COUNTER > 40) {
    COUNTER = 0;
  }
  
  display.clearDisplay();
  display.setCursor(0, 0);
  
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  display.print((temp.temperature*9/5)+32); display.println(" F");

    if (((temp.temperature*9/5)+32) > HI_TEMP) {
      HI_TEMP = ((temp.temperature*9/5)+32);
    } 

        if (((temp.temperature*9/5)+32) < LO_TEMP) {
      LO_TEMP = ((temp.temperature*9/5)+32);
    } 
  
  display.print(humidity.relative_humidity); display.println(" %");

  display.print((bmp.readPressure()/3386)); display.println(" inHg");
  
   BP_READING = bmp.readPressure()/3386;


Serial.print(F("BP_READING= "));    
Serial.println(BP_READING);



    //Assign new values if they are HI or LO
    if (BP_READING > HI_BP) {
      HI_BP = BP_READING;
    } 
     if (BP_READING < LO_BP) {
      LO_BP = BP_READING;
    } 
    //Display HI/LOs based on counter
    if (COUNTER < 21) {
        display.print(HI_TEMP); display.print(" F HI");
    }
    if (COUNTER > 20 && COUNTER < 41) {  
        display.print(LO_TEMP); display.print(" F LO");
    } 
  // if (COUNTER > 20 && COUNTER < 31) {
  //   display.print(HI_BP); display.print(" BP HI");
  // }

  // if (COUNTER > 30 && COUNTER < 41) {
  //    display.print(LO_BP); display.print(" BP LO");
  // }

display.display(); 



  //Serial Print for debugging
    Serial.print(F("Temperature = "));
    Serial.print((bmp.readTemperature()*9/5)+32);
    Serial.println(" *F");

    Serial.print(F("Pressure = "));
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");

    Serial.print(F("Barometric Pressure = "));
    Serial.print((bmp.readPressure()/3386)); 
    Serial.println(" inHg");
    
    Serial.println(HI_TEMP);
    Serial.println(LO_TEMP);
    Serial.println(HI_BP);
    Serial.println(LO_BP);
    Serial.println(BP_READING);

    Serial.println();

  delay(1000);
}

Your code is indeed a mess.

Your code calls testscrolltext before it calls bmp.begin.

testscrolltext calls bmp.readPressure(), which fails because bmp.begin has not been called. When it fails, it returns the value NAN, assigning NAN to BP_READING, HI_BP and LO_BP.

Clean it up.

Thanks! That did the trick. I moved the testscrolltext(); that you referenced to after bmp.begin(); but it broke my "HELLO" message at the beginning. The testscrolltext(); may also have an effect on the OLED maybe??? Not sure but I left testscrolltext(); in both places an the code works fine now. A lot of the messy code I had in their was stuff for trying to debug my problem as well as portions commented out that had to do with the barometric pressure readings. Below is a copy of the working code - works on ESP32 ands ESP8266.

#include <Adafruit_AHTX0.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>


Adafruit_AHTX0 aht;


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define BMP_SCK  (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS   (10)

Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

// #define I2C_SDA 06
// #define I2C_SCL 05
// Define pins for mini?  Didn't work?

//HiLo Variables

float HI_TEMP = 0;
float LO_TEMP = 0;
int COUNTER = 0;
float BP_READING = 0;
float HI_BP = 0;
float LO_BP = 0;
float HI_HUM = 0;
float LO_HUM = 0;


void setup() {
  Serial.begin(115200);

Serial.println("Adafruit AHT10/AHT20 demo!");

  if (! aht.begin()) {
    Serial.println("Could not find AHT? Check wiring");
    while (1) delay(100);
  }
  Serial.println("AHT10 or AHT20 found");


  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000); // Pause for 2 seconds
  // Clear the buffer.
   display.clearDisplay();
 testscrolltext();
  // Clear the buffer.
  
  // display.setRotation(2);
  //Rotate Display???

  display.clearDisplay();
  display.setTextSize(2);
  display.print("   HELLO!");

  display.display();

  delay(1000);
 
  while ( !Serial ) delay(1000);   // wait for native usb
  Serial.println(F("BMP280 test"));
  unsigned status;
  //status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
  status = bmp.begin();

  testscrolltext();

  if (!status) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
                      "try a different address!"));
    Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
    Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
    Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
    Serial.print("        ID of 0x60 represents a BME 280.\n");
    Serial.print("        ID of 0x61 represents a BME 680.\n");
    while (1) delay(10);
  }

  /* Default settings from datasheet. */
  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */


}
 void testscrolltext(void) {
  // display.clearDisplay(); // clear the display screen of the OLED
  // display.setTextSize(2); // Draw 2X-scale text
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  //display.println(F("Welcome"));
  // delay(2000);
  // display.clearDisplay(); 
    
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);


HI_TEMP = ((temp.temperature*9/5)+32);
LO_TEMP = ((temp.temperature*9/5)+32);

BP_READING = bmp.readPressure()/3386;
delay(100);
HI_BP = bmp.readPressure()/3386;
delay(100);
LO_BP = bmp.readPressure()/3386;
delay(100);

BP_READING = bmp.readPressure()/3386;

delay(100);


Serial.println(F("BP_READING= "));    
Serial.println(BP_READING);

Serial.println(HI_TEMP);
Serial.println(LO_TEMP);
Serial.println(HI_BP);
Serial.println(LO_BP);
Serial.println(BP_READING);

}
void loop() {
  
  COUNTER = COUNTER + 1;
  if (COUNTER > 40) {
    COUNTER = 0;
  }
  
  display.clearDisplay();
  display.setCursor(0, 0);
  
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  display.print((temp.temperature*9/5)+32); display.println(" F");

    if (((temp.temperature*9/5)+32) > HI_TEMP) {
      HI_TEMP = ((temp.temperature*9/5)+32);
    } 

        if (((temp.temperature*9/5)+32) < LO_TEMP) {
      LO_TEMP = ((temp.temperature*9/5)+32);
    } 
  
  display.print(humidity.relative_humidity); display.println(" %");

  display.print((bmp.readPressure()/3386)); display.println(" inHg");

delay(100);

   BP_READING = bmp.readPressure()/3386;

delay(100);

Serial.print(F("BP_READING= "));    
Serial.println(BP_READING);



    // Assign new values if they are HI or LO
    if (BP_READING > HI_BP) {
      HI_BP = BP_READING;
    } 
     if (BP_READING < LO_BP) {
      LO_BP = BP_READING;
    } 

    //Display HI/LOs based on counter
    if (COUNTER < 11) {
        display.print(HI_TEMP); display.print(" F HI");
    }
    if (COUNTER > 10 && COUNTER < 21) {  
        display.print(LO_TEMP); display.print(" F LO");
    } 
  if (COUNTER > 20 && COUNTER < 31) {
    display.print(HI_BP); display.print(" BP HI");
  }

  if (COUNTER > 30 && COUNTER < 41) {
     display.print(LO_BP); display.print(" BP LO");
  }

display.display(); 



  //Serial Print for debugging
    Serial.print(F("Temperature = "));
    Serial.print((bmp.readTemperature()*9/5)+32);
    Serial.println(" *F");

    Serial.print(F("Pressure = "));
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");

    Serial.print(F("Barometric Pressure = "));
    Serial.print((bmp.readPressure()/3386)); 
    Serial.println(" inHg");
    
    Serial.println(HI_TEMP);
    Serial.println(LO_TEMP);
    Serial.println(HI_BP);
    Serial.println(LO_BP);
    Serial.println(BP_READING);

    Serial.println();

  delay(1000);
}

and a pic of the working device if it will upload....

and the back....