### Get Serial Code Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Retrieves the serial code from the device's PROM. ```cpp getSerialCode() ``` -------------------------------- ### Get Manufacturer Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Retrieves the manufacturer identification code from the device's PROM. ```cpp getManufacturer() ``` -------------------------------- ### Setup Multiple MS5611 Sensors on I2C Bus Source: https://context7.com/robtillaart/ms5611/llms.txt Demonstrates configuring and reading from two MS5611 sensors simultaneously on the same I2C bus, each with a different address (0x76 and 0x77). ```cpp #include "MS5611.h" MS5611 sensorA(0x76); // CSB pin to VCC MS5611 sensorB(0x77); // CSB pin to GND void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); bool foundA = sensorA.begin(); bool foundB = sensorB.begin(); Serial.print("Sensor 0x76: "); Serial.println(foundA ? "Found" : "Not found"); Serial.print("Sensor 0x77: "); Serial.println(foundB ? "Found" : "Not found"); if (!foundA && !foundB) { Serial.println("No sensors found. Halting."); while (1); } Serial.println("\nSensor A\t\t\tSensor B\t\t\tDifference"); Serial.println("Temp\tPres\t\tTemp\tPres\t\tdT\tdP"); } void loop() { int resultA = sensorA.read(); int resultB = sensorB.read(); if (resultA == MS5611_READ_OK && resultB == MS5611_READ_OK) { float tempA = sensorA.getTemperature(); float presA = sensorA.getPressure(); float tempB = sensorB.getTemperature(); float presB = sensorB.getPressure(); Serial.print(tempA, 2); Serial.print("\t"); Serial.print(presA, 2); Serial.print("\t\t"); Serial.print(tempB, 2); Serial.print("\t"); Serial.print(presB, 2); Serial.print("\t\t"); Serial.print(tempA - tempB, 2); Serial.print("\t"); Serial.println(presA - presB, 2); } delay(1000); } ``` -------------------------------- ### Get Pressure in Pascal Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Retrieves the current pressure reading in Pascals (SI unit). ```cpp float getPressurePascal() ``` -------------------------------- ### Get Temperature and Pressure Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Retrieves the current temperature in degrees Celsius and pressure in mBar. Previous versions had math errors and are now obsolete. ```cpp getTemperature() and getPressure() ``` -------------------------------- ### Configure GY-63 Breakout Board Pins Source: https://github.com/robtillaart/ms5611/blob/master/README.md Pinout and protocol selection guide for the GY-63 breakout board, detailing connections for I2C and SPI modes. ```cpp // // BREAKOUT MS5611 aka GY63 - see datasheet // // SPI I2C // +--------+ // VCC VCC | o | // GND GND | o | // SCL | o | // SDI SDA | o | // CSO | o | // SDO | o L | L = led // PS | o O | O = opening PS = protocol select // +--------+ // // PS to VCC ==> I2C (GY-63 board has internal pull up, so not needed) // PS to GND ==> SPI // CS to VCC ==> 0x76 // CS to GND ==> 0x77 ``` -------------------------------- ### Get PROM Hash / Device ID Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Retrieves a unique device ID based on factory calibration values. This is an experimental function. ```cpp getPromHash() == getDeviceID() ``` -------------------------------- ### Get Altitude in Feet Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Calculates altitude in feet based on air pressure. Requires a float input for air pressure. ```cpp getAltitudeFeet(float airPressure) ``` -------------------------------- ### Get Device Address Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Returns the current I2C address of the MS5611 sensor as an 8-bit unsigned integer. ```cpp uint8_t getAddress() ``` -------------------------------- ### Get Altitude Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Calculates altitude based on air pressure. Defaults to a standard pressure of 1013.25 if no value is provided. ```cpp float getAltitude(float airPressure = 1013.25) ``` -------------------------------- ### Get Sea Level Pressure Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Calculates sea level pressure using current pressure and altitude. Requires float inputs for pressure and altitude. ```cpp float getSeaLevelPressure(float pressure, float altitude) ``` -------------------------------- ### Get CRC Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Retrieves the Cyclic Redundancy Check value of the device's PROM. This is an experimental function. ```cpp uint16_t getCRC() ``` -------------------------------- ### Get MS5611 Device Identification Information Source: https://context7.com/robtillaart/ms5611/llms.txt Retrieves unique device identifiers, manufacturer info, serial code, and CRC from the sensor's PROM. Useful for tracking sensors or applying specific calibrations. ```cpp #include "MS5611.h" MS5611 MS5611(0x77); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); if (MS5611.begin()) { // Get unique device ID (hash of calibration PROM) uint32_t deviceID = MS5611.getDeviceID(); Serial.print("Device ID: 0x"); Serial.println(deviceID, HEX); // Get manufacturer info (experimental) Serial.print("Manufacturer: 0x"); Serial.println(MS5611.getManufacturer(), HEX); // Get serial code (experimental) Serial.print("Serial Code: 0x"); Serial.println(MS5611.getSerialCode(), HEX); // Get CRC from PROM Serial.print("CRC: 0x"); Serial.println(MS5611.getCRC(), HEX); // Read raw PROM values for debugging Serial.println("\nPROM contents:"); for (uint8_t i = 0; i < 7; i++) { Serial.print("PROM["); Serial.print(i); Serial.print("] = "); Serial.println(MS5611.getProm(i)); } } } void loop() {} ``` -------------------------------- ### Initialize MS5611 Sensor Source: https://context7.com/robtillaart/ms5611/llms.txt Demonstrates creating an instance with different I2C addresses or custom Wire interfaces and initializing the sensor using begin(). ```cpp #include "MS5611.h" // Create sensor with default address 0x77 MS5611 sensor(0x77); // Or create with alternate address 0x76 MS5611 sensor2(0x76); // Or create with custom Wire interface (e.g., Wire1 for Teensy) MS5611 sensor3(0x77, &Wire1); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); // Must call Wire.begin() first if (sensor.begin() == true) { Serial.print("MS5611 found at address: 0x"); Serial.println(sensor.getAddress(), HEX); } else { Serial.println("MS5611 not found. Check wiring."); while (1); // Halt on failure } } void loop() {} ``` -------------------------------- ### MS5611 Initialization and Configuration Source: https://github.com/robtillaart/ms5611/blob/master/README.md Methods for initializing the sensor, checking connection, and configuring the math mode. ```APIDOC ## MS5611 Constructor ### Description Initializes the MS5611 object with a specific I2C address and Wire interface. ### Parameters - **deviceAddress** (uint8_t) - Optional - Default is 0x77. - **wire** (TwoWire*) - Optional - Pointer to the I2C interface. ## bool begin() ### Description Initializes the sensor internals by calling reset(). Must be called after Wire.begin(). ### Response - **bool** - Returns true if initialization succeeded, false otherwise. ## bool reset(uint8_t mathMode) ### Description Resets the device and loads constants from ROM. ### Parameters - **mathMode** (uint8_t) - Optional - 0 for datasheet math (default), 1 for Application note math. ### Response - **bool** - Returns false if ROM could not be read. ``` -------------------------------- ### Initial Version Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md The initial release of the MS5611 library, including basic code for temperature and pressure measurement. ```cpp added temperature and Pressure code ``` -------------------------------- ### Include MS5611 Library Source: https://github.com/robtillaart/ms5611/blob/master/README.md Include the header file to access the MS5611 class and its methods. ```cpp #include "MS5611.h" ``` -------------------------------- ### Calibration and Compensation API Source: https://github.com/robtillaart/ms5611/blob/master/README.md Methods for setting and retrieving pressure and temperature offsets, as well as toggling 2nd order compensation. ```APIDOC ## Calibration and Compensation ### Description Functions to calibrate the sensor readings and manage compensation settings. ### Methods - void setPressureOffset(float offset = 0) - float getPressureOffset() - void setTemperatureOffset(float offset = 0) - float getTemperatureOffset() - void setCompensation(bool flag = true) - bool getCompensation() ### Parameters - **offset** (float) - The value to add to the sensor reading for calibration. - **flag** (bool) - Enable or disable 2nd order compensation. ``` -------------------------------- ### Implement Error Handling and Status Checks Source: https://context7.com/robtillaart/ms5611/llms.txt Demonstrates checking sensor connectivity, handling read errors, and retrieving the last I2C result status. ```cpp #include "MS5611.h" MS5611 MS5611(0x77); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); // Check connection before begin if (!MS5611.isConnected()) { Serial.println("Sensor not detected on I2C bus!"); while (1); } if (!MS5611.begin()) { Serial.println("begin() failed - PROM read error"); while (1); } Serial.println("Sensor initialized successfully"); Serial.print("Address: 0x"); Serial.println(MS5611.getAddress(), HEX); } void loop() { // Perform read with error checking int result = MS5611.read(); switch (result) { case MS5611_READ_OK: Serial.print("T: "); Serial.print(MS5611.getTemperature(), 2); Serial.print(" C, P: "); Serial.print(MS5611.getPressure(), 2); Serial.print(" mBar"); Serial.print(", Last read: "); Serial.print(MS5611.lastRead()); Serial.println(" ms"); break; case MS5611_ERROR_2: Serial.println("I2C communication error"); // Try to recover if (MS5611.isConnected()) { MS5611.reset(0); } break; default: Serial.print("Unknown error: "); Serial.println(result); break; } // Check last result status if (MS5611.getLastResult() != 0) { Serial.print("Last I2C result: "); Serial.println(MS5611.getLastResult()); } delay(1000); } ``` -------------------------------- ### Initialize and Read MS5607 Sensor Source: https://context7.com/robtillaart/ms5611/llms.txt Uses the MS5607 derived class to automatically handle specific math constants for the sensor variant. ```cpp #include "MS5611.h" // MS5607 uses different math constants internally // The derived class handles this automatically MS5607 sensor(0x77); void setup() { Serial.begin(115200); while (!Serial); Serial.println("MS5607 Example"); Serial.print("Library Version: "); Serial.println(MS5611_LIB_VERSION); Wire.begin(); if (sensor.begin()) { Serial.print("MS5607 found at address: 0x"); Serial.println(sensor.getAddress(), HEX); } else { Serial.println("MS5607 not found. Halting."); while (1); } } void loop() { int result = sensor.read(); if (result == MS5611_READ_OK) { Serial.print("Temperature: "); Serial.print(sensor.getTemperature(), 2); Serial.print(" C\tPressure: "); Serial.print(sensor.getPressure(), 2); Serial.println(" mBar"); } else { Serial.print("Read error: "); Serial.println(result); } delay(1000); } ``` -------------------------------- ### MS5611 Library Version Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Defines the library version as a constant, stored in PROGMEM for memory efficiency. ```cpp #define MS5611_LIB_VERSION "0.1.05" ``` -------------------------------- ### Get/Set Oversampling Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Allows reading and setting the oversampling rate for sensor measurements. Also includes a read() function. ```cpp get/set oversampling, read() ``` -------------------------------- ### Check Connection Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Verifies if the MS5611 sensor is connected and communicating properly. The write(0) operation is conditional for specific boards like the NANO 33 BLE. ```cpp isConnected() ``` -------------------------------- ### Calibrate MS5611 Temperature and Pressure Offsets Source: https://context7.com/robtillaart/ms5611/llms.txt Adjusts temperature and pressure readings at runtime using offset values. Useful for compensating sensor self-heating or calibrating against reference stations. ```cpp #include "MS5611.h" MS5611 MS5611(0x77); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); MS5611.begin(); // Calibrate temperature offset for self-heating compensation // If sensor reads 2.5°C higher than ambient, use -2.5 MS5611.setTemperatureOffset(-2.5); // Or convert to Kelvin by adding 273.15 // MS5611.setTemperatureOffset(273.15); // Calibrate pressure against local weather station // If sensor reads 3 mBar lower than reference, use +3.0 MS5611.setPressureOffset(3.0); // Or set relative pressure (relative to 1 ATM) // MS5611.setPressureOffset(-1013.25); Serial.print("Temperature offset: "); Serial.println(MS5611.getTemperatureOffset()); Serial.print("Pressure offset: "); Serial.println(MS5611.getPressureOffset()); } void loop() { MS5611.read(); // Values now include offsets automatically Serial.print("Calibrated Temp: "); Serial.print(MS5611.getTemperature(), 2); Serial.print(" C\tCalibrated Pressure: "); Serial.print(MS5611.getPressure(), 2); Serial.println(" mBar"); delay(1000); } // Output: // Temperature offset: -2.50 // Pressure offset: 3.00 // Calibrated Temp: 20.95 C Calibrated Pressure: 1016.25 mBar ``` -------------------------------- ### Read Temperature and Pressure Source: https://context7.com/robtillaart/ms5611/llms.txt Uses the read() method to perform ADC conversion and retrieve compensated temperature and pressure values. ```cpp #include "MS5611.h" MS5611 MS5611(0x77); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); if (!MS5611.begin()) { Serial.println("MS5611 not found. halt."); while (1); } } void loop() { int result = MS5611.read(); if (result == MS5611_READ_OK) { Serial.print("Temperature: "); Serial.print(MS5611.getTemperature(), 2); Serial.println(" C"); Serial.print("Pressure: "); Serial.print(MS5611.getPressure(), 2); Serial.println(" mBar"); // Pressure in Pascal (SI unit) Serial.print("Pressure: "); Serial.print(MS5611.getPressurePascal(), 2); Serial.println(" Pa"); } else { Serial.print("Read error: "); Serial.println(result); } delay(1000); } // Output: // Temperature: 23.45 C // Pressure: 1013.25 mBar // Pressure: 101325.00 Pa ``` -------------------------------- ### Calculate Altitude with MS5611 Source: https://context7.com/robtillaart/ms5611/llms.txt Calculates altitude in meters and feet using standard sea-level pressure. Use getSeaLevelPressure() to calibrate for known altitudes. ```cpp #include "MS5611.h" MS5611 MS5611(0x77); // Known altitude at current location (meters) - for calibration const float KNOWN_ALTITUDE = 150.0; void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); MS5611.begin(); Serial.println("Celsius\tmBar\tMeters\tFeet"); } void loop() { MS5611.read(); float temperature = MS5611.getTemperature(); float pressure = MS5611.getPressure(); // Altitude with standard sea-level pressure (1013.25 mBar) float altitudeM = MS5611.getAltitude(); float altitudeF = MS5611.getAltitudeFeet(); Serial.print(temperature, 2); Serial.print("\t"); Serial.print(pressure, 2); Serial.print("\t"); Serial.print(altitudeM, 2); Serial.print("\t"); Serial.println(altitudeF, 2); // Calculate actual sea level pressure for calibration // Use this when you know your current altitude float seaLevelPressure = MS5611.getSeaLevelPressure(pressure, KNOWN_ALTITUDE); Serial.print("Calibrated sea level pressure: "); Serial.print(seaLevelPressure, 2); Serial.println(" mBar"); // Use calibrated value for accurate altitude float calibratedAltitude = MS5611.getAltitude(seaLevelPressure); Serial.print("Calibrated altitude: "); Serial.print(calibratedAltitude, 2); Serial.println(" m"); delay(2000); } // Output: // Celsius mBar Meters Feet // 23.45 1001.50 99.85 327.59 // Calibrated sea level pressure: 1013.25 mBar // Calibrated altitude: 150.00 m ``` -------------------------------- ### Reset MS5611 and Select Math Mode Source: https://context7.com/robtillaart/ms5611/llms.txt Resets the sensor and loads calibration constants. Optionally selects an alternative math mode (1) for compatible sensors that may return half the expected pressure in default mode (0). ```cpp #include "MS5611.h" MS5611 MS5611(0x77); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); // Standard initialization with default math mode (0) if (MS5611.begin()) { Serial.println("MS5611 initialized with default math mode"); } // Read with default math MS5611.read(); Serial.print("Mode 0 - Pressure: "); Serial.println(MS5611.getPressure(), 2); // If pressure seems half of expected, try math mode 1 // This is needed for some MS5611-compatible sensors bool romOK = MS5611.reset(1); // Use alternative math mode if (romOK) { Serial.println("Reset with math mode 1 successful"); MS5611.read(); Serial.print("Mode 1 - Pressure: "); Serial.println(MS5611.getPressure(), 2); } else { Serial.println("Reset failed - ROM read error"); } } void loop() {} // Output: // MS5611 initialized with default math mode // Mode 0 - Pressure: 1013.25 // Reset with math mode 1 successful // Mode 1 - Pressure: 1013.25 ``` -------------------------------- ### MS5611 Oversampling Configuration Source: https://github.com/robtillaart/ms5611/blob/master/README.md Methods to manage the oversampling rate for sensor readings. ```APIDOC ## void setOversampling(osr_t samplingRate) ### Description Sets the amount of oversampling for subsequent reads. ### Parameters - **samplingRate** (osr_t) - Required - Options: OSR_ULTRA_HIGH, OSR_HIGH, OSR_STANDARD, OSR_LOW, OSR_ULTRA_LOW. ## osr_t getOversampling() ### Description Returns the current oversampling setting. ### Response - **osr_t** - The current oversampling ratio. ``` -------------------------------- ### Second Order Temperature Compensation Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Implements second-order temperature compensation for more accurate pressure readings. This was introduced in version 0.1.04. ```cpp added second order temperature compensation ``` -------------------------------- ### MS5611 Data Acquisition Source: https://github.com/robtillaart/ms5611/blob/master/README.md Methods for reading sensor data and retrieving temperature and pressure values. ```APIDOC ## int read(uint8_t bits) ### Description Performs the actual reading of the sensor. The bits parameter determines the oversampling factor. ### Response - **int** - Returns MS5611_READ_OK upon success. ## float getTemperature() ### Description Returns the last read temperature in degrees Celsius. ### Response - **float** - Temperature in °C. Returns -999 on error. ## float getPressure() ### Description Returns the last read pressure in mBar. ### Response - **float** - Pressure in mBar. Returns -999 on error. ``` -------------------------------- ### Device Identification and PROM Access Source: https://github.com/robtillaart/ms5611/blob/master/README.md Methods to retrieve unique device IDs and raw PROM data from the sensor. ```APIDOC ## Device Identification ### Description Functions to retrieve unique identifiers and raw calibration data stored in the sensor PROM. ### Methods - uint32_t getDeviceID() - uint16_t getManufacturer() - uint16_t getSerialCode() - uint16_t getProm(uint8_t index) - uint16_t getCRC() ``` -------------------------------- ### Configure Oversampling Rates Source: https://context7.com/robtillaart/ms5611/llms.txt Adjusts the oversampling rate to balance measurement resolution and conversion time using setOversampling(). ```cpp #include "MS5611.h" MS5611 MS5611(0x77); uint32_t start, stop; void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); MS5611.begin(); Serial.println("OSR\t\tResolution\tTime(us)\tTemp\tPressure"); } void loop() { // Test each oversampling rate testOversampling(OSR_ULTRA_LOW, "ULTRA_LOW "); testOversampling(OSR_LOW, "LOW "); testOversampling(OSR_STANDARD, "STANDARD "); testOversampling(OSR_HIGH, "HIGH "); testOversampling(OSR_ULTRA_HIGH, "ULTRA_HIGH"); Serial.println(); delay(5000); } void testOversampling(osr_t rate, const char* name) { MS5611.setOversampling(rate); start = micros(); MS5611.read(); stop = micros(); Serial.print(name); Serial.print("\t"); Serial.print(stop - start); Serial.print("\t\t"); Serial.print(MS5611.getTemperature(), 2); Serial.print("\t"); Serial.println(MS5611.getPressure(), 2); } // Output: // OSR Resolution Time(us) Temp Pressure // ULTRA_LOW 1204 23.45 1013.25 // LOW 2408 23.45 1013.26 // STANDARD 4608 23.45 1013.25 // HIGH 9216 23.46 1013.25 // ULTRA_HIGH 18432 23.45 1013.25 ``` -------------------------------- ### Enable/Disable Second Order Temperature Compensation Source: https://context7.com/robtillaart/ms5611/llms.txt Compares readings with and without second-order temperature compensation. Enabled by default for higher accuracy, especially at temperature extremes. Disabling offers slightly faster readings. ```cpp #include "MS5611.h" MS5611 MS5611(0x77); void setup() { Serial.begin(115200); while (!Serial); Wire.begin(); MS5611.begin(); Serial.println("Comparing with and without 2nd order compensation:"); Serial.println("Compensation\tTemp\t\tPressure"); // With compensation (default) MS5611.setCompensation(true); Serial.print("Enabled: \t"); Serial.print(MS5611.getCompensation() ? "ON" : "OFF"); MS5611.read(); Serial.print("\t"); Serial.print(MS5611.getTemperature(), 4); Serial.print("\t"); Serial.println(MS5611.getPressure(), 4); // Without compensation (faster but less accurate at extremes) MS5611.setCompensation(false); Serial.print("Disabled: \t"); Serial.print(MS5611.getCompensation() ? "ON" : "OFF"); MS5611.read(); Serial.print("\t"); Serial.print(MS5611.getTemperature(), 4); Serial.print("\t"); Serial.println(MS5611.getPressure(), 4); // Re-enable for normal operation MS5611.setCompensation(true); } void loop() {} ``` -------------------------------- ### Altitude and Pressure Calculation Source: https://github.com/robtillaart/ms5611/blob/master/README.md Methods for calculating altitude based on pressure and determining reference sea level pressure. ```APIDOC ## Altitude Calculation ### Description Functions to convert pressure readings to altitude or determine reference pressure. ### Methods - float getAltitude(float airPressure = 1013.25) - float getAltitudeFeet(float airPressure) - float getSeaLevelPressure(float pressure, float altitude) ### Parameters - **airPressure** (float) - The reference pressure at sea level in mBar. - **pressure** (float) - Measured local pressure. - **altitude** (float) - Known current altitude. ``` -------------------------------- ### Read PROM Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Reads the calibration data from the device's PROM. Includes offset adjustments for specific read operations. ```cpp readProm() ``` -------------------------------- ### Reset Device Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Resets the MS5611 sensor. The 'mathMode' parameter can be used to switch between different pressure calculation methods. Returns a boolean indicating success. ```cpp reset() ``` -------------------------------- ### Read ADC Source: https://github.com/robtillaart/ms5611/blob/master/CHANGELOG.md Reads the raw ADC value from the MS5611 sensor. This function was fixed in version 0.1.02. ```cpp uint32_t readADC() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.