A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By bkenobi
#83219 I will give the I2C scanner a try. I have one in my set of sketches so it should help. Btw, I'm using the TwoWire library for my project but the I2C scanner I have and the ones I've locate on the playground use the standard Wire.h library. I know this used to work but not sure what I've done with my settings that broke things. I should have just created a new Arduino IDE for the Sonoff rather than mucking up my working NodeMCU setup.

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

Adafruit_BME280 bme; // I2C
TwoWire Wire1 = TwoWire();

#define SSID "******"
#define PASS "******"

char MQTTServer[] = "192.168.0.200";

WiFiClient wifiClient;
PubSubClient client(wifiClient);

int wifi_status = WL_IDLE_STATUS;
unsigned long lastSend;

int value = 0;

void setup()
{
  Serial.begin(9600);

  InitWiFi();
  client.setServer( MQTTServer, 1883 );
  lastSend = 0;

  Wire1.begin(D1,D2);
 
  bool bme_status;
  bme_status = bme.begin(0x76); 
  if (!bme_status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");   
    while (1);
  }
  delay(1000);
}

...
User avatar
By bkenobi
#83220 Ok, I sorted it out. It looks like at some point when I was moving from sensor to sensor during testing I got the SDA and SCL lines swapped. I moved them back and all is working now.

Thanks!