https://github.com/helins/linux.i2c.bme280.clj
Talking to BME280 sensors via I2C from Clojure JVM
https://github.com/helins/linux.i2c.bme280.clj
bme280 clojure i2c iot jvm sensors
Last synced: about 1 month ago
JSON representation
Talking to BME280 sensors via I2C from Clojure JVM
- Host: GitHub
- URL: https://github.com/helins/linux.i2c.bme280.clj
- Owner: helins
- License: mpl-2.0
- Created: 2017-08-10T12:31:28.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2021-03-24T10:50:21.000Z (almost 5 years ago)
- Last Synced: 2025-08-15T06:55:13.196Z (5 months ago)
- Topics: bme280, clojure, i2c, iot, jvm, sensors
- Language: Clojure
- Homepage:
- Size: 1.62 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# linux.i2c.bme280
[](https://clojars.org/io.helins/linux.i2c.bme280)
[](https://cljdoc.org/d/io.helins/linux.i2c.bme280)
Interact with the popular
[BME280](https://www.bosch-sensortec.com/bst/products/all_products/bme280)
sensor via [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) from Clojure JVM.
Relies on [helins.linux.i2c](https://github.com/helins/linux.i2c.clj) for
performing I2C operations.
## Usage
This is an overview.
The [full API is available on Cljdoc](https://cljdoc.org/d/io.helins/linux.i2c.bme280).
In short, without error handling :
```clj
(require '[helins.linux.i2c :as i2c]
'[helins.linux.i2c.bme280 :as bme280])
(with-open [bus (i2c/bus "/dev/i2c-1")]
(i2c/select-slave bus
0x76)
(let [;; Those compensation words will be used for adjusting raw data received from sensors.
compensation-words (bme280/compensation-words bus)
;; Configuration map.
config {:bme280/iir-filter 16
:bme280/mode :forced
:bme280/oversampling.humidity :x1
:bme280/oversampling.pressure :x2
:bme280/oversampling.temperature :x4}
;; Computes how many milliseconds a single measurement takes, at most.
wait-ms (:maximum (bme280/cycle-duration config))]
(bme280/configure bus
config)
(Thread/sleep wait-ms)
(bme280/read-sensors bus
compensation-words)
=> {:bme280/humidity 46.932
:bme280/pressure 960.3226
:bme280/temperature 23.3}
))
```
## License
Copyright © 2017 Adam Helinski
Licensed under the term of the Mozilla Public License 2.0, see LICENSE.