Arduino UNO Q - MS5611 Pressure Sensor

Before a storm comes, the air pressure often falls for some hours. The sky may still be blue, and you feel nothing. An MS5611 pressure sensor notices it, because it can measure even very small pressure changes. On this page, you turn the Arduino UNO Q into a storm watcher. The STM32 MCU reads the sensor once per second. The Linux side remembers the last 3 hours and writes to you on Telegram when the pressure falls too fast.

What you will do, step by step:

The wiring diagram between Arduino UNO Q, MS5611 pressure sensor module, its pinout and the I2C

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×MS5611 Pressure Sensor Module
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno
1×Recommended: Sensors/Servo Expansion Shield for Arduino Uno
1×Recommended: Breadboard Shield for Arduino Uno
1×Recommended: Enclosure for Arduino Uno
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of the MS5611 Pressure Sensor

The DIYables GY-63 module carries the MS5611-01BA03, an air pressure chip from TE Connectivity. You may also meet it under the names barometer, barometric pressure sensor, altimeter or altitude sensor. It works in air only, so it is not the right part for water pressure or car tires.

How it works. The shiny metal can hides a very thin plate of silicon, called a membrane. When the air pushes harder, the plate bends a little more. The chip measures this bend with a 24-bit converter. It also measures its own temperature, because the pressure value must be corrected with it.

What changes the air pressure? Two things:

  • The weather. The pressure of one place goes up and down from day to day. This is what our storm watcher uses.
  • The height. Higher up there is less air above us. Near sea level, every metre up takes away about 0.12 hPa (1 hPa = about 8.3 m). So the same sensor can also tell the altitude.

The unit is hPa (hectopascal). Weather reports often write mbar, and it is the same number. The standard pressure at sea level is 1013.25 hPa.

Property MS5611 (GY-63) module
Smallest pressure change (resolution) 0.012 hPa, about 10 cm of height
Pressure accuracy ±1.5 hPa at 25 °C, between 700 and 1100 hPa
Measuring range 10 to 1200 hPa, with full accuracy between 450 and 1100 hPa
Working temperature -40 to 85 °C
Accuracy of the temperature ±0.8 °C (at 25 °C)
Speed one pressure conversion takes about 9 ms at the best resolution
Bus I2C up to 400 kHz (this is the default), or SPI
Address on the I2C bus 0x77, or 0x76 when CSB is at 3.3V
Power 3.3V to 5V, a 3.3V regulator is on the module
Size about 19 mm x 13 mm

Compare two rows: the resolution is 0.012 hPa, but the accuracy is ±1.5 hPa. So the number on the screen may be about 1 hPa off, but it follows every small change. For a storm watcher, only the change counts. The bot subtracts two readings of the same sensor, and a fixed error drops out. (Weather reports give the pressure for the sea level. If you live higher, your sensor shows less, and this is normal.)

MS5611 GY-63 module pinout with VCC, GND, SCL, SDA, CSB, SDO and PS

Four of the seven pins do all the work on this page:

  • VCC: power. Connect it to 3.3V of the Arduino UNO Q
  • GND: ground, 0V
  • SCL: the clock line of I2C
  • SDA: the data line of I2C

The other three stay empty:

  • CSB: sets the I2C address. Leave it empty (or tie it to GND) for 0x77, tie it to 3.3V for 0x76. So two modules can share one bus. SPI uses this pin as chip select
  • SDO: data out in SPI mode. I2C does not use it
  • PS: chooses between I2C and SPI. The module pulls it HIGH with a resistor, so I2C is already chosen. GND would choose SPI

Both CSB and PS belong to the 3.3V chip. Should one of them need a HIGH level one day, use 3.3V and never 5V.

What does the pressure say about the weather? A simple rule of thumb:

The pressure is What often comes next
rising steadily, or high fair weather
falling clouds, wind or rain
falling 3 hPa or more in 3 hours a strong weather change

The last row is the rule that the Telegram bot checks.

※ NOTE THAT:

Where to put the sensor. A normal room is fine, because the pressure in a house follows the pressure outside. Sunlight and wind spoil the reading, so choose a shady corner, away from fans and open windows. A bit of open foam (air must pass through it) on top of the metal can keeps the wind off. The can has two small holes: never close them, and keep them dry.

Wiring Diagram

Four wires are enough. You need no extra resistors: the module has its own pull-up resistors on SCL and SDA.

The wiring diagram between Arduino UNO Q MS5611 pressure sensor

This image is created using Fritzing. Click to enlarge image

MS5611 Pin Arduino UNO Q MCU
VCC 3.3V
GND GND
SCL SCL
SDA SDA
CSB, SDO, PS leave empty

※ NOTE THAT:

VCC goes to 3.3V, not to 5V. The module accepts 5V, but its SCL and SDA lines follow VCC: with 5V on VCC, it pulls both lines up to 5V. The MCU pins of the Arduino UNO Q work at 3.3V, so 3.3V is the right choice.

SCL and SDA are the two pins at the end of the digital header, next to AREF. In the diagram, the 3.3V pin has the tag 3V3.

A storm watcher runs for weeks, and one loose wire would stop it. Two shields help here: the Proto Screw Terminal Block Shield and the Screw Shield V2. Plug one of them onto the Arduino UNO Q and clamp the power wires under screws. The pins are the same as before.

The wiring diagram between Arduino UNO Q MS5611 pressure sensor Screw Shield

This image is created using Fritzing. Click to enlarge image

Look at the upper left part of this diagram: on the Screw Shield V2, SDA and SCL have no screw terminals. Push these two wires into the SDA and SCL header holes of the shield, as the diagram shows. Only 3.3V and GND go under screws.

How To Program For MS5611

The MS5611 library by Rob Tillaart talks to the sensor and does the pressure math. Your sketch only opens the I2C bus for it.

  1. Include both libraries and create the sensor. 0x77 is its address (tie CSB to 3.3V and it is 0x76):
#include <Wire.h> #include <MS5611.h> MS5611 ms5611(0x77);
  1. In setup(), Wire.begin() comes first. begin() then returns false when no sensor answers at this address:
Wire.begin(); if (!ms5611.begin()) { Serial.println("MS5611 not found"); }
  1. Set the oversampling. The default is fast but noisy (0.065 hPa). With OSR_ULTRA_HIGH, the noise is only 0.012 hPa:
ms5611.setOversampling(OSR_ULTRA_HIGH);
  1. Take a reading. It needs about 20 ms. When it is good, get the values:
if (ms5611.read() == MS5611_READ_OK) { Serial.println(ms5611.getPressure()); // hPa Serial.println(ms5611.getTemperature()); // °C }
  1. For the altitude, write the present sea-level pressure of your area (from a weather website) in the brackets:
float altitude = ms5611.getAltitude(1013.25); // m above sea level
  1. Want a steadier pressure? Let it go only one tenth of the way to each new reading:
pressure += (ms5611.getPressure() - pressure) / 10;

Arduino UNO Q Code

Start with the sensor alone, without Linux and without Telegram:

  • The STM32 MCU owns the SDA and SCL pins, so it reads the MS5611
  • The Qualcomm MPU with Debian Linux has nothing to do yet. Its turn comes in the Bridge section
  • The sketch prints pressure, temperature and altitude about once per second
/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-ms5611-pressure-sensor */ // Arduino UNO Q - MS5611 (GY-63) pressure sensor: pressure, temperature and altitude // Wiring: VCC -> 3.3V, GND -> GND, SCL -> SCL, SDA -> SDA (CSB, SDO and PS stay empty) // The STM32 MCU of the Arduino UNO Q reads the sensor over I2C. The Linux side is not used here. // Library: "MS5611" by Rob Tillaart #include <Wire.h> #include <MS5611.h> #define SEA_LEVEL_HPA 1013.25 // today's sea-level pressure of your area, in hPa MS5611 ms5611(0x77); // 0x76 when CSB is tied to 3.3V void setup() { Serial.begin(115200); delay(1500); Wire.begin(); // I2C on the SDA and SCL pins if (!ms5611.begin()) { Serial.println("MS5611 not found - check the 4 wires"); while (true) { delay(1000); // stop here } } ms5611.setOversampling(OSR_ULTRA_HIGH); // the steadiest values Serial.println("Arduino UNO Q MS5611 ready, I2C address 0x" + String(ms5611.getAddress(), HEX)); } void loop() { if (ms5611.read() == MS5611_READ_OK) { // takes about 20 ms Serial.print("Pressure: "); Serial.print(ms5611.getPressure(), 2); Serial.print(" hPa | Temperature: "); Serial.print(ms5611.getTemperature(), 2); Serial.print(" °C | Altitude: "); Serial.print(ms5611.getAltitude(SEA_LEVEL_HPA), 1); Serial.println(" m"); } else { Serial.println("The MS5611 does not answer - check the wires"); } delay(1000); // about one line per second }

Detailed Instructions

New to this board? Prepare Arduino App Lab with Getting Started with Arduino UNO Q.

  • Check the wires: VCC to 3.3V, GND to GND, SCL to SCL, SDA to SDA.
  • Connect the Arduino UNO Q to the computer with the USB-C cable.
  • Open Arduino App Lab and wait until it shows your board.
  • Create an App: Click Create New App.
Create a new App for the MS5611 sketch in Arduino App Lab
  • Give it the name MS5611Pressure and click Create.
Files of the new MS5611 App in Arduino App Lab
  • Paste the sketch: Open sketch/sketch.ino, remove everything in it, and paste the code above.
  • Add the library: Its name is just MS5611, its author is Rob Tillaart. MS5611_SPI and similar names are different libraries.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
Add sketch library in Arduino App Lab on Arduino UNO Q
  • Search for MS5611 created by Rob Tillaart and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
MS5611 Rob Tillaart

Experimental, GY-63, GY63, MS5607,altitude.

0.5.2
Install
More Info
  • Run: Click the Run button.
Run button that uploads the MS5611 sketch in Arduino App Lab
  • Lift it: Leave the board on the table for a few lines. Then lift it about 2 m up, with the sensor on it, and put it back.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-11-24 09:17:20] Arduino UNO Q MS5611 ready, I2C address 0x77 [2026-11-24 09:17:20] Pressure: 1008.93 hPa | Temperature: 25.42 °C | Altitude: 36.0 m [2026-11-24 09:17:21] Pressure: 1008.94 hPa | Temperature: 25.42 °C | Altitude: 35.9 m [2026-11-24 09:17:22] Pressure: 1008.92 hPa | Temperature: 25.43 °C | Altitude: 36.1 m [2026-11-24 09:17:23] Pressure: 1008.80 hPa | Temperature: 25.43 °C | Altitude: 37.1 m [2026-11-24 09:17:24] Pressure: 1008.69 hPa | Temperature: 25.43 °C | Altitude: 38.0 m [2026-11-24 09:17:25] Pressure: 1008.70 hPa | Temperature: 25.42 °C | Altitude: 37.9 m [2026-11-24 09:17:26] Pressure: 1008.95 hPa | Temperature: 25.42 °C | Altitude: 35.8 m

Two metres up, the pressure is about 0.24 hPa lower, and the altitude is 2 m higher. If you see this, the sensor works.

If a Number Looks Wrong

  • The altitude is wrong by some metres. The sketch uses 1013.25 hPa for the sea level, but the real value changes every day. Each hPa of difference moves the altitude by about 8.3 m. Look for the sea-level pressure of your area (QNH) on a weather website or in an airport report, and write it into SEA_LEVEL_HPA.
  • "MS5611 not found", but the wires are right. Your module may use the other address. Try 0x76 in the line MS5611 ms5611(0x77);.
  • All values are nonsense. Look at the print on the module. A BMP280, BME280 or BMP180 has the same address, and begin() may accept it. This library cannot read these chips.
  • The pressure is about 500 hPa. Some modules carry a MS5607 chip. Add ms5611.reset(1); right after a successful begin(), in both sketches of this page.
  • The temperature is 1 to 3 °C too high. This is the temperature of the chip, and the board warms it a bit. It is there to correct the pressure. For the room, use a DHT22.
  • The pressure jumps. Wind or a fan blows on the module. Move it to a calm place, or use the foam.

Bridge: Linux + MCU

The sensor hangs on the I2C pins of the MCU, so Linux cannot reach it. But Wi-Fi and Telegram belong to the Linux side. Bridge connects the two halves:

  • The MCU reads once per second and keeps the latest values. The sketch smooths the pressure and the altitude. One short gust of wind then changes very little
  • Four read-only values are offered with Bridge.provide():
    • get_pressure - the pressure in hPa, like 1012.46
    • get_temperature - the chip temperature in °C, like 24.9
    • get_altitude - the altitude in m, like 6.6
    • get_status - one status, see the table below
  • Python asks with Bridge.call(). It gets the last value at once and never waits for the sensor
  • No restart needed: as long as the sensor is missing, the MCU looks for it again every second
  • Reserved: /dev/ttyHS1 on Linux and Serial1 on the MCU belong to the Arduino router. Never open them in your own code
Status Meaning What to do
STARTING no reading yet wait a second or two
OK the values are fresh nothing
NOT FOUND no sensor answers at the address of the sketch check the four wires and the address
NO ANSWER the sensor worked before, then went silent look for a loose wire

Never used Bridge? Arduino UNO Q - Communication Between Linux and MCU explains the basics.

MCU Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-ms5611-pressure-sensor */ // Arduino UNO Q - MS5611 (GY-63) pressure sensor, shared with Linux via Bridge // Wiring: VCC -> 3.3V, GND -> GND, SCL -> SCL, SDA -> SDA (CSB, SDO and PS stay empty) // The MCU reads the sensor every second and keeps the latest values. // Python on Linux only asks for these values. It never talks to the sensor itself. // Library: "MS5611" by Rob Tillaart #include "Arduino_RouterBridge.h" #include <Wire.h> #include <MS5611.h> #define SEA_LEVEL_HPA 1013.25 // today's sea-level pressure of your area, in hPa #define SMOOTHING 10 // 1 = off, a bigger number gives a steadier but slower pressure MS5611 ms5611(0x77); // 0x76 when CSB is tied to 3.3V float pressure = 0.0; // latest good values: hPa float temperature = 0.0; // °C float altitude = 0.0; // m const char* sensor_status = "STARTING"; // or "OK", "NOT FOUND", "NO ANSWER" bool sensor_found = false; bool first_reading = true; unsigned long last_read_ms = 0; // Read-only values for Python. They return what is already in memory, so they never wait. String get_pressure() { return String(pressure, 2); } String get_temperature() { return String(temperature, 1); } String get_altitude() { return String(altitude, 1); } String get_status() { return String(sensor_status); } // Look for the sensor. loop() comes back here every second until it is found. void find_sensor() { if (ms5611.begin()) { sensor_found = true; first_reading = true; Monitor.println("MS5611 found, I2C address 0x" + String(ms5611.getAddress(), HEX)); } else { sensor_status = "NOT FOUND"; Monitor.println("MS5611 problem: " + String(sensor_status)); } } void read_sensor() { if (ms5611.read() != MS5611_READ_OK) { sensor_status = "NO ANSWER"; sensor_found = false; // start the sensor again in the next second Monitor.println("MS5611 problem: " + String(sensor_status)); return; } // The first reading is taken as it is. Later ones move the value by 1/SMOOTHING of the difference. int divider = first_reading ? 1 : SMOOTHING; pressure += (ms5611.getPressure() - pressure) / divider; altitude += (ms5611.getAltitude(SEA_LEVEL_HPA) - altitude) / divider; temperature = ms5611.getTemperature(); first_reading = false; sensor_status = "OK"; } void setup() { Bridge.begin(); Monitor.begin(); Wire.begin(); // I2C on the SDA and SCL pins ms5611.setOversampling(OSR_ULTRA_HIGH); // the steadiest values Bridge.provide("get_pressure", get_pressure); Bridge.provide("get_temperature", get_temperature); Bridge.provide("get_altitude", get_altitude); Bridge.provide("get_status", get_status); Monitor.println("Arduino UNO Q MS5611 Bridge ready"); } void loop() { if (millis() - last_read_ms < 1000) { return; // one round per second } last_read_ms = millis(); if (sensor_found) { read_sensor(); } else { find_sensor(); } }

Python Code (Bridge)

This script asks for the values every 10 seconds. It also shows how far the pressure has moved since the App was started.

""" This Arduino UNO Q script was developed by newbiely.com This Arduino UNO Q script is made available for public use without any restriction For comprehensive instructions and wiring diagrams, please visit: https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-ms5611-pressure-sensor """ from arduino.app_utils import * import time # Linux side: ask the MCU for the MS5611 values every 10 seconds. # Python remembers the first pressure and shows how far the pressure has moved since then. start_pressure = None def loop(): global start_pressure status = str(Bridge.call("get_status")) if status != "OK": # "STARTING", "NOT FOUND" or "NO ANSWER" print(f"No reading yet, sensor status: {status}") time.sleep(2) return pressure = float(str(Bridge.call("get_pressure"))) # hPa, e.g. 1012.47 temperature = float(str(Bridge.call("get_temperature"))) # °C, e.g. 25.1 altitude = float(str(Bridge.call("get_altitude"))) # m, e.g. 6.5 if start_pressure is None: start_pressure = pressure change = pressure - start_pressure print(f"{pressure:.2f} hPa ({change:+.2f} since start), {temperature:.1f} °C, altitude {altitude:.1f} m") time.sleep(10) App.run(user_loop=loop)

Detailed Instructions

  • Second App: Create a new App in Arduino App Lab and call it StormWatcher.
  • MCU part: Paste the MCU code into sketch/sketch.ino and add two libraries:
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
Add sketch library in Arduino App Lab on Arduino UNO Q
  • Search for MS5611 created by Rob Tillaart and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
MS5611 Rob Tillaart

Experimental, GY-63, GY63, MS5607,altitude.

0.5.2
Install
More Info
  • Search for Arduino_RouterBridge created by Arduino and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Arduino_RouterBridge Arduino

This library provides a simple RPC bridge for Arduino UNO Q boards, allowing communication between the board and other devices using MsgPack serialization.

0.4.1
Install
More Info
  • Linux part: Put the Python code into the Python file of this App.
  • Run the App and leave it alone for an hour or two.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-11-24 13:02:15] Arduino UNO Q MS5611 Bridge ready [2026-11-24 13:02:15] MS5611 found, I2C address 0x77
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-11-24 13:02:16] No reading yet, sensor status: STARTING [2026-11-24 13:02:18] 1012.46 hPa (+0.00 since start), 24.9 °C, altitude 6.6 m [2026-11-24 13:02:28] 1012.44 hPa (-0.02 since start), 24.9 °C, altitude 6.7 m [2026-11-24 13:02:38] 1012.45 hPa (-0.01 since start), 24.9 °C, altitude 6.7 m [2026-11-24 13:37:08] 1012.03 hPa (-0.43 since start), 25.2 °C, altitude 10.2 m [2026-11-24 14:11:38] 1011.52 hPa (-0.94 since start), 25.3 °C, altitude 14.4 m [2026-11-24 14:46:08] 1011.01 hPa (-1.45 since start), 25.3 °C, altitude 18.7 m [2026-11-24 15:02:08] 1010.77 hPa (-1.69 since start), 25.1 °C, altitude 20.7 m

Only a few of the lines are shown. The pressure went down by 1.69 hPa in two hours, so clouds or rain may come, but it is not a storm alert yet. Look at the altitude too: it "climbed" 14 m, but the board never left the table. That was the weather. For this reason, the storm watcher works with the pressure and not with the altitude.

Telegram

Nobody wants to watch a console all day. The bot does it for you. It answers three commands, and it writes by itself when the pressure falls too fast.

Command Answer
/pressure the air pressure now, in hPa
/temperature the temperature of the sensor chip, in °C
/status the pressure, the fall in the last 3 hours and the state of the alert

How the bot decides:

  • Once per minute it stores a pair in a small list: the time and the pressure. Pairs older than 3 hours are thrown away, so the list has at most about 180 entries
  • Fall = the highest pressure in the list minus the newest one
  • A fall of 3.0 hPa or more sends the alert. After that the bot stays quiet, even if the pressure keeps falling. One storm, one alert
  • When the fall gets smaller than 1.0 hPa, the event is over. The pressure has gone up again, or it has been steady for a long time. The bot sends a short message, and the alert is ready for the next storm

Here is one afternoon in numbers. The last two columns show what the bot computes and does:

Time after start Pressure now Highest of the last 3 hours Fall Bot
1 hour 1012.30 1012.42 0.12 quiet
2 hours 1011.60 1012.42 0.82 quiet
3 hours 1010.50 1012.42 1.92 quiet
3 h 44 min 1009.33 1012.33 3.00 sends the alert
5 h 30 min 1006.61 1011.05 4.44 quiet, the alert was sent already
7 h 13 min 1007.51 1008.50 0.99 event over, ready again

MCU sketch: It is the same sketch as in the Bridge section. Do not change it.

Python Code (Telegram)

""" This Arduino UNO Q script was developed by newbiely.com This Arduino UNO Q script is made available for public use without any restriction For comprehensive instructions and wiring diagrams, please visit: https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-ms5611-pressure-sensor """ from arduino.app_utils import * import requests import time # Linux side: a Telegram storm watcher for the MS5611 pressure sensor. # It keeps one pressure reading per minute for the last 3 hours. # When the pressure has fallen by 3.0 hPa or more inside these 3 hours, it sends ONE alert. # Keep the MCU sketch from the Bridge section. TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" # the alerts go to this chat API_URL = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}" WINDOW_SECONDS = 3 * 60 * 60 # how far the bot looks back (3 hours) SAMPLE_SECONDS = 60 # store one reading per minute STORM_FALL = 3.0 # hPa, a fall of this size (or more) sends the alert CALM_FALL = 1.0 # hPa, below this the event is over and the alert is ready again readings = [] # (time, pressure) pairs, the oldest one first storm_alert = False # True from the alert until the event is over last_update_id = 0 HELP_TEXT = ( "Arduino UNO Q Storm Watcher\n" "/pressure - air pressure now\n" "/temperature - temperature of the sensor chip\n" "/status - pressure, fall in the last 3 hours, alert state\n" f"Automatic alert after a fall of {STORM_FALL} hPa within 3 hours." ) def get_updates(): try: resp = requests.get(f"{API_URL}/getUpdates", params={"offset": last_update_id + 1, "timeout": 5}, timeout=10) data = resp.json() if data.get("ok"): return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): try: requests.post(f"{API_URL}/sendMessage", data={"chat_id": chat_id, "text": text}, timeout=10) except Exception as e: print(f"Error sending message: {e}") def read_value(name): return float(str(Bridge.call(name))) def pressure_fall(): # How far the newest reading is below the highest one in the list highest = max(pressure for _, pressure in readings) return highest - readings[-1][1] def watch_pressure(): global storm_alert now = time.monotonic() # seconds, not changed when Linux corrects its clock if readings and now - readings[-1][0] < SAMPLE_SECONDS: return # the last reading is still fresh if str(Bridge.call("get_status")) != "OK": return # no valid reading, try again in the next round readings.append((now, read_value("get_pressure"))) while now - readings[0][0] > WINDOW_SECONDS: readings.pop(0) # older than 3 hours pressure = readings[-1][1] fall = pressure_fall() if fall >= STORM_FALL and not storm_alert: storm_alert = True alert = (f"Storm watch! {pressure:.1f} hPa now. The pressure fell {fall:.1f} hPa within 3 hours. " "A strong weather change is likely.") elif fall < CALM_FALL and storm_alert: storm_alert = False alert = f"{pressure:.1f} hPa now. The fast fall is over. The storm alert is ready again." else: return # nothing new to say print(alert) send_message(CHAT_ID, alert) def handle(text): if text not in ("/pressure", "/temperature", "/status"): return HELP_TEXT status = str(Bridge.call("get_status")) if status != "OK" or not readings: return f"No reading, sensor status: {status}" if text == "/pressure": return f"Pressure: {read_value('get_pressure'):.1f} hPa" if text == "/temperature": return f"Temperature: {read_value('get_temperature'):.1f} °C" minutes = (readings[-1][0] - readings[0][0]) / 60 alert_state = "sent" if storm_alert else "ready" return (f"Pressure: {readings[-1][1]:.1f} hPa\n" f"Fall: {pressure_fall():.1f} hPa in the last {minutes:.0f} min\n" f"Storm alert: {alert_state}") def loop(): global last_update_id watch_pressure() for update in get_updates(): # waits up to 5 seconds for a message last_update_id = update["update_id"] if "message" not in update: continue chat_id = update["message"]["chat"]["id"] text = update["message"].get("text", "").strip().lower() print(f"Received: {text}") send_message(chat_id, handle(text)) time.sleep(1) App.run(user_loop=loop)

Detailed Instructions

  • Make a bot: Get a token from @BotFather and find your chat ID. Both are explained in How to Create a Telegram Bot.
  • Open the StormWatcher App and replace its Python code with the bot script.
  • Fill in TELEGRAM_BOT_TOKEN and CHAT_ID. The alerts go to this chat.
  • Run the App and send /pressure to your bot.
  • Test without a storm: Set STORM_FALL = 0.15, CALM_FALL = 0.05 and SAMPLE_SECONDS = 5, and run again. Leave the board on the floor for one minute. Then hold it about 2 m up for half a minute: the bot sends the alert. Put it back on the floor: the bot says that the event is over.
  • Put back the numbers 3.0, 1.0 and 60 after the test.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-11-25 14:16:08] Received: /pressure [2026-11-25 14:17:09] Received: /temperature [2026-11-25 16:01:11] Received: /status [2026-11-25 16:25:12] Storm watch! 1009.3 hPa now. The pressure fell 3.0 hPa within 3 hours. A strong weather change is likely. [2026-11-25 18:11:12] Received: /status [2026-11-25 19:54:13] 1007.5 hPa now. The fast fall is over. The storm alert is ready again.
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
/pressure
10:15 AM ✓✓
Pressure: 1011.9 hPa
10:16 AM
/temperature
10:17 AM ✓✓
Temperature: 24.6 °C
10:18 AM
/status
10:19 AM ✓✓
Pressure: 1010.0 hPa Fall: 2.4 hPa in the last 179 min Storm alert: ready
10:20 AM
Storm watch! 1009.3 hPa now. The pressure fell 3.0 hPa within 3 hours. A strong weather change is likely.
10:21 AM
/status
10:22 AM ✓✓
Pressure: 1006.6 hPa Fall: 4.4 hPa in the last 179 min Storm alert: sent
10:23 AM
1007.5 hPa now. The fast fall is over. The storm alert is ready again.
10:24 AM

The alert came at 16:25, when the fall reached 3.0 hPa. The pressure kept going down for two more hours, but there was no second alert.

※ NOTE THAT:

  • Do not move the board while the bot runs. Three storeys up is about 9 m, and this already looks like a fall of 1 hPa.
  • The list lives in memory. After a restart of the App, the bot starts with an empty list.
  • This is a hobby project. In dangerous weather, follow the official warnings.

OpenClaw

You can adapt the OpenClaw to this tutorial by refering the instruction on Arduino Uno Q - OpenClaw Tutorial

Project Ideas

More things to do with a barometer that has Linux and Wi-Fi next to it:

  • Barometer on the Wall: Show the pressure and an arrow (up, steady, down) on an OLED display. Python computes the arrow and sends it to the MCU.
  • Pressure Diary: Python saves one line per hour to a CSV file and draws the curve of the week.
  • Elevator Meter: Save the pressure of the ground floor in a variable. Then getAltitude() with this variable tells how high the elevator has gone.
  • Fishing Helper: The bot sends the pressure and its change every morning at 5 o'clock, before you leave.
  • Window Closer: On a storm alert, Python asks the MCU to switch a relay, and a motor closes the roof window.

Challenge Yourself

Three tasks, from small to big:

  • Easy: Add the pressure in mmHg to the first sketch (1 hPa = 0.750062 mmHg).
  • Medium: Save the list of readings in a file on the Linux side, so a restart of the App does not empty it. Tip: use time.time() then, because time.monotonic() starts again after a reboot.
  • Advanced: Weather reports give the pressure for the sea level. Add a Bridge value get_sea_level that uses getSeaLevelPressure(pressure, 120), where 120 is the altitude of your home in metres, add a /sealevel command, and compare its answer with the nearest weather station.

Function References

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!