https://github.com/owaiswiz/ds18b20
🌡️A Ruby Gem to easily interface with the DS18B20 temperature Sensor over 1-Wire
https://github.com/owaiswiz/ds18b20
ds18b20 raspberry-pi temperature-monitoring temperature-sensor
Last synced: about 1 year ago
JSON representation
🌡️A Ruby Gem to easily interface with the DS18B20 temperature Sensor over 1-Wire
- Host: GitHub
- URL: https://github.com/owaiswiz/ds18b20
- Owner: owaiswiz
- License: mit
- Created: 2017-12-07T19:46:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-26T09:12:02.000Z (almost 8 years ago)
- Last Synced: 2025-04-10T11:07:44.919Z (about 1 year ago)
- Topics: ds18b20, raspberry-pi, temperature-monitoring, temperature-sensor
- Language: Ruby
- Homepage:
- Size: 15.6 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DS18B20
[](https://travis-ci.org/owaiswiz/ds18b20) [](https://badge.fury.io/rb/ds18b20) []()
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](https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing?view=all).
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:
```ruby
gem 'ds18b20'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install ds18b20
## Usage
### 1. Require
```ruby
require 'ds18b20'
```
### 2. Create Instance with Proper File Path
```ruby
sensor = Ds18b20::Parser.new("/sys/bus/w1/devices/28-800000048d57/w1_slave")
```
### 3. Getting Temperature
```ruby
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](https://opensource.org/licenses/MIT).