MS5803-14BA I2c scan Freeze

Good Evening.

i have a MS5803-14BA sensor, and i want to use it with i2c.
i use this code below, to scan the i2c address

#include <Wire.h>

 
void setup()
{
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

But it stucks on scanning
the serial monitor keep displaying
"Scanning..."

But, when i try with the MS5803-14BA code

// The Wire library carries out I2C communication
#include <Wire.h>
// Place the MS5803_14 library folder in your Arduino 'libraries' directory
#include <MS5803_14.h> 

// Declare 'sensor' as the object that will refer to your MS5803 in the sketch
// Enter the oversampling value as an argument. Valid choices are
// 256, 512, 1024, 2048, 4096. Library default = 512.
MS_5803 sensor = MS_5803(512);

void setup() {
  // Start the serial ports.
  Serial.begin(9600); // other values include 9600, 14400, 57600 etc.
  delay(2000);
  // Initialize the MS5803 sensor. This will report the
  // conversion coefficients to the Serial terminal if present.
  // If you don't want all the coefficients printed out, 
  // set sensor.initializeMS_5803(false).
  if (sensor.initializeMS_5803()) {
    Serial.println( "MS5803 CRC check OK." );
  } 
  else {
    Serial.println( "MS5803 CRC check FAILED!" );
  }
  delay(3000);
}

void loop() {
  // Use readSensor() function to get pressure and temperature reading. 
  sensor.readSensor();
   // Uncomment the print commands below to show the raw D1 and D2 values
//  Serial.print("D1 = ");
//  Serial.println(sensor.D1val());
//  Serial.print("D2 = ");
//  Serial.println(sensor.D2val());

  // Show pressure
  Serial.print("Pressure = ");
  Serial.print(sensor.pressure());
  Serial.println(" mbar");
  
  // Show temperature
  Serial.print("Temperature = ");
  Serial.print(sensor.temperature());
  Serial.println("C");

  delay(1000); // For readability
}

it gives me

temp: 20.00 c
pressure : 0.00 Mbar

can someone give me information about this? cause i really confused about this.

sketch_dec26a.ino (1.09 KB)

MS5803_01_test.ino (2.39 KB)

Some i2c devices are not fully i2c compliant/compatible. They work ok with sketches especially written for them, but may not give all the correct responses if you use the scanner sketch. I have come across other sensors like this in the past. If the sensor works ok, don't worry about it. If not, try a known working i2c device in it's place. Can that be detected by the scanner sketch? Try adding pull-up resistors (e.g. 4K7) to the sda & scl lines. If that still fails, post pictures of your circuit (close up, well lit, well focussed) showing all the wiring clearly, and a schematic diagram (hand drawn is fine).

PaulRB:
Some i2c devices are not fully i2c compliant/compatible. They work ok with sketches especially written for them, but may not give all the correct responses if you use the scanner sketch. I have come across other sensors like this in the past. If the sensor works ok, don't worry about it. If not, try a known working i2c device in it's place. Can that be detected by the scanner sketch? Try adding pull-up resistors (e.g. 4K7) to the sda & scl lines. If that still fails, post pictures of your circuit (close up, well lit, well focussed) showing all the wiring clearly, and a schematic diagram (hand drawn is fine).

im So Sorry im not telling you, but the data that sensor give was wrong. The temperature isnt 20 C, i measured it with thermometer, it write 28 c. Could this be my sensor are broke?

Ayu1610:
im So Sorry im not telling you, but the data that sensor give was wrong.

It's OK, I understood that. Unless you are in the vacuum of space, the pressure would be higher than zero!
What I am trying to say is that yes, your sensor could be faulty. But the fact that it does not respond to the scanner sketch does not prove that it is faulty, because I know that some working i2c components do not do that either.

Do you have any other i2c components to try in its place? Like an rtc module?

Getting those numbers is interesting, it's like you get returned a default number from the library. Not likely it's an actual measurement.

  1. run an i2cscanner, see whether you see all the devices you expect on your I2C bus.

  2. try another library.

PaulRB:
It's OK, I understood that. Unless you are in the vacuum of space, the pressure would be higher than zero!
What I am trying to say is that yes, your sensor could be faulty. But the fact that it does not respond to the scanner sketch does not prove that it is faulty, because I know that some working i2c components do not do that either.

Do you have any other i2c components to try in its place? Like an rtc module?

i've trying with another sensor (MPU6050), it works fine. But with this, it doesnt works. Turns out, when i unplugged the sda/scl wires from the arduino, the data sent 20 c for the temperature, and 0 mbar for the pressure, but when i plugged the wires sda/scl, it makes the code freeze.

Do try another library. There are several out there. It sounds like a software issue - well, maybe that's not everything, but code that freezes is anyway faulty.