Hi,
Does anyone know working library for Arduino IDE that could communicate with GY-63 MS5611. I tried Rob Tillaart library 0.4.1 with no success.
The only way I was able the get readings from the board using Arduino IOT 33 was this code (no MS5611 library used at all).
The code gave this kind of result on serial:
14:48:48.854 -> Pressure: 101945 Pa, Temperature: 24.74 °C
I wonder if someone has some working library.h or example that communicates with the board better...
The default address on this press/temp board is 0x77, if u connect CSB to VCC the address changes to 0x76...So if only one sensor board is used in I2C mode then you need only SCL, SCA, GND, VCC connections to the microcontroller
#include <Wire.h>
#define MS5611_ADDRESS 0x77
// MS5611 commands
#define MS5611_CMD_RESET 0x1E
#define MS5611_CMD_ADC_READ 0x00
#define MS5611_CMD_CONV_D1 0x40 // Pressure conversion
#define MS5611_CMD_CONV_D2 0x50 // Temperature conversion
#define MS5611_CMD_READ_PROM 0xA0
// Variables to store calibration data
uint16_t C[6]; // Calibration coefficients
// Function prototypes
void resetSensor();
void readCalibrationData();
uint32_t readADC(uint8_t cmd);
void setup() {
Serial.begin(9600);
Wire.begin();
// Reset the MS5611 sensor
resetSensor();
delay(100);
// Read calibration data from PROM
readCalibrationData();
Serial.println("MS5611 sensor initialized.");
}
void loop() {
// Read temperature
uint32_t D2 = readADC(MS5611_CMD_CONV_D2);
int32_t dT = D2 - (uint32_t)C[4] * 256;
int32_t TEMP = 2000 + ((int64_t)dT * C[5]) / 8388608;
// Read pressure
uint32_t D1 = readADC(MS5611_CMD_CONV_D1);
int64_t OFF = (int64_t)C[1] * 65536 + ((int64_t)C[3] * dT) / 128;
int64_t SENS = (int64_t)C[0] * 32768 + ((int64_t)C[2] * dT) / 256;
int32_t P = (D1 * SENS / 2097152 - OFF) / 32768;
// Print results
Serial.print("Pressure: ");
Serial.print(P);
Serial.print(" Pa, Temperature: ");
Serial.print(TEMP / 100.0);
Serial.println(" °C");
delay(1000); // Wait for 1 second before the next reading
}
// Reset the MS5611 sensor
void resetSensor() {
Wire.beginTransmission(MS5611_ADDRESS);
Wire.write(MS5611_CMD_RESET);
Wire.endTransmission();
}
// Read calibration data from PROM
void readCalibrationData() {
for (int i = 0; i < 6; i++) {
Wire.beginTransmission(MS5611_ADDRESS);
Wire.write(MS5611_CMD_READ_PROM + (i + 1) * 2);
Wire.endTransmission();
Wire.requestFrom(MS5611_ADDRESS, 2);
C[i] = (Wire.read() << 8) | Wire.read();
}
}
// Read ADC value from the sensor
uint32_t readADC(uint8_t cmd) {
// Start conversion
Wire.beginTransmission(MS5611_ADDRESS);
Wire.write(cmd);
Wire.endTransmission();
// Wait for conversion to complete
delay(10); // Adjust delay based on oversampling ratio
// Read ADC result
Wire.beginTransmission(MS5611_ADDRESS);
Wire.write(MS5611_CMD_ADC_READ);
Wire.endTransmission();
Wire.requestFrom(MS5611_ADDRESS, 3);
uint32_t value = Wire.read() << 16;
value |= Wire.read() << 8;
value |= Wire.read();
return value;
}