An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# DS18B20

[![Build Status](https://travis-ci.org/owaiswiz/ds18b20.svg?branch=master)](https://travis-ci.org/owaiswiz/ds18b20) [![Gem Version](https://badge.fury.io/rb/ds18b20.svg)](https://badge.fury.io/rb/ds18b20) [![Gem](https://img.shields.io/gem/dt/ds18b20.svg?colorB=brightgreen&maxAge=3600)]()

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).