|
1 | | ---- |
2 | | -layout: default |
3 | | -title: BME280 Free Pascal Driver for Raspberry Pi |
4 | | -description: Free Pascal driver for BME280 sensor measuring temperature, humidity, and air pressure. Includes accurate dewpoint calculation. |
5 | | ---- |
6 | 1 |
|
7 | | -# BME280 Free Pascal Driver for Raspberry Pi |
8 | | - |
9 | | -This is a Free Pascal driver for the BME280 sensor that measures temperature, humidity, and air pressure. The driver supports both default and user-configured settings and includes accurate dewpoint calculation. |
10 | | - |
11 | | - |
12 | | - |
13 | | -## 📄 Introduction |
14 | | - |
15 | | -This driver provides functions for interacting with the BME280 sensor via I2C on the Raspberry Pi. It offers two initialization methods: one with default settings and one for user-defined configurations. |
16 | | - |
17 | | ---- |
18 | | - |
19 | | -## 🛠️ Features |
20 | | - |
21 | | -- Supports both I2C addresses `$76` and `$77`. |
22 | | -- Two initialization functions: one with default settings and one for custom configuration. |
23 | | -- All parameters are defined as constants for ease of use. |
24 | | -- Simple integration with Raspberry Pi (requires I2C enabled). |
25 | | - |
26 | | ---- |
27 | | - |
28 | | -## 🛠️ Funktionen |
29 | | - |
30 | | -- Unterstützt sowohl die I2C-Adressen `$76` als auch `$77`. |
31 | | -- Zwei Initialisierungsfunktionen: eine mit Standardeinstellungen und eine für benutzerdefinierte Konfiguration. |
32 | | -- Alle Parameter sind als Konstanten definiert, um die Verwendung zu erleichtern. |
33 | | -- Einfache Integration mit Raspberry Pi (erfordert aktiviertes I2C). |
34 | | - |
35 | | -## 🧰 Installation |
36 | | - |
37 | | -1. Enable I2C on your Raspberry Pi (run `sudo raspi-config`, then navigate to `Interfacing Options` → `I2C` and enable it). |
38 | | -2. Clone this repository: |
39 | | -```bash |
40 | | -git clone https://github.com/RaspberryFpc/BME280-FreePascal-Driver.git |
41 | | -``` |
42 | | -3. Add the `bme280.pas` file to your project. |
43 | | - |
44 | | ---- |
45 | | - |
46 | | -## 📜 Predefined Constants / Vordefinierte Konstanten |
47 | | - |
48 | | -### 1. Mode / Modus |
49 | | - |
50 | | -| Name | Description (EN) | Beschreibung (DE) | Binary | |
51 | | -|------|-----------------|-----------------|--------| |
52 | | -| `Sleepmode` | Sleep mode of the sensor | Schlafmodus des Sensors | `%0` | |
53 | | -| `Forcedmode` | Forced mode (sensor reads once and then returns to sleep mode) | Zwangsmodus | `%1` | |
54 | | -| `Normalmode` | Normal mode, continuous measurements | Normalmodus | `%11` | |
55 | | - |
56 | | -### 2. Oversampling |
57 | | - |
58 | | -| Name | Description (EN) | Beschreibung (DE) | Binary | |
59 | | -|------|-----------------|-----------------|--------| |
60 | | -| `PressureOversampling1` | Pressure oversampling (x1) | Oversampling für Luftdruck (x1) | `%00100` | |
61 | | -| `PressureOversampling2` | Pressure oversampling (x2) | Oversampling für Luftdruck (x2) | `%01000` | |
62 | | -| `PressureOversampling4` | Pressure oversampling (x4) | Oversampling für Luftdruck (x4) | `%01100` | |
63 | | -| `PressureOversampling8` | Pressure oversampling (x8) | Oversampling für Luftdruck (x8) | `%10000` | |
64 | | -| `PressureOversampling16` | Pressure oversampling (x16) | Oversampling für Luftdruck (x16) | `%10100` | |
65 | | -| `TemperatureOversampling1` | Temperature oversampling (x1) | Oversampling für Temperatur (x1) | `%00100000` | |
66 | | -| `TemperatureOversampling2` | Temperature oversampling (x2) | Oversampling für Temperatur (x2) | `%01000000` | |
67 | | -| `TemperatureOversampling4` | Temperature oversampling (x4) | Oversampling für Temperatur (x4) | `%01100000` | |
68 | | -| `TemperatureOversampling8` | Temperature oversampling (x8) | Oversampling für Temperatur (x8) | `%10000000` | |
69 | | -| `TemperatureOversampling16` | Temperature oversampling (x16) | Oversampling für Temperatur (x16) | `%10100000` | |
70 | | -| `HumidityOversampling1` | Humidity oversampling (x1) | Oversampling für Luftfeuchtigkeit (x1) | `0` | |
71 | | -| `HumidityOversampling2` | Humidity oversampling (x2) | Oversampling für Luftfeuchtigkeit (x2) | `1` | |
72 | | -| `HumidityOversampling4` | Humidity oversampling (x4) | Oversampling für Luftfeuchtigkeit (x4) | `2` | |
73 | | -| `HumidityOversampling8` | Humidity oversampling (x8) | Oversampling für Luftfeuchtigkeit (x8) | `3` | |
74 | | -| `HumidityOversampling16` | Humidity oversampling (x16) | Oversampling für Luftfeuchtigkeit (x16) | `4` | |
75 | | - |
76 | | -### 3. Repeat Time / Wiederholrate |
77 | | - |
78 | | -| Name | Description (EN) | Beschreibung (DE) | Binary | |
79 | | -|------|-----------------|-----------------|--------| |
80 | | -| `Repeat0_5ms` | Repeat time every 0.5ms | Wiederholrate alle 0,5ms | `%00000000` | |
81 | | -| `Repeat_62_5ms` | Repeat time every 62.5ms | Wiederholrate alle 62,5ms | `%00100000` | |
82 | | -| `Repeat_125ms` | Repeat time every 125ms | Wiederholrate alle 125ms | `%01000000` | |
83 | | -| `Repeat_250ms` | Repeat time every 250ms | Wiederholrate alle 250ms | `%01100000` | |
84 | | -| `Repeat_500ms` | Repeat time every 500ms | Wiederholrate alle 500ms | `%10000000` | |
85 | | -| `Repeat_1000ms` | Repeat time every 1000ms | Wiederholrate alle 1000ms | `%10100000` | |
86 | | -| `Repeat_10ms` | Repeat time every 10ms | Wiederholrate alle 10ms | `%11000000` | |
87 | | -| `Repeat_20ms` | Repeat time every 20ms | Wiederholrate alle 20ms | `%11100000` | |
88 | | - |
89 | | -### 4. Filter |
90 | | - |
91 | | -| Name | Description (EN) | Beschreibung (DE) | Binary | |
92 | | -|------|-----------------|-----------------|--------| |
93 | | -| `filterOff` | No filter | Kein Filter | `%00000000` | |
94 | | -| `filter2` | Filter level 2 | Filterstufe 2 | `%00000100` | |
95 | | -| `filter4` | Filter level 4 | Filterstufe 4 | `%00001000` | |
96 | | -| `filter8` | Filter level 8 | Filterstufe 8 | `%00001100` | |
97 | | -| `filter16` | Filter level 16 | Filterstufe 16 | `%00010000` | |
98 | | - |
99 | | -### 5. SPI Enable |
100 | | - |
101 | | -| Name | Description (EN) | Beschreibung (DE) | Binary | |
102 | | -|------|-----------------|-----------------|--------| |
103 | | -| `EnableSPI` | Enable SPI | SPI aktivieren | `00000001` | |
104 | | - |
105 | | ---- |
106 | | - |
107 | | -## ⚙️ Functions / Funktionen |
108 | | - |
109 | | -### 1. Initbme280 |
110 | | - |
111 | | -Initializes the BME280 sensor with user-defined configurations. |
112 | | - |
113 | | -```pascal |
114 | | -function Initbme280(HumidityOversampling, PressureOversampling, TemperatureOversampling, mode, Repeattime, filter: byte): integer; |
115 | | -``` |
116 | | - |
117 | | -### 2. Initbme280_WithDefaults |
118 | | - |
119 | | -Initializes the BME280 sensor with default settings. |
120 | | - |
121 | | -```pascal |
122 | | -function Initbme280_WithDefaults: integer; |
123 | | -``` |
124 | | - |
125 | | ---- |
126 | | - |
127 | | -## 🔒 License / Lizenz |
128 | | - |
129 | | -```text |
130 | | -MIT License |
131 | | -Copyright (c) 2025 [Your Name] |
132 | | - |
133 | | -Permission is hereby granted, free of charge, to any person obtaining a copy |
134 | | -of this software and associated documentation files (the "Software"), to deal |
135 | | -in the Software without restriction, including without limitation the rights |
136 | | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
137 | | -of the Software, and to permit persons to whom the Software is provided to do so, |
138 | | -subject to the following conditions: |
139 | | - |
140 | | -The above copyright notice and this permission notice shall be included in all copies |
141 | | -or substantial portions of the Software. |
142 | | -``` |
143 | | - |
144 | | ---- |
145 | | - |
146 | | -## 🌐 Other Projects by the Author |
147 | | - |
148 | | -- [pibackup](https://github.com/RaspberryFpc/pibackup) – Portable live backup and restore tool with GUI, Zstandard compression, auto-shrinking (resize2fs) and flexible restore options. |
149 | | -- [Raspberry-UDP_audio_receiver](https://github.com/RaspberryFpc/Raspberry-UDP_audio_receiver) – Network audio receiver (UDP) with direct ALSA output and very low latency. |
150 | | -- [DS18B20-FPC-Pi-GUI](https://github.com/RaspberryFpc/DS18B20-FPC-Pi-GUI) – GUI tool to read DS18B20 temperature sensors with linearization for high accuracy. |
151 | | -- [RaspberryPi-GPIOv2-FPC](https://github.com/RaspberryFpc/RaspberryPi-GPIOv2-FPC) – Simple and fast Pascal unit for controlling GPIO pins via the Linux GPIO character device interface. |
0 commit comments