DPS310 pressure sensor with Arduino Wifi Rev2 - code not verifying.

Hi there,

I'm getting the following error message when trying to get a DPS310 (bought from SEEED studio) pressure sensor to work with an Arduino Wifi Rev2. I'm using a code example that came with the library (code included below). It won't verify the code. Its part of a weather station project, so will later be joined by humidity/light sensors etc and connected to thingspeak. I really only need the code to produce a single pressure value to add to a thingspeak field, but first I need to get the example code working!

Any help would be greatly appreciated.

Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Uno WiFi Rev2, ATMEGA328"

C:\Users\Andrew\Documents\Arduino\libraries\DPS310-Pressure-Sensor-dps310\src\DpsClass.cpp: In member function 'int16_t DpsClass::readBlock(RegBlock_t, uint8_t*)':

C:\Users\Andrew\Documents\Arduino\libraries\DPS310-Pressure-Sensor-dps310\src\DpsClass.cpp:777:73: error: call of overloaded 'requestFrom(uint8_t&, uint8_t&, unsigned int)' is ambiguous

int16_t ret = m_i2cbus->requestFrom(m_slaveAddress, regBlock.length, 1U);

^

In file included from C:\Users\Andrew\Documents\Arduino\libraries\DPS310-Pressure-Sensor-dps310\src\DpsClass.h:20:0,

from C:\Users\Andrew\Documents\Arduino\libraries\DPS310-Pressure-Sensor-dps310\src\DpsClass.cpp:1:

C:\Users\Andrew\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.6\libraries\Wire\src/Wire.h:61:13: note: candidate: virtual uint8_t TwoWire::requestFrom(uint8_t, size_t, bool)

uint8_t requestFrom(uint8_t, size_t, bool);

^~~~~~~~~~~

C:\Users\Andrew\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.6\libraries\Wire\src/Wire.h:63:13: note: candidate: uint8_t TwoWire::requestFrom(int, int, int)

uint8_t requestFrom(int, int, int);

^~~~~~~~~~~

exit status 1
Error compiling for board Arduino Uno WiFi Rev2.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#include <Dps310.h>

// Dps310 Opject
Dps310 Dps310PressureSensor = Dps310();

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

  //Call begin to initialize Dps310PressureSensor
  //The parameter 0x76 is the bus address. The default address is 0x77 and does not need to be given.
  //Dps310PressureSensor.begin(Wire, 0x76);
  //Use the commented line below instead to use the default I2C address.
  Dps310PressureSensor.begin(Wire);

  //temperature measure rate (value from 0 to 7)
  //2^temp_mr temperature measurement results per second
  int16_t temp_mr = 2;
  //temperature oversampling rate (value from 0 to 7)
  //2^temp_osr internal temperature measurements per result
  //A higher value increases precision
  int16_t temp_osr = 2;
  //pressure measure rate (value from 0 to 7)
  //2^prs_mr pressure measurement results per second
  int16_t prs_mr = 2;
  //pressure oversampling rate (value from 0 to 7)
  //2^prs_osr internal pressure measurements per result
  //A higher value increases precision
  int16_t prs_osr = 2;
  //startMeasureBothCont enables background mode
  //temperature and pressure ar measured automatically
  //High precision and hgh measure rates at the same time are not available.
  //Consult Datasheet (or trial and error) for more information
  int16_t ret = Dps310PressureSensor.startMeasureBothCont(temp_mr, temp_osr, prs_mr, prs_osr);
  //Use one of the commented lines below instead to measure only temperature or pressure
  //int16_t ret = Dps310PressureSensor.startMeasureTempCont(temp_mr, temp_osr);
  //int16_t ret = Dps310PressureSensor.startMeasurePressureCont(prs_mr, prs_osr);


  if (ret != 0)
  {
    Serial.print("Init FAILED! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.println("Init complete!");
  }
}



void loop()
{
  uint8_t pressureCount = 20;
  float pressure[pressureCount];
  uint8_t temperatureCount = 20;
 float temperature[temperatureCount];

  //This function writes the results of continuous measurements to the arrays given as parameters
  //The parameters temperatureCount and pressureCount should hold the sizes of the arrays temperature and pressure when the function is called
  //After the end of the function, temperatureCount and pressureCount hold the numbers of values written to the arrays
  //Note: The Dps310 cannot save more than 32 results. When its result buffer is full, it won't save any new measurement results
  int16_t ret = Dps310PressureSensor.getContResults(temperature, temperatureCount, pressure, pressureCount);

  if (ret != 0)
  {
    Serial.println();
    Serial.println();
    Serial.print("FAIL! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.println();
    Serial.println();
    Serial.print(temperatureCount);
    Serial.println(" temperature values found: ");
    for (int16_t i = 0; i < temperatureCount; i++)
    {
      Serial.print(temperature[i]);
      Serial.println(" degrees of Celsius");
    }

    Serial.println();
    Serial.print(pressureCount);
    Serial.println(" pressure values found: ");
    for (int16_t i = 0; i < pressureCount; i++)
    {
      Serial.print(pressure[i]);
      Serial.println(" Pascal");
    }
  }

  //Wait some time, so that the Dps310 can refill its buffer
  delay(10000);
}

The compiler is telling you there are two candidate functions for TwoWire::requestFrom(). One takes (uint8_t, size_t, bool) type variables, the other takes (int, int, int) but your Dps class is calling it with (uint8_t&, uint8_t&, unsigned int). The third parameter is an unsigned int which the compiler would have to coerce into a bool or an int and it can't read your mind.

I would edit this line
int16_t ret = m_i2cbus->requestFrom(m_slaveAddress, regBlock.length, 1U);

and make that third parameter simply a 1 (so it is not unsigned)

That worked. Many thanks!