Using the MS8607 with Arduino is a simple matter of wiring up the sensor to your Arduino-compatible microcontroller, installing the Adafruit MS8607 library we've written, and running the provided example code.
I2C Wiring
Use this wiring if you want to connect via I2C interface. The MS8607 is actually two devices in the same package so the I2C address for the pressure sensor is 0x76 and the address for the humidity sensor is 0x40.
Here is how to wire up the sensor using one of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Here is how to wire the sensor to a board using a solderless breadboard:
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Library Installation
You can install the Adafruit MS8607 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit MS8607 , and select the Adafruit MS8607 library:
Follow the same process for the Adafruit BusIO library.
Finally follow the same process for the Adafruit Unified Sensor library:
After opening the demo file, upload to your Arduino wired up to the sensor. Once you upload the code, you will see the pressure, temperature, and humidity values being printed when you open the Serial Monitor (Tools->Serial Monitor) at 115200 baud, similar to this:
// Basic demo for reading Humidity and Temperature #include <Wire.h> #include <Adafruit_MS8607.h> #include <Adafruit_Sensor.h> Adafruit_MS8607 ms8607; void setup(void) { Serial.begin(115200); while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens Serial.println("Adafruit MS8607 test!"); // Try to initialize! if (!ms8607.begin()) { Serial.println("Failed to find MS8607 chip"); while (1) { delay(10); } } Serial.println("MS8607 Found!"); ms8607.setHumidityResolution(MS8607_HUMIDITY_RESOLUTION_OSR_8b); Serial.print("Humidity resolution set to "); switch (ms8607.getHumidityResolution()){ case MS8607_HUMIDITY_RESOLUTION_OSR_12b: Serial.println("12-bit"); break; case MS8607_HUMIDITY_RESOLUTION_OSR_11b: Serial.println("11-bit"); break; case MS8607_HUMIDITY_RESOLUTION_OSR_10b: Serial.println("10-bit"); break; case MS8607_HUMIDITY_RESOLUTION_OSR_8b: Serial.println("8-bit"); break; } // ms8607.setPressureResolution(MS8607_PRESSURE_RESOLUTION_OSR_4096); Serial.print("Pressure and Temperature resolution set to "); switch (ms8607.getPressureResolution()){ case MS8607_PRESSURE_RESOLUTION_OSR_256: Serial.println("256"); break; case MS8607_PRESSURE_RESOLUTION_OSR_512: Serial.println("512"); break; case MS8607_PRESSURE_RESOLUTION_OSR_1024: Serial.println("1024"); break; case MS8607_PRESSURE_RESOLUTION_OSR_2048: Serial.println("2048"); break; case MS8607_PRESSURE_RESOLUTION_OSR_4096: Serial.println("4096"); break; case MS8607_PRESSURE_RESOLUTION_OSR_8192: Serial.println("8192"); break; } Serial.println(""); } void loop() { sensors_event_t temp, pressure, humidity; ms8607.getEvent(&pressure, &temp, &humidity); Serial.print("Temperature: ");Serial.print(temp.temperature); Serial.println(" degrees C"); Serial.print("Pressure: ");Serial.print(pressure.pressure); Serial.println(" hPa"); Serial.print("Humidity: ");Serial.print(humidity.relative_humidity); Serial.println(" %rH"); Serial.println(""); delay(500); }
Text editor powered by tinymce.