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