Hello,
for a portable wheather station i use UNO + BME280 + OLED 1106 compatible.
Everything works fine when Pressure is not read. When reading Pressure, Display is off or loop stops after first read.
Message from Upload:
Der Sketch verwendet 17498 Bytes (54%) des Programmspeicherplatzes. Das Maximum sind 32256 Bytes.
Globale Variablen verwenden 831 Bytes (40%) des dynamischen Speichers, 1217 Bytes für lokale Variablen verbleiben. Das Maximum sind 2048 Bytes.
Your attached file is down loaded but is not opened in my IDE 2.0.0. Please, post the codes online in this thread. Are you the following 5V-I2C BME280 Breakout Board?
Hi Mostafa, thanks for your quick reply.
Yes, i am using this breakout board.
Testing with Serial.println alone works fine.
Here my sketch:
/*********************************************************************
This is an example for our Monochrome OLEDs based on SH110X drivers
This example is for a 128x64 size display using I2C to communicate
3 pins are required to interface (2 I2C and one reset)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
i2c SH1106 modified by Rupert Hirst 12/09/21
*********************************************************************/
//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
//#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
Adafruit_BME280 bme; // I2C
/* Uncomment the initialize the I2C address , uncomment only one, If you get a totally blank screen try the other*/
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
#define SCREEN_WIDTH 128 // OLED width in pixels
#define SCREEN_HEIGHT 64 // OLED height in pixels
#define OLED_RESET -1 // QT-PY / XIAO ??
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
// Ausblenden Splashscreen ( Adafruit-Logo )
// SH110X_NO_SPLASH gesetzt in Adafruit_SH110X.h
delay(250); // wait for the OLED to power up
display.begin(i2c_Address, true); // Address 0x3C default
//display.setContrast (0); // dim display
display.display();
// Clear the buffer.
display.clearDisplay();
display.display();
Serial.begin(9600);
bool communication = bme.begin(0x76);
if (!communication) {
Serial.println("Could not find a valid BME280 sensor");
Serial.println("check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x");
Serial.println(bme.sensorID(), 16);
Serial.println("ID of 0xFF probably means a bad address\n");
while (true) { };
delay(10);
} else {
Serial.println("Communication established!\n");
}
}
void loop() {
display.clearDisplay();
// Variables for Temp and Humidity
float Temp = 0; // Temperature
float Humid = 0; // Humidity
float Druck = 0; // Pressure
// MEASURE Temp, Humid, Druck
//Druck = bme.readPressure();
//Druck = Druck / 100.0F;
// ABOVE NOT WORKING
Temp = bme.readTemperature();
Humid = bme.readHumidity();
Serial.println(Temp);
Serial.println(Humid);
Serial.println(Druck);
//delay(250);
//display.clearDisplay();
// Rahmen
display.drawRect(0, 0, display.width(), display.height(), SH110X_WHITE);
display.drawRect(0, 0, display.width(), 12, SH110X_WHITE);
display.setTextSize(0);
display.setTextColor(SH110X_WHITE);
// Überschrift
display.setCursor(5, 2);
display.print(F("Barometer @ G.Schmid"));
// Display Temp
display.setCursor(5, 14);
display.print(F("Temperatur C"));
display.setCursor(75, 14);
display.print(Temp, 2);
// Display Humidity
display.setCursor(5, 24);
display.print(F("Luftfeuchte %"));
display.setCursor(75, 24);
display.print(Humid, 2);
// Display Pressure
display.setCursor(5, 34);
display.print(F("Luftdruck hPa"));
display.setCursor(65, 34);
display.print(Druck, 1);
// Display Trend ( TODO rising / falling
display.setCursor(5, 44);
display.print(F("Tendenz"));
display.setCursor(67, 44);
display.print("steigend");
// Update screen
display.display();
delay(1000);
}
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project See About the Installation & Troubleshooting category.
i found a hint in the forum: you must not use serial.print within I2C configurations,
because I2c and serial both use interrupts and so get in conflict.
Thanks for your Efforts !
I deleted all "serial"-Commands and now my Sketch works perfect !
Your sketch falied also when reading pressure ...
thats right, I added bme.readPressure , and got the same behavior.
Is it possible, to search members in the arduino forum ?.
I think, you are quite experienced and I would like to look at your other contribs.
BTW:
Today I found a nice and best documented solution for „Trending“ barometric pressure.
I will try to integrate it ( without LEDs, Switches etc, just indicate „rising“ or „falling".
About me:
I am a retired ( aged 69 ) software developer for xtcommerce online shops ( but still working a little in this context )
and interested in electronics since my childhood
Yours sincerely,
It:logistik Günther Schmid
Am Steinbruch 1
85131 Pollenfeld / Wachenzell