|
|
Arduino_Nano_v3.x |
x 1 | |
|
|
16x4 LCD Display |
x 1 | |
|
|
button |
x 1 | |
|
|
BME280 sensor board |
x 1 |
|
Soldering iron |
|
|
Soldering Iron Wire Welding Lead Roll |
Arduino Barometer + Barograph with BME280 Sensor
A barograph is a barometer that records the barometric pressure over time in graphical form. This instrument is also used to make a continuous recording of atmospheric pressure.
The former Barographs use the pressure-sensitive element, which is linked to a pen arm in such a way that the vertical displacement of the pen is proportional to the changes in the atmospheric pressure. This pen marks pressure changes on specially marked paper that is placed on a disc that rotates 360 degrees over 24 hours. In the picture below you can see what a Barograph from the last century looks like.

The barometer and the barograph are basic local instruments (independent of the Internet) in Meteorology that serve to predict the weather. This time I will present you a very simple way, using an Arduino microcontroller, you can make an electronic Barometer + Barograph that presents the results in graphic form on a 20x4 LCD display. The basic project is taken from "cxem.net" by the author AMatroskin, in which I modified and now the pressure is displayed in hPa instead of mmHg, and what is much more important, instead of the Absolute, the Relative Atmospheric Pressure for the specific altitude is displayed, which is a common standard in Meteorology.
For this purpose we need to enter the Relative Standard Atmospheric Pressure for the current altitude (As described further in the text), in the line:
#define SEALEVELPRESSURE_HPA (932.17) // for Ohrid, 698m altitude
and we can calculate that, on one of the online calculators, such as:
https://www.mide.com/air-pressure-at-altitude-calculator
Also further down the line
value = round ((bme.seaLevelForAltitude(698, bme.readPressure())/100))
the current altitude in meters should be entered.

As I mentioned before, the device is very simple to build and contains only a few components:
- Arduino Nano microcontroller
- 20x4 I2C protocol LCD Display
- BME 280 Pressure sensor board
- and one Button
Now let's see how the device works in reality. First of all, it takes 24 hours to draw a complete graph. The display shows the current Relative Atmospheric Pressure, as well as the positive or negative difference in hectopascals, for a given previous time period. This period can be 3,6,12, and 24 hours. Correct interpretation of this difference is the basis for accurate weather prediction. And now a few words about the graph. The maximum number of values on the vertical axis can be 28 (7vertical dots on every of four rows). At the beginning of the code, the range in which the air pressure is read can be changed, i.e. the smallest and the largest value. Depending on these values, the resolution of the graph also changes. For example, if we choose the difference between the minimum and maximum pressure to be 28, then 1 Hectopascal corresponds to one line on the Y axis of the graph. The sixteen values on the X axis represent time, and here the resolution depends on the selected elapsed time value.
Basically, when the pressure rises, an improvement in the weather is expected, and conversely, when it decreases, a worsening of the weather is expected.

And finally, the device is placed in a suitable box made of PVC material with a thickness of 5 mm, and covered with self-adhesive colored wallpaper. Let me mention that the BME280 sensor is placed inside the box, because in this case we measure only the pressure, which is independent of the temperature .
/*
Barometer with digital and graphic display of atmospheric pressure data.
Components: Screen text LCD 2004, platform: arduinio nano/uno (Atmega328 or more), pressure sensor: BME 280.
Amatroskin 2022.
*/
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include "GyverButton.h"
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (933,17) // Set the height
#define BTN_PIN 3 //Button Pin
#define BASE_PERIOD 675000 //Main array acquisition period 675000ms = 11.25 min (*16 bars = 3 hours) maximum graph resolution
#define MIN_VAL 990 //The minimum value displayed on the chart
#define MAX_VAL 1035 //The maximum value displayed on the graph
LiquidCrystal_I2C lcd(0x27, 20, 4); //We create the necessary objects
GButton butt1(BTN_PIN);
Adafruit_BME280 bme;
uint32_t tmr1, tmr2; //timer variables
uint32_t set_period = BASE_PERIOD; //Display period, changes in multiples of 3 hours (3, 6, 12, 24)
int16_t plot_array[20]; //Data array for drawing a chart
uint16_t base_array [128]; //The base array stores all measurements for the last 24 hours (128 cells * 11.25 minutes = 1440 minutes = 24 hours)
int16_t value, delta; //Current (taken) readings, difference in readings for a selected period of time
byte interval = 1; //Interval displayed on the screen (time difference between adjacent chart bars)
// 11.25 min * 16 = 3 hours, 22.5 min - 6 hours, 45 min - 12 hours, 90 min - 24 hours
void setup() {
read_all ();
// Serial.begin(9600);
attachInterrupt(1, isr, CHANGE);
butt1.setDebounce(80); // anti-bounce setting (default 80 ms)
butt1.setTimeout(300); // hold timeout setting (default 500ms)
lcd.init();
lcd.backlight();
lcd.clear();
if (!bme.begin(0x76)) { //Initialization of the BME280 sensor at address 0x76 (default)
//Serial.println("Could not find a valid BME280!");//Printing an Error Message to the Port Monitor
lcd.setCursor(3, 1);
lcd.print(F("No connection")); //___________________________or on the screen
lcd.setCursor(5, 2);
lcd.print(F("to sensor"));
while (1); //won't go without a sensor.
}
if (!digitalRead(BTN_PIN)) { //Reset settings when turned on with the button held down
for (byte i = 0; i < 128; i++) base_array [i] = 0; //Erase data
update_all (); //Save
lcd.setCursor(5, 1); //Report it
lcd.print(F("Reset data"));
lcd.setCursor(9, 2);
lcd.print(F("OK"));
}
while (!digitalRead(BTN_PIN));
lcd.clear();
initPlot(); //Initializing Symbols for Rendering
value = round ((bme.seaLevelForAltitude(700, bme.readPressure())/100));//We take the current readings, convert to mm Hg.
base_array[0] = value;
get_data ();
}
void isr() { //We poll the button in the interrupt to catch the click anyway
butt1.tick();
}
void loop() {
butt1.tick(); //Poll button
if (butt1.isClick()) { //When you press:
interval *= 2; //Switching the chart scale
if (interval > 8) interval = 1;
set_period = BASE_PERIOD * interval; //Recalculate the interval for updating data from the sensor
get_data (); //Update information on the display
}
if (millis() - tmr1 >= BASE_PERIOD) { //We collect the basic array of data
tmr1 = millis(); //Every 11.25 minutes we take readings from the sensor
for (int i = 126; i >= 0; i--) { //Shift the entire array by one point
base_array[i + 1] = base_array[i];
}
value = round ((bme.seaLevelForAltitude(700, bme.readPressure())/100));//Convert to mm/Hg.
base_array[0] = value; //Write the latest readings to an array
update_all (); //And remember in EEPROM
}
if (millis() - tmr2 >= set_period) { //After a period of time set_period (milliseconds)
tmr2 = millis(); //Refreshing the data on the screen
get_data ();
}
}
void get_data () { //We draw 16 columns of the diagram on the screen
for (int i = 15; i >= 0; i--) {
drawPlot(0, 3, 16, 4, MIN_VAL, MAX_VAL, (base_array[i * interval]));
}
delta = ((base_array[0]) - (base_array[15 * interval])); //We calculate the delta (pressure change) for the selected interval
screen_data (value, delta, (interval * 3)); //Displaying text information on the screen
}
void screen_data (int value, int delta, byte interval) { //The function of displaying text information on the screen (everything except for the chart bars)
lcd.setCursor(16, 0);
lcd.print(value);
lcd.setCursor(17, 2);
if (delta == value) delta = 0;
if (delta > 0) {
lcd.print("+");
} else if (delta < 0) {
lcd.print("-");
} else if (delta == 0) {
lcd.print(" ");
}
lcd.setCursor(18, 2);
lcd.print(abs(delta));
if (abs(delta) < 10) {
lcd.setCursor(19, 2);
lcd.print(" ");
}
lcd.setCursor(17, 1);
lcd.print("hPa");
lcd.setCursor(17, 3);
lcd.print(interval);
(interval < 10) ? lcd.print("h ") : lcd.print("h");
}
void initPlot() {
// necessary symbols for work
// created in http://maxpromer.github.io/LCD-Character-Creator/
byte row8[8] = {0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte row7[8] = {0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte row6[8] = {0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte row5[8] = {0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte row4[8] = {0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111};
byte row3[8] = {0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111};
byte row2[8] = {0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111};
byte row1[8] = {0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111};
lcd.createChar(0, row8);
lcd.createChar(1, row1);
lcd.createChar(2, row2);
lcd.createChar(3, row3);
lcd.createChar(4, row4);
lcd.createChar(5, row5);
lcd.createChar(6, row6);
lcd.createChar(7, row7);
}
//Diagram drawing, code taken from Guyver https://alexgyver.ru/lcd-plots-and-bars/
void drawPlot(byte pos, byte row, byte width, byte height, int min_val, int max_val, int fill_val) {
for (byte i = 0; i < width; i++) {
plot_array[i] = plot_array[i + 1];
}
fill_val = constrain(fill_val, min_val, max_val);
plot_array[width - 1] = fill_val;
for (byte i = 0; i < width; i++) { // each parameter column
int infill, fract;
// find the number of whole blocks, taking into account the minimum and maximum, to display on the chart
infill = floor((float)(plot_array[i] - min_val) / (max_val - min_val) * height * 10);
fract = (infill % 10) * 8 / 10; // find the number of remaining stripes
infill = infill / 10;
for (byte n = 0; n < height; n++) { // for all graph lines
if (n < infill && infill > 0) { // while we're below the level
lcd.setCursor(i, (row - n)); // fill in cells
lcd.write(0);
}
if (n >= infill) { // if you reach the level
lcd.setCursor(i, (row - n));
if (fract > 0) lcd.write(fract); // заполняем дробные ячейки
else lcd.write(16); // if fractional == 0, fill empty
for (byte k = n + 1; k < height; k++) { // everything that is on top is filled with empty
lcd.setCursor(i, (row - k));
lcd.write(16);
}
break;
}
}
}
}
void update_all () { //Обновляем данные в EEPROM
eeprom_update_block((void*)&base_array, 0, sizeof(base_array));
}
void read_all () { //Reading data from EEPROM
eeprom_read_block((void*)&base_array, 0, sizeof(base_array));
}
Arduino Barometer + Barograph with BME280 Sensor
- Comments(0)
- Likes(1)
-
Engineer
Jun 16,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Mirko Pavleski
-
Arduino 3D Printed self Balancing Cube
Self-balancing devices are electronic devices that use sensors and motors to keep themselves balanc...
-
Build simple Retro Style VFO (Variable frequency oscillator) with Crowoanel 1.28 inch Round Display
Today I received a shipment with a Small round LCD display from Elecrow. The device is packed in tw...
-
Human vs Robot – Rock Paper Scissors with MyCobot 280 M5Stack
Today I received a package containing the few Elephant Robotics products. The shipment is well pack...
-
How to Build a Simple Audio Spectrum Analyzer with Adjustable Settings
An audio spectrum analyzer is an electronic device or software tool that measures and visually disp...
-
How to Make a Digital Clock on a Vintage B&W TV using Arduino
These days I accidentally came across this small retro Black and White TV with a built-in Radio, so ...
-
Build a $10 Function Generator with Frequency Meter for Your Lab
A function generator is a piece of electronic test equipment used to generate various types of elec...
-
From Unboxing to Coding - Radar Clock on Elecrow’s 2.1 HMI Display
Today I received a shipment with a large round LCD display from Elecrow. The device is packed in two...
-
Making a Retro Analog NTP Clock with Unihiker K10 - Arduino IDE Tutorial
Some time ago I presented you a way to use standard Arduino libraries on the Unihiker k10 developme...
-
Build a Cheap & Easy HF Preselector - Antenna Tuner
HF antenna preselector is an electronic device connected between an HF radio antenna, and a radio r...
-
DIY Static Charge Monitor - Electrostatic Field Detector (Arduino & TL071)
A Static Charge Monitor also known as a Static Field Meter or Electrostatic Voltmeter is a device u...
-
XHDATA D-219 Radio Short Review with complete disassembly
Some time ago I received an offer from XHDATA to be one of the first test users of their new radio m...
-
How to make Simplest ever Oscilloscope Clock
An oscilloscope clock is a unique and creative way to display the time using an oscilloscope, which...
-
DIY Digital Barograph with BME280 and ESP32 - 24 Hour Pressure Trends
A barograph is a self-recording barometer that continuously measures and records atmospheric pressu...
-
Build a Raspberry Pi Pico SDR Radio with Waterfall Display
Software-defined radio (SDR) is a radio communication system where components that have traditional...
-
DIY Magnet Polarity Detector - How to Identify Poles with a Hall Sensor from a PC Fan
Recently, while working on a project, I needed to determine the polarity of several permanent magne...
-
Light Meter Project - Making Dfrobot Unihiker K10 Work with Standard Arduino Libraries
The other day I received a shipment with a UNIHIKER K10 development board from DFRobot, which I rec...
-
DIY Simple Arduino Whack-a-Mole Game
A "Whack-a-Mole" game is a classic arcade-style game where moles pop up randomly from holes, and th...
-
Wireless Power Transmission, Long-Distance and High-Efficiency with Class-E Tesla Coil
Wireless energy transfer also known as wireless power transmission is a method of getting useful el...
-
-
AEL-2011 Power Supply Module
341 0 1 -
AEL-2011 50W Power Amplifier
316 0 1 -
-
-
Custom Mechanical Keyboard
575 0 0 -
Tester for Touch Screen Digitizer without using microcontroller
240 2 2 -
Audio reactive glow LED wristband/bracelet with NFC / RFID-Tags
241 0 1 -
-
-







