I am building a weather station with an Arduino slave (dedicated to a rain gauge - depicted below as a reed switch) and a NodeMCU master with some additional sensors.
One such sensor, a BMP280 uses D1 and D2 as SCL and SDA, while slave control is using D3 and D4 for communication with Arduino.
When I enable Wire.begin
for slave communication, my BMP280 readings go nuts
#include <Adafruit_BMP280.h>
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
Adafruit_BMP280 bmp;
// masterSlave
#include <Wire.h>
#define I2CAddressESPWifi 8
...
void setup() {
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
// masterSlave - generates problem with BMP280...
Wire.begin(0,2);//Change to Wire.begin() for non ESP. D3 SDA D4 SCL
BMP280 Temp = -136.42 *C
Pressure = 125136.25 Pa
as opposed to this reading when Wire.begin is commented out.
// COMMENTED OUT FOR DEBUGGING
//masterSlave - generates problem with BMP280...
//Wire.begin(0,2);//Change to Wire.begin() for non ESP. D3 SDA D4 SCL
BMP280 Temp = 20.01 *C
Pressure = 93464.36 Pa
I attempted setting D3 and D4 to LOW while reading from BMP280, but it had no effect on readings.