Arduino Nano 33 IoT - MS5611 Pressure Sensor
In a holiday cabin or on a boat, there is often no internet and no fresh weather forecast. But you can measure one storm sign yourself: the air pressure. It often goes down for hours before the bad weather arrives. This tutorial instructs you how to use Arduino Nano 33 IoT and an MS5611 pressure sensor (the module is also sold as GY-63) to build a storm early-warning box for the window sill. The box remembers the pressure of the moment when you switch it on. After that, it tells you every 10 seconds how far the pressure has moved, and adds one word. In detail, we will learn:
- What the MS5611 measures, and which four of its seven pins must be connected to the Arduino Nano 33 IoT
- Why the module takes its power from the 3V3 pin of this board, and why VUSB stays empty
- How to program the Arduino Nano 33 IoT to read the air pressure and the chip temperature
- How to compare the pressure with the value at power-on and print steady, rising, falling or falling fast
- How to start a new comparison with the reset button

We suggest:
- Trying the Arduino Nano 33 IoT - Rain Sensor tutorial if a message at the first drops of rain is early enough for you.
- Going to the Arduino Nano 33 IoT - DHT22 tutorial if you want the temperature and the humidity of the cabin. The MS5611 only knows how warm its own chip is.
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 finished project, look for a small plastic box and make some holes in its side. The air must get in, because an airtight box also keeps the pressure change out.
Overview of MS5611 Pressure Sensor and Its Pinout

The MS5611 is a digital barometer. On the blue DIYables module, it is the metal can with two tiny holes. TE Connectivity makes the chip, and its full name is MS5611-01BA03. The module adds a 3.3V regulator, a level shifter and the resistors for the I2C bus.
The air goes through the holes into the can. Inside, it presses on a thin silicon membrane, and the membrane bends by a very small amount. A 24-bit converter measures this bend, and the library turns the result into a pressure in hPa (hectopascal). Some weather maps say mbar, and this is the same number. The standard value at sea level is 1013.25 hPa. Higher up, there is less air above us, so the pressure is lower. That is why shops also call this module an altimeter or an altitude sensor.
| DIYables MS5611 Module (GY-63) | |
|---|---|
| It measures | the air pressure, and the temperature of its own chip |
| Range of the pressure | 10 to 1200 hPa (full accuracy from 450 to 1100 hPa) |
| Resolution of the pressure | 0.012 hPa |
| Accuracy of the pressure | ±1.5 hPa (at 25°C, from 700 to 1100 hPa) |
| Temperature | from -40°C to 85°C, ±0.8°C at 25°C |
| Supply voltage | from 3.3V to 5V, in this tutorial 3.3V |
| Talks over | I2C with up to 400 kHz (SPI is also possible) |
| Address on the I2C bus | 0x77 (default) or 0x76 |
| Size | about 19 x 13 mm |
With I2C, only the first four pins are in use:
- VCC pin: must be connected to the 3.3V pin of the Arduino Nano 33 IoT (3V3 is printed on the board)
- GND pin: must be connected to GND (0V)
- SCL pin: the I2C clock. It must be connected to A5
- SDA pin: the I2C data. It must be connected to A4
The last three stay free in this project:
- CSB pin: decides about the address. A resistor on the module pulls it to GND, which gives 0x77. With 3.3V on CSB, the address is 0x76. In SPI mode, it is the chip select pin.
- SDO pin: gives out the data in SPI mode, and does nothing in I2C mode
- PS pin: HIGH means I2C, GND means SPI. A resistor on the module keeps it HIGH.
※ NOTE THAT:
Not every MS5611 module has its pins in this order, so trust the names printed on your own board. And if CSB or PS ever needs a HIGH level, take it from 3V3. These pins lead to the 3.3V chip, and 5V is too much for it.
What a Falling Pressure Means
Fair weather usually belongs to the high pressure areas of a weather map, and clouds, wind and rain belong to the low ones. If the pressure at your window goes down, a low is probably coming closer. The box uses these four words:
| Word | Change since power-on | What you can expect |
|---|---|---|
| rising | more than 1 hPa up | fair weather is likely |
| steady | not more than 1 hPa up or down | no sign of a change yet |
| falling | more than 1 hPa down | clouds, wind or rain are likely |
| falling fast | 3 hPa down or more | a strong weather change, if the drop took 3 hours or less |
The accuracy of ±1.5 hPa is no problem here. The box subtracts two values of the same sensor, and both contain nearly the same error.
※ NOTE THAT:
This is only a rule of thumb. A summer thunderstorm can also come without a clear drop. Before you go out on the water, always check the official storm warning.
Wiring Diagram
The MS5611 needs two signal wires and two power wires. A4 and A5 are the I2C pins of the Arduino Nano 33 IoT, and 3V3 and GND give the power:

This image is created using Fritzing. Click to enlarge image
| MS5611 Module | Arduino Nano 33 IoT |
|---|---|
| VCC | 3.3V (3V3) |
| GND | GND |
| SCL | A5 |
| SDA | A4 |
| CSB, SDO, PS | leave them free |
※ NOTE THAT:
- Why not the VUSB (5V) pin? The module raises SCL and SDA to the voltage on its VCC pin. With 5V on VCC, you get 5V on A4 and A5. The pins of the Arduino Nano 33 IoT work at 3.3V and are not 5V tolerant. So use 3V3, even if the VUSB solder jumper on your board is closed.
- Do not add resistors. SCL and SDA already have their pull-ups on the module.
- Two chips on the Arduino Nano 33 IoT itself use the same I2C bus: the motion sensor (0x6A) and the crypto chip (0x60). They do not disturb the MS5611, because its address is 0x77.
On a boat, the waves shake every wire, and a jumper wire may slip out just before the storm. Screws hold it much better. Plug the Arduino Nano 33 IoT into a Screw Terminal Expansion Board for Arduino Nano and put the wires under the screws 3V3, GND, A5 and A4:

This image is created using Fritzing. Click to enlarge image
One of the screws has the name 5V. With this board it leads to VUSB, so no wire goes there.
A Good Place for the Box
- Inside is fine. A cabin has many small gaps, so the pressure inside follows the pressure outside.
- No direct sun and no wind, because both disturb the reading. Choose a window on the shady side, and lay a piece of open foam over the metal can.
- Keep it dry. Water must not get into the two holes of the can, and nothing may close them. The MS5611 is made for air only, not for water or tires.
- Leave it where it is. The pressure also depends on the height: near sea level, it is about 0.12 hPa lower for each meter up. A walk 25 m up the hill is 3 hPa, and the box would call it a storm.
- A boat goes up and down with the tide, and this is no problem. Even a tide of 4 m is only 0.48 hPa, so the word is still "steady".
How To Program For MS5611 Pressure Sensor
- The first step is to include two libraries. Wire takes care of I2C, and MS5611 by Rob Tillaart knows the sensor:
- Create the sensor object with its address. If CSB is on 3.3V, write 0x76 instead:
- Start I2C in setup(), and only then the sensor. begin() returns false if nothing answers at this address:
- Choose the resolution. The library has five levels and begins with the lowest one, where the pressure jumps about five times more. This line takes the highest:
- Measure once. read() waits for the sensor, about 20 ms. If it returns MS5611_READ_OK, get the results:
- The storm box also makes the pressure calm. It calls read() in every loop() and gets about 50 readings per second. Each of them moves the value by only 1/200 of the difference:
Arduino Nano 33 IoT Code for MS5611 Pressure Sensor
First, we make sure that the sensor works. This sketch prints the pressure and the temperature of the chip every 2 seconds. It waits until the Serial Monitor is open, so you do not miss the first line.
Detailed Instructions
Is the board new to you? Then read Arduino Nano 33 IoT - Getting Started first.
- Wire the components as shown in the diagram, with VCC on 3V3.
- Connect the Arduino Nano 33 IoT board to your computer using a Micro USB cable.
- Open Arduino IDE on your computer.
- Select Arduino Nano 33 IoT and the COM port that belongs to it.
- Click the Library Manager icon on the left side of the Arduino IDE.
- Search for MS5611. Several libraries appear. The one you need has exactly this name and is made by Rob Tillaart (not MS5611_SPI or MS5xxx).
- Click its Install button. It does not ask for other libraries.
- Search for MS5611 created by Rob Tillaart
and click the Install button.
- Copy the code above, paste it into the Arduino IDE and click the Upload button.
- Open the Serial Monitor and choose 9600 baud.
- After three lines, hold the corner with the big round hole between two fingers, and warm it up:
The chip got almost 3°C warmer, but the pressure only moved in its last digits. This is the job of the temperature: the library uses it to correct the pressure. It is not the temperature of the room: even without your fingers, the board makes the chip 1°C to 3°C warmer.
Does 951 hPa look low to you? Our cabin is in the hills, 540 m above the sea, and at the coast, 985 to 1025 hPa are normal. Weather reports give the pressure at sea level. To compare with them, print ms5611.getSeaLevelPressure(ms5611.getPressure(), 540) with the height of your own place. Here it gives about 1014.8 hPa.
Arduino Nano 33 IoT Code for a Storm Early-Warning Box
Now the sensor gets its task. The sketch does three things:
- At power-on, it takes 200 readings in about 4 seconds. Their average is the start value.
- After that, it takes one reading after the other and smooths them over about 4 seconds. A slamming door hardly counts.
- Every 10 seconds, it prints the start value, the pressure now, the change, the minutes since power-on and the word from the table.
Detailed Instructions
- The wires and the library stay the same. Put the module in its place before you go on.
- Upload the second code and open the Serial Monitor:
- Let the box work, and look at it from time to time. Here are some lines from an afternoon with a storm at its end:
A drop of more than 3 hPa in less than 3 hours is a clear message: bring the chairs in, close the windows and check the ropes of the boat.
No storm in sight? Then carry the laptop and the box up the stairs, about 12 m (four floors). The change goes to about -1.4 hPa, and the word becomes "falling".
Start Again with the Reset Button
The box compares with one moment only, the moment of power-on. The older this moment is, the less the word means. A drop of 3 hPa in two hours is a warning, but the same drop in two days is quite normal. This is why every line shows the minutes.
So start a new comparison when the number of minutes is above 180, when you have moved the box, or before you go to bed. Press the small white reset button on the Arduino Nano 33 IoT once. The sketch runs from the beginning and takes a new start value. This is the next morning, first right after a reset, and then one hour and 44 minutes later:
Three things to know about the restart on this board:
- Press once, not twice. Two quick presses start the upload mode, and the sketch does not run. One more press brings it back.
- The USB connection is gone for a moment. If the Serial Monitor stays silent after that, close it and open it again.
- Opening the Serial Monitor does not restart the sketch, so the start value stays. But it is lost when the power goes off, even for the short moment when you move the USB cable from a charger to the computer.
The box does not remember the hours in between. If the pressure first goes up by 2 hPa and then down by 3 hPa, the change is only -1 hPa, and you do not see "falling fast".
Troubleshooting
- Does the MS5611 not answer? Look at A4 and A5 first, because SDA and SCL are often swapped. Then check 3V3 and GND, and PS must not touch GND. If you run an I2C scanner, 0x60 and 0x6A belong to the Arduino Nano 33 IoT. The scanner must also find 0x77 (or 0x76). If it is 0x76, change the address in the sketch.
- Are the numbers impossible? Read the print on your module. A BMP280, BME280 or BMP180 can have the same address, and begin() does not always notice it. These are different sensors and need different libraries.
- Is the pressure about 500 hPa? There are modules with a MS5607 chip. Add this line in setup(), after the begin() part: ms5611.reset(1);
- Does the pressure jump when the wind blows? The wind really changes the pressure at the can. Close the window, or use the open foam.
Additional Knowledge
Pressure Sensor or Rain Sensor?
Both belong in a weather box, but they do different jobs:
| MS5611 | Rain sensor | |
|---|---|---|
| What it feels | the pressure of the air | water on a plate |
| When it reacts | often some hours before the bad weather | when the first drops fall |
| Its place | inside, dry and in the shade | the plate must be outside |
| What gives a false alarm | carrying it to another height | any other water on the plate |
It is evident that only the MS5611 gives you time to prepare. The rain sensor is better for closing a roof window when the rain begins.
A Warning Lamp on the Board
On a USB charger, there is no Serial Monitor. The built-in LED of the Arduino Nano 33 IoT can show the warning instead. Add one line to setup() of the second sketch:
In loop(), add this line below the one that calculates the change:
The LED is on as long as the word is "falling fast". Remember that it also goes on when you carry the box up a hill.
Project Ideas
- Put the word on an OLED 128x64 display. It uses A4 and A5 too, and its address 0x3C is still free.
- Hear the warning in bed: let a buzzer beep three times when "falling fast" appears for the first time.