Looking for a second set of eyes here...
When not invoking the TFT, BME280 data in Serial Monitor is correct
14:30:26.203 -> Temperature = 69.08°F / 20.60°C
14:30:26.271 -> Pressure = 29.71 inHg
14:30:26.271 -> Approx. Altitude = 197.65 ft
14:30:26.301 -> Humidity = 51.25 %
When I invoke TFT_eSPI and try to get the same data, everything is static and grossly incorrect (as below)...
14:30:37.487 -> Temperature = 374.20°F / 190.11°C
14:30:37.487 -> Temperature = 374.20°F / 190.11°C
14:30:37.505 -> Temperature = 374.20°F / 190.11°C
14:30:37.552 -> Temperature = 374.20°F / 190.11°C
Code:
#include <SPI.h>
#include <TFT_eSPI.h>
#include <Wire.h>
#include <Adafruit_BME280.h>
#define BME_SCK 18
#define BME_MISO 19
#define BME_MOSI 23
#define BME_CS 5
#define TFT_GREY 0x5AEB
#define WHITE 0xFFFF
#define BLACK 0x0000
#define SEALEVELPRESSURE_HPA (1013.25)
TFT_eSPI tft = TFT_eSPI();
Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
unsigned long delayTime;
void setup() {
Serial.begin(9600);
unsigned bmeStatus;
bmeStatus = bme.begin();
if (!bmeStatus) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
while (1) delay(10);
}
tft.init();
tft.setRotation(0);
tft.setCursor(0, 0,);
tft.setTextColor(TFT_GREEN);
tft.setTextFont(4);
tft.println("TFT Ready");
}
void loop() {
Serial.print("Temperature = ");
Serial.print(convertBME('F'));
printDegree();
Serial.print("F ");
Serial.print(" / ");
Serial.print(convertBME('C'));
printDegree();
Serial.println("C ");
tft.setTextColor(TFT_GREEN);
tft.setTextFont(2);
tft.println(convertBME('F'));
}
float convertBME(char type) {
float wxValue;
float temp = bme.readTemperature();
float pressure = bme.readPressure();
float relHum = bme.readHumidity();
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
if(type == 'F') {
wxValue = temp * 9.0/5.0 +32; // Fahrenheit Conversion
} else if(type == 'H') {
wxValue = relHum; // Relative Humidity
} else if(type == 'B') {
wxValue = pressure;
} else if(type == 'M') {
wxValue = pressure * 0.029529983071445; // Pressure to inHg
} else if (type == 'A') {
wxValue = altitude * 3.280839895; // Approximate Altitude
} else {
wxValue = temp; // return default temp
}
return wxValue;
}
void printDegree() {
Serial.print("\xC2");
Serial.print("\xB0");
}
Any thoughts on why this is happening?
Also: If I pull the MISO from the BME280 (Pin 18 on ESP32), the same happens, but the numbers are now hundreds of "degrees" below zero (i.e., -260.xx for F).
Also: I can do a variety of things on the TFT without the BME280 being invoked. So it is working correctly.
TIA
