Skip to content

Ruby driver for the Bosch BME280 temperature, humidity and pressure sensor.

License

Notifications You must be signed in to change notification settings

lukasjapan/i2c-bme280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I2C::BME280

Gem Version

Ruby driver for the Bosch BME280 sensor over the I2C protocol.

The driver uses the i2c gem which relies on the i2c-dev package.

It was mainly ported from the bme280_sample.py script.

Thanks and credits to:

Installation

The library depends on the i2c-dev package. Furthermore the I2C kernel module has to be enabled manually if you are using the Raspberry Pi.

i2c-dev

Debian based systems:

sudo apt-get install i2c-dev

Enable I2C (Raspberry Pi)

sudo raspi-config -> Select Advanced Options -> Select I2C -> Select Yes (2 times) -> Reboot

Gemfile

Just include the following line to your Gemfile to use the driver.

gem 'i2c-bme280'

Usage

Example:

require 'i2c/bme280'
require 'json'

# Make sure you specify the i2c device id in the constructor.
# The default device id on the raspberry pi is 1.
# You can also pass a string that points to the device file: e.g. '/dev/i2c-1'
bme280 = I2C::Driver::BME280.new(device: 1)

puts "Temperature: #{'%7.2f' % bme280.temperature} [°C]"
puts "Pressure:    #{'%7.2f' % bme280.pressure} [hPa]"
puts "Humidity:    #{'%7.2f' % bme280.humidity} [%]"
puts
puts "JSON: #{bme280.all.to_json}"

License

The gem is available as open source under the terms of the MIT License.

About

Ruby driver for the Bosch BME280 temperature, humidity and pressure sensor.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages