(solved) Problems with WEMOS D1 mini and BME280

Hi guys,

maybe I am wrong, but I dont know another forum where I can ask my questions regarding my wemos D1 mini, as I am a beginner :slight_smile: (Does anybody knows a good forum for Wemos problems?)

My problem is following:

I have attached my wemos d1 mini to ardoino ide an anything is working so far. Now I has tried to get the BME280 sensor working, but the board does not detect the sensor. I have attached the bme280 as follows:

VIN < > 3V3
GND < > GND
SDA < > D3
SCL < > D4

following sketch was used:

// ESP8266 WebServer
// (c) D L Bird 2016
//
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
const char ssid = “myssid”; // Your SSID here
const char password = “mypwd”; // Your password here
IPAddress ip(192, 168, 1, 223); // The address 192.168.0.53 is arbitary, if could be any address in the range of your router, but not another device!
IPAddress gateway(192,168,1,1); // My router has this base address
IPAddress subnet(255,255,255,0); // Define the sub-network
float bme_pressure, bme_temp, bme_humidity;
int count = 0;
WiFiServer server(80);
Adafruit_BME280 bme; // Note Adafruit assumes I2C adress = 0x77 my module (eBay) uses 0x76 so the library address has been changed.
void setup() {
Serial.begin(115200);
Serial.print(“Connecting to “);
Serial.println(ssid); // Connect to WiFi network
WiFi.config(ip, gateway, subnet);
WiFi.persistent(false); // disables the storage of credentials to flash.
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(”.”);
}
Serial.println(“WiFi connected…”);
// Start the webserver
server.begin();
Serial.println(“Webserver started…”);
pinMode(D3, INPUT_PULLUP); //Set input (SDA) pull-up resistor on
Wire.setClock(2000000); // Set I2C bus speed
Wire.begin(D3,D4); // Define which ESP8266 pins to use for SDA, SCL of the Sensor
if (!bme.begin()) {
Serial.println(“Could not find a valid BME280 sensor, check wiring!”);
while (1);
}
}

void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (client) { // an http request has been made
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read(); // if at the end of a line because newline character received and the line is blank, the http request is complete, so the client can receive a response
if (c == ‘\n’ && currentLineIsBlank) {
bme_temp = bme.readTemperature(); // No correction factor needed for this sensor
delay(1000);
bme_humidity = bme.readHumidity() + 1.0; // Plus a correction factor for this sensor
delay(1000);
bme_pressure = bme.readPressure()/100 + 3.7; // Plus a correction factor for this sensor
Serial.println(bme_temp);
Serial.println(bme_humidity);
Serial.println(bme_pressure);
float T = (bme_temp * 9 / 5) + 32; // Convert back to deg-F for the RH equation
float RHx = bme_humidity; // Short form of RH for inclusion in the equation makes it easier to read
float heat_index = (-42.379+(2.04901523
T)+(10.14333127
RHx)-(0.22475541TRHx)-(0.00683783sq(T))-(0.05481717sq(RHx))+(0.00122874sq(T)RHx)+(0.00085282Tsq(RHx))-(0.00000199sq(T)sq(RHx))-32)5/9;
if ((bme_temp <= 26.66) || (bme_humidity <= 40)) heat_index = bme_temp; // The convention is not to report heat Index when temperature is < 26.6 Deg-C or humidity < 40%
float dew_point = 243.04
(log(bme_humidity/100)+((17.625
bme_temp)/(243.04+bme_temp)))/(17.625-log(bme_humidity/100)-((17.625
bme_temp)/(243.04+bme_temp)));
// Now send a correctly formatted HTML response together with the sensor data, statements indented to help with HTML formatting
client.println("");
client.println("");
client.println("");
client.println("");
client.println(“h2 { color: blue; font-family: verdana; font-size: 200%; text-align: left; display:inline; } “);
client.println(“table { font-family: arial, sans-serif; font-size: 150%; border-collapse: collapse; border: 3px blue; width: 60%; }”);
client.println(“td, th { border: 1px solid blue; text-align: center; padding: 8px; } “);
client.println(“tr:nth-child(even) { background-color: skyblue; }”);
client.println(””);
client.println(“ESP8266 Readings”);
client.println(”<meta http-equiv=“refresh” content=“15”>”); // Refresh the screen every 15-seconds
client.println("");
client.println("");
client.println(“

BOSCH BME280 Sensor

”);
client.println("");
client.println("");
client.println(“”);
client.println(“”);
client.println(“”);
client.println(“”);
client.println(“”);
client.println("");
client.println("");
client.println("”); // Mixing HTML with sensor values for display
client.println(””);
client.println(””);
client.println("”);
client.println(””);
client.println(”");
client.println("
Temperature Humidity Pressure Dew Point Heat Index
“+String(bme_temp,1) + “°C “+String(bme_humidity,1) + “% RH “+String(bme_pressure,1) + " hPa “+String(dew_point,1) + “°C “+String(heat_index,1) + “°C
");

client.println(“
© D Bird 2016 (”+String(count)+")
"); // And display how many times the screen has been refreshed

client.println("");
client.println("");
break;
}
if (c == ‘\n’) {
currentLineIsBlank = true; // It’s a new line
} else if (c != ‘\r’) {
currentLineIsBlank = false; // There’s a character on the current line
}
}
}
delay(10);
client.flush(); // Flush the buffers
client.stop(); // Close the Client connection
count = count + 1; // Increase refresh indicator count
delay(5000); // Control speed of BME280 sensor reading
}
}

I have uploaded the sketch and I am stucking at: “Could not find a valid BME280 sensor, check wiring!”

Following troubleshooting was done so far:

-used another sensor … same problem
-used other pins on the board / changed also the code (D1 and D2) … same problem
-used other cables … same problem

Has anybody another idea, what I am doing wrong?

Thanks in advance and best regards

found the possible problem:

The Adafruit_BME280 Lib assumes the I2C adress = 0x77 my module uses 0x76 so the library address has been changed in the relevant file.