This gem makes interfacing with the DS18B20 temperature easier over 1-Wire.
After setting it up correctly make sure you have the correct file path where it's output is being recorded.
The file name on raspberry pi should be w1_slave
. If you don't know where the file is located - please read : DS18B20 - Temperature Sensing.
After making sure that you have the file path and that output looks similar to one in the tutorial above, you can easily use this gem following the instructions below.
Add this line to your application's Gemfile:
gem 'ds18b20'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ds18b20
require 'ds18b20'
sensor = Ds18b20::Parser.new("/sys/bus/w1/devices/28-800000048d57/w1_slave")
sensor.celsius
#=> 28.5625
sensor.fahrenheit
#=> 82.0625
sensor.kelvin
#=> 300.9
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/owaiswiz/ds18b20.
The gem is available as open source under the terms of the MIT License.