error: invalid conversion from 'TwoWire*' to 'uint8_t' {aka 'unsigned char'} [-fpermissive] when compiling my project.
I am using the latest library #include <Adafruit_BMP280.h> V2.6.8 but have tried several others without success.
The error occurs at this line :- bool status = bmp.begin( 0x77,&Wire); Any help would be much appreciated and of course I will submit all code if required.
Yeah, the full code can help us to try and possibly give you an answer.
PS: remember to enclose the full and already indented code within "CODE" tags. To make things easier, load the IDE with your sketch then click Ctrl-T for auto-indent if required, then use "Copy for forum," menu function (or press Ctrl-shift-C) and paste it here.
The begin() function doesn't have a version that accepts address followed by Wire pointer. 0x77 is the default address and Wire is the default I2C interface so a begin without args will work just fine.
The DB_Meter works and I can post to Thingsboard on my own server. I would like to have the data also from the BMP280 & the AHT10 The bus wiring is correct at I can see the devices with test apps ```cpp //SoundI2cTempHumPres1 - 4/10/25 int versionno = 1; //#include <Spi.h> #include <Wire.h> //#include <Adafruit_AHT10.h> #include <Adafruit_BMP280.h> #include <WiFi.h> #include <HTTPClient.h> // SDA and SCL pins for the decibel meter module #define I2C_SDA 21 // 5 #define I2C_SCL 22 // 18 //AHT10 myAHT20(AHT10_ADDRESS_0X38, AHT20_SENSOR); // I2C address for the module #define DBM_ADDR 0x48 // Device registers #define DBM_REG_VERSION 0x00 #define DBM_REG_ID3 0x01 #define DBM_REG_ID2 0x02 #define DBM_REG_ID1 0x03 #define DBM_REG_ID0 0x04 #define DBM_REG_SCRATCH 0x05 #define DBM_REG_CONTROL 0x06 #define DBM_REG_TAVG_HIGH 0x07 #define DBM_REG_TAVG_LOW 0x08 #define DBM_REG_RESET 0x09 #define DBM_REG_DECIBEL 0x0A #define DBM_REG_MIN 0x0B #define DBM_REG_MAX 0x0C #define DBM_REG_THR_MIN 0x0D #define DBM_REG_THR_MAX 0x0E #define DBM_REG_HISTORY_0 0x14 #define DBM_REG_HISTORY_99 0x77 Adafruit_BMP280 bmp; TwoWire dbmeter = TwoWire(0); //( i2c for sound sensor) // delay (2000); uint8_t db, dbmin, dbmax; String DBMjson; // Buffer for printing decibel values over UART char buf[64]; // Function to read a register from decibel meter uint8_t dbmeter_readreg(TwoWire *dev, uint8_t regaddr) { dev->beginTransmission(DBM_ADDR); dev->write(regaddr); dev->endTransmission(); dev->requestFrom(DBM_ADDR, 1); delay(10); return dev->read(); } // Function to write a register to decibel meter module uint8_t dbmeter_writereg(TwoWire *dev, uint8_t regaddr, uint8_t regdata) { dev->beginTransmission(DBM_ADDR); dev->write(regaddr); dev->write(regdata); dev->endTransmission(); delay(10); return dbmeter_readreg(dev, regaddr); } void setup() { Serial.begin(115200); delay(1000); dbmeter.begin(I2C_SDA, I2C_SCL); delay(2000); //bmp.begin (I2C_SDA, I2C_SCL); // this line stops the other i2c device //delay (2000); Serial.println("Decibel Meter test sketch"); Serial.println("with Oled display======"); Serial.print("Version no "); Serial.println(versionno); // ser print version no delay(1000); ; // Wait and set up Wi-Fi connection delay(1000); WiFi.begin("xxxxxxxx", "xxxxxxxxx"); while (WiFi.status() != WL_CONNECTED) { delay(5000); Serial.println("Connecting to WiFi network 'Airtel'..."); } Serial.println("Connected!"); // Read version register uint8_t version = dbmeter_readreg(&dbmeter, DBM_REG_VERSION); Serial.printf("Version = 0x%02X\r\n", version); Serial.println(buf); // Read ID registers uint8_t id[4]; id[0] = dbmeter_readreg(&dbmeter, DBM_REG_ID3); id[1] = dbmeter_readreg(&dbmeter, DBM_REG_ID2); id[2] = dbmeter_readreg(&dbmeter, DBM_REG_ID1); id[3] = dbmeter_readreg(&dbmeter, DBM_REG_ID0); Serial.printf("Unique ID = %02X %02X %02X %02X\r\n", id[3], id[2], id[1], id[0]); // Clear the MIN and MAX reading dbmeter_writereg(&dbmeter, DBM_REG_RESET, 0x02); //.......BMP20.....initaisation if (!bmp.begin(0x77, &Wire)) { Serial.println("Could not find a valid BMP280 sensor, check wiring!"); while (1) ; } //bmp.begin(0x77); /* bool status = bmp.begin( 0x77,&Wire); if (!status) { Serial.println("Could not find a valid BMP280 sensor, check wiring!"); while (1); } */ } void loop() { while (1) { delay(1000); // Read decibel, min and max db = dbmeter_readreg(&dbmeter, DBM_REG_DECIBEL); if (db == 255) continue; // module is not ready dbmin = dbmeter_readreg(&dbmeter, DBM_REG_MIN); dbmax = dbmeter_readreg(&dbmeter, DBM_REG_MAX); Serial.printf("dB reading = %03d \t [MIN: %03d \tMAX: %03d] \r\n", db, dbmin, dbmax); // Assemble JSON with dB SPL reading DBMjson = "{\"db\": " + String(db) + "}"; Serial.println("JSON: \n" + DBMjson); Serial.print("Temperature = "); Serial.print(bmp.readTemperature()); Serial.print("Pressure = "); Serial.print(bmp.readPressure() / 100.0F); Serial.println(" *C"); // Make a POST request with the data if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status HTTPClient http; http.begin("http://192.168.1.140:8080/api/v1/twR9jeaRwqmyZyCh9k4i/telemetry"); http.addHeader("Content-Type", "application/json"); int httpResponseCode = http.POST(DBMjson); //Send the actual POST request if (httpResponseCode > 0) { //Get the response to the request String response = http.getString(); Serial.println(httpResponseCode); //Print return code Serial.println(response); //Print request answer } else { Serial.print("Error on sending POST: "); Serial.println(httpResponseCode); } http.end(); //Free resources } else { Serial.println("Something wrong with WiFi?"); } // Wait for 5 seconds before posting another reading delay(2000); } delay(2000); } ```
\sound_i2c_New2.ino: In function 'void setup()': \sound_i2c_New2\sound_i2c_New2.ino:133:12: error: request for member 'begin' in 'bmp', which is of pointer type 'Adafruit_BMP280*' (maybe you meant to use '->' ?) 133 | if (!bmp.begin(0x77)) {