So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By ArtooDetoo
#74386 Hello everyone,

I have a NodeMCU and a BME280 sensor board. Is it safe/reasonable to connect the VCC-GND-SCL-SDA-CSB-SDO of the BME280 to 3v3-GND-D5-D6-D7-D8 of the NodeMCU? How can I access them afterwards? This is what I tried, which did not work.

Code: Select all#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

// assign the ESP8266 pins to arduino pins
#define D1 5
#define D2 4
#define D3 0
#define D4 2
#define D5 14
#define D6 12
#define D7 13
#define D8 15
#define D9 3

// assign the SPI bus to pins
#define BME_SCK D5 // SCL
#define BME_MOSI D6 // SDA
#define BME_CS D7 // CSB
#define BME_MISO D8 // SDO

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme;//(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Wire.begin(D6, D5);
    Wire.setClock(100000);
    Serial.begin(9600);
    Serial.println(F("BME280 test"));

    bool status;
   
    // default settings
    status = bme.begin();
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
   
    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}


void loop() {
    printValues();
    delay(delayTime);
}


void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
}



Apparently, there exist several versions of the BME280. Mine looks like this: https://www.my-batteries.net/ebay/image ... E280-1.jpg