I am using a ESP32-SIM800L with GPRS / MS5803-14BA / BME280 / SH1106 OLED
The modem and sensor setup (using TwoWire ) is as follows (relevant extracts only):
#include <Wire.h>
...
#define I2C_SDA 21
#define I2C_SCL 22
#define I2C_SDA_2 18
#define I2C_SCL_2 19
...
#include <SparkFun_MS5803_I2C.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "SH1106Wire.h"
TwoWire I2CPower = TwoWire(0);
TwoWire I2CMS = TwoWire(1); // I2C bus for MS5803 @ 0x77
TwoWire I2CBME = TwoWire(1); // I2C bus for BME280 @ 0x76
TwoWire I2CSH = TwoWire(1); // I2C bus for SH1106 OLED @ 0x3c
MS5803 sensor(ADDRESS_LOW); // default is ADDRESS_HIGH = 0x76 // ADDRESS_LOW = 0x77
Adafruit_BME280 bme;
SH1106Wire display(0x3c, I2C_SDA_2, I2C_SCL_2);
...
void setup() {
...
I2CPower.begin(I2C_SDA, I2C_SCL, 400000); // start I2C bus No. 1 for SIM800L
I2CMS.begin(I2C_SDA_2, I2C_SCL_2, 400000); // start I2C bus No. 2 for MS5803
I2CBME.begin(I2C_SDA_2, I2C_SCL_2, 400000); // start I2C bus No. 2 for BME280
I2CSH.begin(I2C_SDA_2, I2C_SCL_2, 400000); // start I2C bus No. 2 for SH1106 OLED
...
// Init BME280 @ 0x76
if (!bme.begin(0x76, &I2CBME)) {
Serial.println("No valid BME280 sensor @ 0x76, check wiring!");
} else {
Serial.println("BME280 @ 0x76 : Ok");
}
// Init MS5803 @ 0x77
sensor.reset();
delay(500);
//sensor.begin();
//delay(500);
if (!sensor.begin()) {
Serial.println("No valid MS5803 sensor @ 0x77");
} else {
Serial.println("MS5803 @ 0x77 : Ok");
}
// Init SH1106 OLED @ 0x3c
display.init();
Serial.println("SH1106 OLED @ 0x3c : SCREEN CHECK");
display.flipScreenVertically();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0,0,"SCREEN ON");
display.display();
...
} // End void setup()
void loop() {
read sensors and report & etc. ...
}
The Modem, BME280 and SH1106 OLED are all found and work, however the MS5803 is not picked up.
There are no I2C address clashes (0x76,0x33,0x77 respectivly).
Object creation or initialization of the BME280 and SH1106 OL allow explicit SDA/SCL pin assignments:
SH1106Wire display(0x3c, I2C_SDA_2, I2C_SCL_2);
...
bme.begin(0x76, &I2CBME)
however creation of the MS5803 object and its initialization has no provision for this:
MS5803 sensor(ADDRESS_LOW);
...
sensor.begin();
Trying to enter explicit pin numbers or reference to its TwoWire object in these expressions produces an error warning that there is no such function to allow such assignment.
Basically, if the modem, the BME280 and SH1106 OLED are not used, and TwoWire is not needed or invoked, then the MS5803 runs perfectly without pin assignment using the default I2C Pins (which for my ESP32Sim800L are 21/22). It is the issue of trying to put the sensor on a second I2C wire that seems problematic.
Can anyone explain how to use the MS5803 with TwoWire? Having looked on GitHub at the Sparkfun .h & .cpp I cant see one or how to explicitly set the SDA/SCL pins. Is there a way. Any pointers much appreciated.