Arduino Giga R1 WiFi MS5611 Pressure Sensor
Put an air pressure sensor on a table, do not touch it, and read it again and again. The last digits change all the time, although nothing in the room seems to move. This trembling is called noise, and every sensor has it. In this guide, we will learn how to use the MS5611 pressure sensor with the Arduino Giga R1 WiFi, how to see its noise as a curve in the Serial Plotter, and how to calm the curve. In detail, we will learn:
- What the MS5611 module (also sold as GY-63) measures, and how big its noise is in hPa and in centimeters of height.
- How to connect the module to the I2C pins 20 and 21 of the Giga R1 WiFi, with 3.3V on VCC.
- How to read the air pressure and the temperature of the chip.
- How to draw a raw curve and a smooth curve together, and switch between OSR 4096 and OSR 256 while they run.
- How to choose the smoothing level, and which errors smoothing cannot repair.

Why are a few hundredths of a hPa important? A barometer is also an altimeter. Near sea level, the pressure falls by about 0.12 hPa for every meter up. With a noise of 0.06 hPa, the height trembles by half a meter. With 0.003 hPa, it trembles by only 2 or 3 cm. This helps in every later project with the sensor, such as a weather station or a height meter.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
For the experiments you also need a quiet table, and a shelf or a box about 1 m above it.
Overview of MS5611 Pressure Sensor
The small metal can on the module is the sensor itself, an MS5611-01BA03 from TE Connectivity. A thin silicon membrane is inside. The air presses on it and bends it a very little, and a 24-bit converter in the chip turns the bend into a number. The higher you are, the less air is above you, so the number gets smaller.
The result is a pressure in hPa (hectopascal). 1 hPa is the same as 1 mbar, and near sea level it stands for about 8.3 m of height. The standard pressure at sea level is 1013.25 hPa.
| MS5611 Module (DIYables GY-63) | |
|---|---|
| Pressure resolution | 0.012 hPa (about 10 cm of height) |
| Pressure accuracy | ±1.5 hPa (25°C, 700 to 1100 hPa) |
| Pressure range | 10 to 1200 hPa, with full accuracy from 450 to 1100 hPa |
| Converter | 24 bit, about 9 ms for one pressure conversion at the best resolution |
| Temperature range and accuracy | -40°C to 85°C, ±0.8°C (at 25°C) |
| Interface | I2C up to 400 kHz (default), or SPI |
| I2C address | 0x77 (default), or 0x76 |
| Module supply | 3.3V to 5V, with a 3.3V regulator on the board |
| Module size | about 19 x 13 mm |
Compare the first two rows: the sensor can see a change of 0.012 hPa, but the value itself may be wrong by up to 1.5 hPa. Resolution and accuracy are two different things, and we come back to this at the end.

Four pins get a wire:
- VCC pin: connect to 3.3V of the Arduino Giga R1 WiFi
- GND pin: connect to GND (0V)
- SCL pin: the I2C clock, connect to pin 21 (SCL)
- SDA pin: the I2C data, connect to pin 20 (SDA)
Three pins stay empty:
- CSB pin: sets the I2C address. Empty or GND means 0x77, and 3.3V means 0x76, so two modules can share one bus. With SPI, it is the chip select.
- SDO pin: the data output for SPI, not used for I2C
- PS pin: chooses the protocol. A resistor on the module holds it HIGH for I2C. GND would switch the module to SPI.
The pull-up resistors for SCL and SDA are already on the module, so there's no need to add them. CSB and PS belong to the 3.3V chip: if you ever connect one of them to a HIGH level, use 3.3V and never 5V.
Noise, Oversampling and Smoothing
Three words are enough for our lab:
- Noise is a small random error that is new in each reading. One reading is a bit too high, the next one a bit too low.
- Oversampling (OSR) fights the noise inside the chip. With a higher OSR, the converter works longer on one reading, and the reading gets better.
- Smoothing fights the noise in the program. A new reading does not replace the old result. It only moves the result a small part of the way.
The library has five oversampling settings. The default is the first one, the one with the most noise:
| Setting | Name in the Library | Typical Noise | Seen as Height | Time for One Reading |
|---|---|---|---|---|
| OSR 256 | OSR_ULTRA_LOW | 0.065 hPa | 54 cm | about 3 ms |
| OSR 512 | OSR_LOW | 0.042 hPa | 35 cm | about 4 ms |
| OSR 1024 | OSR_STANDARD | 0.027 hPa | 22 cm | about 6 ms |
| OSR 2048 | OSR_HIGH | 0.018 hPa | 15 cm | about 11 ms |
| OSR 4096 | OSR_ULTRA_HIGH | 0.012 hPa | 10 cm | about 20 ms |
"Typical" means that about two of three readings are closer to the middle than this value.
Can we also read fast and make the average ourselves? In 20 ms there is time for six readings with OSR 256, but their average still has a noise of about 0.027 hPa. One reading with OSR 4096 has 0.012 hPa. So use OSR 256 only when speed is more important than a calm value.
Wiring Diagram
Four wires go from the module to the Giga R1 WiFi, and both I2C wires end on neighboring pins.

This image is created using Fritzing. Click to enlarge image
| MS5611 Module Pin | Arduino Giga R1 WiFi Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SCL | 21 (SCL) |
| SDA | 20 (SDA) |
| CSB, SDO, PS | nothing |
The red wire starts at the 3.3V hole of the power header, between RESET and 5V. The black wire uses the GND hole between pin 13 and AREF. Pins 20 and 21 are the last two holes at the other end of that side.
※ NOTE THAT:
- Never connect VCC to 5V on this board. The level shifter of the module follows VCC, so with 5V the module would pull SCL and SDA up to 5V. The pins of the Giga are made for 3.3V.
- The Giga has three I2C buses. SDA1 and SCL1 next to AREF, and pins 9 and 8 (SDA2 and SCL2), belong to the other two. The code of this guide uses the default bus, Wire, on pins 20 and 21.
- The metal can has two small holes for the air. Do not block them and do not let them get wet. The sensor is made for air, not for water pressure or tire pressure.
How To Program For MS5611 Pressure Sensor
- Include Wire for the I2C bus, and the library for the sensor:
- Create one object for the sensor and give it the I2C address:
- In setup(), switch on the bus and look for the sensor. If there is no answer, or if the calibration data in the chip is empty, begin() returns false:
- Select OSR 4096, because the library begins with OSR 256:
- Measure, then get the two results in hPa and °C:
The noise lab adds two things:
- Use a one-line filter. With LEVEL = 10, the smooth value moves one tenth of the way to the raw value:
- Print a name, a colon and a number for each curve, with a comma in between. The Serial Plotter understands this form:
Arduino Giga R1 WiFi Code - MS5611 Pressure Sensor
First a short test. The sketch prints the pressure and the chip temperature every second. Two digits after the point are enough to see the noise.
Detailed Instructions
Follow these instructions step by step:
- First time with this board? Prepare the Arduino IDE with the Arduino Giga R1 WiFi getting started guide.
- Wire the components according to the provided diagram.
- Connect the Giga R1 WiFi and the computer with the USB Type-C cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Giga R1 WiFi board (e.g., Arduino Giga R1 WiFi) and COM port.
- Open the Libraries panel on the left side and search for MS5611.
- Several libraries come up. Find the one by Rob Tillaart that is named only MS5611 and press Install. It has no dependencies.
- Search for MS5611 created by Rob Tillaart
and click the Install button.
- Copy the sketch into the IDE and press Upload.
- Open the Serial Monitor at 9600 baud. The sketch waits for it, so you see every line from the start.
The module lay still, but the pressure moved between 994.35 and 994.39 hPa. Near sea level, these 0.04 hPa are the same as about 33 cm of height. A third digit would not help, because the library counts in whole pascals (0.01 hPa).
The second number is the temperature of the chip itself, and it is used to correct the pressure. It goes up a little after power-on, because the board warms the chip. 1 to 3°C above the room is normal. For the real room temperature, take a DS18B20 as in the Arduino Giga R1 WiFi - Temperature Sensor guide.
Arduino Giga R1 WiFi Code - Noise Lab with the Serial Plotter
Now we draw the noise. This sketch works as follows:
- It starts with OSR 4096, and the first reading is the start of the smooth value.
- Ten times per second, it reads the raw pressure and calculates the smooth value with the one-line filter.
- It prints both values in one line. The smooth value gets a third digit, because it can lie between two steps of 0.01 hPa.
- If you send the character 2, it changes to OSR 256 (OSR_ULTRA_LOW). The character 4 brings back OSR 4096 (OSR_ULTRA_HIGH).
Detailed Instructions
- Leave the wires as they are and upload the new sketch.
- Click the Serial Plotter icon at the top right of the Arduino IDE, beside the Serial Monitor icon. Choose 9600 baud.
- Two curves appear. Their names, raw and smooth, come from the sketch.
- Put the module on the table, away from a fan, an open window and direct sunlight. Wait a minute.
- Type 2 into the message box at the bottom of the plotter and send it. After some seconds, send 4.
The Serial Monitor shows the same data as text. One second with OSR 4096:
And one second with OSR 256, after sending 2:
The difference between the highest and the lowest number of each column is:
| Raw Moves by | Smooth Moves by | |
|---|---|---|
| OSR 4096 | 0.04 hPa (33 cm) | 0.003 hPa (2.5 cm) |
| OSR 256 | 0.21 hPa (174 cm) | 0.016 hPa (13 cm) |
The average of the raw values is almost the same in both samples: 994.366 and 994.357 hPa. So a low OSR does not move the pressure up or down. It only adds more noise.
※ NOTE THAT:
Read the numbers on the left axis, not only the shape of the curve. The plotter always stretches the curves until they fill the window. So after a while, the noise of OSR 4096 looks as tall as the noise of OSR 256. In the first seconds after you send 2 or 4, both are in the same window, and you can compare them directly.
Three More Experiments
- Lift it: send 4, then move the module from the table to the shelf, about 1 m up. The raw curve falls by about 0.12 hPa and stays there. The smooth curve needs about 2 seconds to follow. Put the module back, and both curves rise again.
- Hide the step: send 2 and lift the module again. Now the step is only about twice the typical noise, and it is hard to see in the raw curve. In the smooth curve, you can still find it.
- Make wind: wave a notebook over the module. The raw curve jumps. This is not noise of the sensor, because the pressure at the can really changes. A higher OSR does not help here, but a piece of open foam over the can does.
How Much Smoothing Is Right?
More smoothing makes the curve calmer, but also slower. The table counts from a sudden step of the pressure until the smooth value has made 90% of the step:
| LEVEL | Noise Gets Smaller | Readings to Follow a Step | Time at 10 Readings per Second |
|---|---|---|---|
| 1 | not at all | 1 | at once |
| 5 | 3 times | 11 | 1.1 s |
| 10 | 4.4 times | 22 | 2.2 s |
| 20 | 6.2 times | 45 | 4.5 s |
| 50 | 10 times | 114 | 11.4 s |
These values are calculated for pure random noise. In a real room the air is never quite still, so your curve can be a little rougher. Try level 5 or 10 for a moving project, and 20 to 50 for a weather display.
The level counts readings, not seconds. If you read more often, the same level follows faster.
The Same Filter at Full Speed
The lab makes a pause between two lines, so the curve is easy to follow. In your own project, keep the filter line and let loop() read without any pause:
read() waits for the sensor and returns after about 20 ms. This gives about 50 readings per second with OSR 4096, and level 10 then follows a step in less than half a second. The filter line also works with the altitude or the temperature in place of the pressure.
What Smoothing Cannot Repair
- Accuracy: if the sensor shows 1 hPa too much, the smooth curve also shows 1 hPa too much. It is calm, but it is not more correct.
- Weather: the air pressure itself changes during the day. A curve that moves slowly up or down for an hour is a real signal. A fast fall of 3 hPa or more in 3 hours means a strong weather change.
- Altitude above sea level: it needs the present sea-level pressure of your area (QNH) from a weather website. Write it between the brackets after each reading:
For the 994.37 hPa of our table, this gives 199.2 m. With the standard value of 1013.25 hPa, it would be 158.3 m. So the noise is an error of about 10 cm, but the wrong sea-level pressure is an error of 41 m here. To measure a change of height, wait some seconds, save the smooth pressure (zeroPressure = smooth;), and then use ms5611.getAltitude(zeroPressure). Then you need no sea-level pressure. With the filter line for this height too, the result is good to about 10 to 20 cm, but only for a short time, because the weather also changes the pressure.
Troubleshooting
- "No MS5611 on pins 20 and 21": check VCC on 3.3V and GND first. Then check that SCL is on 21 and SDA on 20, and not on SDA1 and SCL1. PS must be empty. Is there 3.3V on CSB? Then write 0x76 in the line MS5611 ms5611(0x77);.
- The pressure and the temperature cannot be true: perhaps a BMP280, BME280 or BMP180 uses the same address, and the library cannot notice it. Look at the print on your module.
- The pressure is about 500 hPa: your module has an MS5607 chip. Add ms5611.reset(1); between ms5611.begin() and setOversampling().
- The plotter stays empty: open the Serial Monitor to see if an error message is there. Also check the COM port and 9600 baud.
What comes next? Connect a knob from the Arduino Giga R1 WiFi - Potentiometer guide and use its value for LEVEL (as a variable, not a const). Or show the smooth pressure on the Arduino Giga R1 WiFi - OLED Display, where a value without trembling digits is much easier to read.