Error: Not in Scope

Hello. Having a persistent error we are not able to resolve. In short, states 'DPS310 was not declared in this scope':

//High precision and hgh measure rates at the same time are not available. //Consult Datasheet (or trial and error) for more information int ret = dps310.startMeasureBothCont(temp_mr, temp_osr, prs_mr, prs_osr); //Use one of the commented lines below instead to measure only temperature or pressure //int ret = dps310.startMeasureTempCont(temp_mr, temp_osr); //int ret = dps310.startMeasurePressureCont(prs_mr, prs_osr);

Entire code to be included in attachment.

ANY insight is greatly appreciated.

Thank you. Bob

PS My son and I are trying to create a 'smart watch' following an Arduino Project from the site. We copied the code and placed in the Arduino software on a Windows 10 Pro OS, if that matters at all. Downloaded the latest version of Arduiono today (vers 1.8.7). Have read several other posts and not able to fix this issue. Please share any thoughts. Thank you.

Full code:

#include <Dps310.h>

#include <dps310.h>

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

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

// IMPORTANT NOTE
//If you face the issue that the DPS310 indicates a temperature around 60 C although it should be around 20 C (room temperature), you might have got an IC with a fuse bit problem
//Call the following function directly after begin() to resolve this issue (needs only be called once after startup)
//dps310.correctTemp();

//temperature measure rate (value from 0 to 7)
//2^temp_mr temperature measurement results per second
int temp_mr = 2;
//temperature oversampling rate (value from 0 to 7)
//2^temp_osr internal temperature measurements per result
//A higher value increases precision
int temp_osr = 2;
//pressure measure rate (value from 0 to 7)
//2^prs_mr pressure measurement results per second
int prs_mr = 2;
//pressure oversampling rate (value from 0 to 7)
//2^prs_osr internal pressure measurements per result
//A higher value increases precision
int 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
int ret = dps310.startMeasureBothCont(temp_mr, temp_osr, prs_mr, prs_osr);
//Use one of the commented lines below instead to measure only temperature or pressure
//int ret = dps310.startMeasureTempCont(temp_mr, temp_osr);
//int ret = dps310.startMeasurePressureCont(prs_mr, prs_osr);

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

void loop()
{
unsigned char pressureCount = 20;
long int pressure[pressureCount];
unsigned char temperatureCount = 20;
long int 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
int ret = Dps310.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 (int i = 0; i < temperatureCount; i++)
{
Serial.print(temperature*);*

  • Serial.println(" degrees of Celsius");*
  • }*
  • Serial.println();*
  • Serial.print(pressureCount);*
  • Serial.println(" pressure values found: ");*
  • for (int i = 0; i < pressureCount; i++)*
  • {*
    _ Serial.print(pressure*);_
    _
    Serial.println(" Pascal");_
    _
    }_
    _
    }_
    _
    //Wait some time, so that the Dps310 can refill its buffer*_
    * delay(10000);*
    }

I haven’t used this particular library, but generally you need to declare an object of the type the library defines. You’ve got this scrambled into two #includes by the look of it. This:

#include <Dps310.h>

#include <dps310.h>

Should more likely be:

#include <Dps310.h>

Dps310 dps310;

Make sure that whenever you try to use the object, you refer to it as dps310. There’s (at least) one place where you used Dps310 by mistake. C++ is case sensitive.

#include <Dps310.h>

#include <dps310.h>

void setup()

You have not declared an instance of the object, hence the compiler cannot find an object named Dps310. You can’t name the object the same as the library name so I suggest

#include <Dps310.h>

Dps310 dps310;  // declare an instance of the Dps310 object

void setup()

Then look through the code and make sure the instance names are all dps310. In C++ Dps310 and dps310 are different. Case matters.

That is as far as I got. Your improperly posted code has some more errors but some are caused by how the forum software treats code that is not posted in code tags. See how to use this forum-please read, #7.

Hello WildBill and groundFungus,
Thank you for the suggestions. We will try these now. Regarding the full code, I appreciate the link to the #7 of the ‘how to use this forum’ related to posting the full source code. I am going to use this info to re-post the full code here…even as I try the noted suggestions.
Thank you again.

#include <dps310.h>

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

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

  // IMPORTANT NOTE
  //If you face the issue that the DPS310 indicates a temperature around 60 C although it should be around 20 C (room temperature), you might have got an IC with a fuse bit problem
  //Call the following function directly after begin() to resolve this issue (needs only be called once after startup)
  //dps310.correctTemp();

  //temperature measure rate (value from 0 to 7)
  //2^temp_mr temperature measurement results per second
  int temp_mr = 2;
  //temperature oversampling rate (value from 0 to 7)
  //2^temp_osr internal temperature measurements per result
  //A higher value increases precision
  int temp_osr = 2;
  //pressure measure rate (value from 0 to 7)
  //2^prs_mr pressure measurement results per second
  int prs_mr = 2;
  //pressure oversampling rate (value from 0 to 7)
  //2^prs_osr internal pressure measurements per result
  //A higher value increases precision
  int 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
  int ret = dps310.startMeasureBothCont(temp_mr, temp_osr, prs_mr, prs_osr);
  //Use one of the commented lines below instead to measure only temperature or pressure
  //int ret = dps310.startMeasureTempCont(temp_mr, temp_osr);
  //int ret = dps310.startMeasurePressureCont(prs_mr, prs_osr);


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



void loop()
{
  unsigned char pressureCount = 20;
  long int pressure[pressureCount];
  unsigned char temperatureCount = 20;
  long int 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
  int ret = Dps310.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 (int 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 (int 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);
}

Hello! Everything worked this time...using the code from groundFungus AND making sure (like you both stated) that the case sensitivity was consistent throughout. THANK YOU.

Now, on to step two using the blynk code!

Will post in a new topic a related issue...and maybe if either of you can point me to 'where' to learn more, then maybe I can understand this a bit further.

In short, I am getting a similar error 'not in scope' related to the Blynk code. I am also getting one related to 'Blynk does not name a type'. I have been searching on the forum a bit for the answers (since posting earlier). Still unsure...anyway, will post separately...and wanted to say thank you again.

At the top of this Forum is a topic title Useful Links. In that post, there is a section called C++ Programming. Within that section is a section on Scope. Read that post and see if it helps.