It is my first post here. I’m desperately looking for help.
I have Heltec WiFi LoRa 32 V3 with OLED display.
I successfully add BME280 sensor. But I have problem to display reading/data on OLED display.
Bellow is my code.
Program stops at “Could not find OLED”
When I try to run only BME28 - everything works fine.
Can correct my sketch to recognize OLED display
Thx in advance
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include “HT_SSD1306Wire.h”
#define I2C_BME_SDA 41
#define I2C_BME_SCL 42
#define I2C_OLED_SCL 18
#define I2C_OLED_SDA 17
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
TwoWire I2CBME = TwoWire(0);
TwoWire I2COLED = TwoWire(1);
unsigned long delayTime;
// For Ds18B20
#include “OneWire.h”
#include “DallasTemperature.h”
#define ONE_WIRE_BUS 4 // needs 4.7K pull up resistor
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
float airTemperature;
float barometricPressure;
float airHumidity;
float waterTemperature;
void setup() {
Serial.begin(115200);
I2CBME.begin(I2C_BME_SDA, I2C_BME_SCL, 40000);
//Wire(begin);
bool status;
status = bme.begin(0x76, &I2CBME);
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
sensors.begin();
I2COLED.begin(I2C_OLED_SCL, I2C_OLED_SDA, 50000);
bool status2;
status2 = bme.begin(0x3c, &I2COLED);
if (!status2)
{
Serial.println("Could not find OLED");
while (1);
}
}
void loop()
{
printValues();
delay(delayTime);
}
static void printValues()
{
airTemperature = bme.readTemperature();
barometricPressure = bme.readPressure() / 100.0F;
airHumidity = bme.readHumidity();
sensors.requestTemperatures();
waterTemperature = sensors.getTempCByIndex(0);
Serial.print("Air Temperature = ");
Serial.print(airTemperature);
Serial.println(" *C");
Serial.print("Barometric Pressure = ");
Serial.print(barometricPressure);
Serial.println(" hPa");
Serial.print("Air Humidity = ");
Serial.print(airHumidity);
Serial.println(" %");
Serial.print("Water Temperature = ");
Serial.print(waterTemperature);
Serial.println(" *C");
Serial.println();
}