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)