0

CPS120 Error Data
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CPS120 Error Data

by magnethead on Fri Sep 06, 2019 1:36 pm

I picked up a CPS120 Barometer (my second one) and I feel like I am getting faulty data?

I swapped in the one from my working project, and it yields the same value.

The outputs are:

Baro: 127 255 16383 119994.51 35.43

I'm wondering if I did something wrong?

Both modules work in my other project, showing 29.88 inHg (100,812 pascal).

As best as I can tell, I haven't changed anything from what other programs utilize.

https://github.com/ncdcommunity/Arduino ... ter_Sensor

https://github.com/ControlEverythingCommunity/CPS120

Code: Select all | TOGGLE FULL SIZE
float CPS120(){

  //static int address = 0x28;
  static byte state;
  static int buff[2] = {0,0};
  float barometer;
  static long baro1;

  Wire.beginTransmission(0x28);
  Wire.write(0x80);

  state = Wire.endTransmission();
  if (state != 0){
    //Report sensor failure
    Serial.println("CPS120 Failure");
    return 0;
  }

  delay(10);
  Wire.requestFrom(0x28,2);
  delay(50);

  buff[0] = Wire.read();
  buff[1] = Wire.read();

  baro1 = ((buff[0] & 0x3F) << 8) | buff[1];
  barometer = 1000 * ((( baro1 / 16384.00)*90) + 30) ;

  Serial.print("Baro: ");
  Serial.print(buff[0]);
  Serial.print(" ");
  Serial.print(buff[1]);
  Serial.print(" ");
  Serial.print(baro1);
  Serial.print(" ");
  Serial.print(barometer);
  Serial.print(" ");
  Serial.println(barometer * 0.0002953);
 
  return barometer;
 
}


Yields:

Baro: 127 255 16383 119994.51 35.43

magnethead
 
Posts: 31
Joined: Tue Jul 11, 2017 7:49 pm

Re: CPS120 Error Data

by adafruit_support_mike on Fri Sep 06, 2019 10:43 pm

I'm afraid we don't have any experience with that device. Maybe someone from the community will have more information.

adafruit_support_mike
 
Posts: 58825
Joined: Thu Feb 11, 2010 2:51 pm

Re: CPS120 Error Data

by magnethead on Fri Sep 06, 2019 11:17 pm

I figured it out. Of course, it was something silly. I didn't copy and paste the right thing....

First code is what it's supposed to be. Second code is what I had there.

Code: Select all | TOGGLE FULL SIZE
Wire.beginTransmission(0x28);

  delay(10);
  Wire.requestFrom(0x28,4);
  delay(50);

  if (Wire.available() == 4){
 
    buff[0] = Wire.read();
    buff[1] = Wire.read();
    buff[2] = Wire.read();
    buff[3] = Wire.read();

  }

  state = Wire.endTransmission();
  if (state != 0){
    //Report sensor failure
    Serial.println("CPS120 Failure");
    return 0;
  }


Code: Select all | TOGGLE FULL SIZE
Wire.beginTransmission(0x28);
  Wire.write(0x80);

  state = Wire.endTransmission();
  if (state != 0){
    //Report sensor failure
    Serial.println("CPS120 Failure");
    return 0;
  }

  delay(10);
  Wire.requestFrom(0x28,2);
  delay(50);

  buff[0] = Wire.read();
  buff[1] = Wire.read();

magnethead
 
Posts: 31
Joined: Tue Jul 11, 2017 7:49 pm

Please be positive and constructive with your questions and comments.