Project

ds18b20

0.0
No commit activity in last 3 years
No release in over 3 years
A Gem to easily interface with the DS18B20 Temperature Sensor Over 1-Wire
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.16
~> 10.0
~> 3.0
 Project Readme

DS18B20

Build Status Gem Version Gem

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.

Installation

Add this line to your application's Gemfile:

gem 'ds18b20'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ds18b20

Usage

1. Require

require 'ds18b20'

2. Create Instance with Proper File Path

sensor = Ds18b20::Parser.new("/sys/bus/w1/devices/28-800000048d57/w1_slave")

3. Getting Temperature

sensor.celsius
#=> 28.5625


sensor.fahrenheit
#=> 82.0625


sensor.kelvin
#=> 300.9

Development

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/owaiswiz/ds18b20.

License

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