rpi-dht 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +82 -0
- data/Guardfile +42 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rpi/dht.rb +39 -0
- data/lib/rpi/dht/base.rb +186 -0
- data/lib/rpi/dht/dht11.rb +18 -0
- data/lib/rpi/dht/dht22.rb +22 -0
- data/lib/rpi/dht/version.rb +5 -0
- data/rpi-dht.gemspec +47 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: daed8bd7412ee833eb636efa8e5762277ac483586c101713bc1a305c6dd0b24c
|
4
|
+
data.tar.gz: 3ab13239c1d0ce26443e59b858d266ac6f6b200b6b563b84008fd9a2fa0fb800
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0b571779461f11854abfa4f02af581aad49a350845366d61903ba54759f62f3240481ed4b1041d95b2de7686f7c9ffa2dea90f92bb335d5c574da4f1d6c635c
|
7
|
+
data.tar.gz: 31399e69fe8c00aec0cbad49e04a0694232de6d6c7074c35e2e0bf6a1c9cdf5e48683edaa2c43cab0c8dffdc8ff52ebb9852df89a41758125194adf7c052cc5e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rpi-dht (0.1.0)
|
5
|
+
rpi_gpio
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
byebug (11.1.3)
|
11
|
+
coderay (1.1.3)
|
12
|
+
diff-lcs (1.4.4)
|
13
|
+
epoll (0.3.0)
|
14
|
+
ffi (1.13.1)
|
15
|
+
formatador (0.2.5)
|
16
|
+
guard (2.16.2)
|
17
|
+
formatador (>= 0.2.4)
|
18
|
+
listen (>= 2.7, < 4.0)
|
19
|
+
lumberjack (>= 1.0.12, < 2.0)
|
20
|
+
nenv (~> 0.1)
|
21
|
+
notiffany (~> 0.0)
|
22
|
+
pry (>= 0.9.12)
|
23
|
+
shellany (~> 0.0)
|
24
|
+
thor (>= 0.18.1)
|
25
|
+
guard-compat (1.2.1)
|
26
|
+
guard-rspec (4.7.3)
|
27
|
+
guard (~> 2.1)
|
28
|
+
guard-compat (~> 1.1)
|
29
|
+
rspec (>= 2.99.0, < 4.0)
|
30
|
+
listen (3.2.1)
|
31
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
32
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
33
|
+
lumberjack (1.2.8)
|
34
|
+
method_source (1.0.0)
|
35
|
+
naught (1.1.0)
|
36
|
+
nenv (0.3.0)
|
37
|
+
notiffany (0.1.3)
|
38
|
+
nenv (~> 0.1)
|
39
|
+
shellany (~> 0.0)
|
40
|
+
pry (0.13.1)
|
41
|
+
coderay (~> 1.1)
|
42
|
+
method_source (~> 1.0)
|
43
|
+
pry-byebug (3.9.0)
|
44
|
+
byebug (~> 11.0)
|
45
|
+
pry (~> 0.13.0)
|
46
|
+
rake (10.5.0)
|
47
|
+
rb-fsevent (0.10.4)
|
48
|
+
rb-inotify (0.10.1)
|
49
|
+
ffi (~> 1.0)
|
50
|
+
rpi_gpio (0.5.0)
|
51
|
+
epoll (~> 0.3)
|
52
|
+
rspec (3.9.0)
|
53
|
+
rspec-core (~> 3.9.0)
|
54
|
+
rspec-expectations (~> 3.9.0)
|
55
|
+
rspec-mocks (~> 3.9.0)
|
56
|
+
rspec-core (3.9.3)
|
57
|
+
rspec-support (~> 3.9.3)
|
58
|
+
rspec-expectations (3.9.2)
|
59
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
+
rspec-support (~> 3.9.0)
|
61
|
+
rspec-mocks (3.9.1)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.9.0)
|
64
|
+
rspec-support (3.9.3)
|
65
|
+
shellany (0.0.1)
|
66
|
+
thor (1.0.1)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
ruby
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
bundler (~> 1.17)
|
73
|
+
guard-rspec
|
74
|
+
naught
|
75
|
+
pry
|
76
|
+
pry-byebug
|
77
|
+
rake (~> 10.0)
|
78
|
+
rpi-dht!
|
79
|
+
rspec (~> 3.0)
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
1.17.2
|
data/Guardfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Rpi::Dht
|
2
|
+
|
3
|
+
Written purly in Ruby (except external gems)!
|
4
|
+
|
5
|
+
## datasheet references
|
6
|
+
|
7
|
+
- [dht11][1]
|
8
|
+
- [dht22][2]
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```rb
|
15
|
+
gem "rpi-dht"
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install rpi-dht
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```rb
|
29
|
+
require "rpi-dht"
|
30
|
+
|
31
|
+
pin = 4
|
32
|
+
|
33
|
+
# Because it can't receive valid data from sensor reliably, there are methods try to read continusly until it gets valid data
|
34
|
+
# [read_11 and read_22] (without !) are recommended
|
35
|
+
|
36
|
+
####################
|
37
|
+
# for DHT11 sensor
|
38
|
+
####################
|
39
|
+
RPi::Dht.read_11!(pin) # raises exception, if you want to manage by yourself
|
40
|
+
# => returns e.g. {humidity: 12, temperature: 34, temperature_f: 93.2}
|
41
|
+
# or exception
|
42
|
+
|
43
|
+
RPi::Dht.read_11(pin, tries: 50) # tries 50 times and doesn't raise
|
44
|
+
# or RPi::Dht.read_11(pin) defaults to 50 tries
|
45
|
+
# => returns e.g. {humidity: 12, temperature: 34, temperature_f: 93.2}
|
46
|
+
# or nil if it doesn't get valid data
|
47
|
+
|
48
|
+
####################
|
49
|
+
# for DHT22 sensor
|
50
|
+
####################
|
51
|
+
RPi::Dht.read_22!(pin) # raises exception, if you want to manage by yourself
|
52
|
+
# => returns e.g. {humidity: 12.3, temperature: 34.5, temperature_f: 94.1}
|
53
|
+
# or exception
|
54
|
+
|
55
|
+
RPi::Dht.read_22(pin, tries: 50) # tries 50 times and doesn't raise
|
56
|
+
# or RPi::Dht.read_22(pin) defaults to 50 tries
|
57
|
+
# => returns e.g. {humidity: 12.3, temperature: 34.5, temperature_f: 94.1}
|
58
|
+
# or nil if it doesn't get valid data
|
59
|
+
```
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
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.
|
64
|
+
|
65
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/github0013/rpi-dht.
|
70
|
+
|
71
|
+
[1]: https://akizukidenshi.com/download/ds/aosong/DHT11.pdf
|
72
|
+
[2]: https://akizukidenshi.com/download/ds/aosong/AM2302.pdf
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rpi/dht"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rpi/dht.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "rpi/dht/version"
|
2
|
+
def debug?
|
3
|
+
not `cat /proc/cpuinfo`.include?("Raspberry Pi")
|
4
|
+
end
|
5
|
+
|
6
|
+
if debug?
|
7
|
+
require "naught"
|
8
|
+
else
|
9
|
+
require "rpi_gpio"
|
10
|
+
RPi::GPIO.set_numbering :bcm
|
11
|
+
end
|
12
|
+
|
13
|
+
require "rpi/dht/base"
|
14
|
+
require "rpi/dht/dht11"
|
15
|
+
require "rpi/dht/dht22"
|
16
|
+
|
17
|
+
module RPi
|
18
|
+
GPIO = Naught.build(&:black_hole).new if debug?
|
19
|
+
|
20
|
+
module Dht
|
21
|
+
extend self
|
22
|
+
|
23
|
+
def read_11!(pin)
|
24
|
+
Dht11.read!(pin)
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_11(pin, tries: 50)
|
28
|
+
Dht11.read(pin, tries: tries)
|
29
|
+
end
|
30
|
+
|
31
|
+
def read_22!(pin)
|
32
|
+
Dht22.read!(pin)
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_22(pin, tries: 50)
|
36
|
+
Dht22.read(pin, tries: tries)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/rpi/dht/base.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
module RPi
|
2
|
+
module Dht
|
3
|
+
class InvalidByteSetError < StandardError; end
|
4
|
+
class InvalidByteError < StandardError; end
|
5
|
+
class ParityError < StandardError; end
|
6
|
+
|
7
|
+
class Base
|
8
|
+
CLEAR_SIGNALS = 500 / 1000.to_f
|
9
|
+
START_SIGNAL = 1 / 1000.to_f
|
10
|
+
VALID_BYTE_SIZE = 5 # humidity_high, humidity_low, temp_high, temp_low, parity
|
11
|
+
BITS_IN_BYTE = 8
|
12
|
+
HUMIDITY_PRECISION = 10.to_f
|
13
|
+
TEMPERATURE_PRECISION = 10.to_f
|
14
|
+
ENOUGH_TO_CAPTURE_COUNT = 1000 # collecting high/low this many times should be enough (rough estimate...)
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def read!(pin)
|
18
|
+
dht = new(pin)
|
19
|
+
dht.send_start_signal
|
20
|
+
dht.collect_response_bits
|
21
|
+
dht.convert
|
22
|
+
end
|
23
|
+
|
24
|
+
def read(pin, tries: 50)
|
25
|
+
tries.to_i.times do
|
26
|
+
value = ignore_exception { read!(pin) }
|
27
|
+
return value if value.is_a?(Hash)
|
28
|
+
end
|
29
|
+
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def ignore_exception
|
36
|
+
yield
|
37
|
+
rescue => ex
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(pin)
|
42
|
+
@pin = pin
|
43
|
+
end
|
44
|
+
|
45
|
+
def send_start_signal
|
46
|
+
# https://i.gyazo.com/a3e13113125d56326517fa936c6011fc.png
|
47
|
+
# The OUTPUT part
|
48
|
+
RPi::GPIO.setup pin, as: :output, initialize: :high
|
49
|
+
sleep(CLEAR_SIGNALS)
|
50
|
+
|
51
|
+
RPi::GPIO.set_low pin
|
52
|
+
sleep(START_SIGNAL)
|
53
|
+
end
|
54
|
+
|
55
|
+
def collect_response_bits
|
56
|
+
# https://i.gyazo.com/a3e13113125d56326517fa936c6011fc.png
|
57
|
+
# The INPUT part (until the release just below)
|
58
|
+
RPi::GPIO.setup pin, as: :input, pull: :up
|
59
|
+
@bits = ENOUGH_TO_CAPTURE_COUNT.times.collect { RPi::GPIO.high?(pin) }
|
60
|
+
release
|
61
|
+
|
62
|
+
break_into_byte_strings
|
63
|
+
check_parity!
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
attr_reader :pin, :bits, :byte_strings
|
69
|
+
|
70
|
+
def release
|
71
|
+
RPi::GPIO.clean_up pin
|
72
|
+
end
|
73
|
+
|
74
|
+
def break_by_high_or_low
|
75
|
+
# group trues with trues / falses with falses
|
76
|
+
# [
|
77
|
+
# [true, true, true, ...],
|
78
|
+
# [false, false, false, ...],
|
79
|
+
# ...
|
80
|
+
# ]
|
81
|
+
last_value = :not_yet
|
82
|
+
bits.slice_before do |value|
|
83
|
+
(last_value != value).tap { |not_same| last_value = value if not_same }
|
84
|
+
end.to_a
|
85
|
+
end
|
86
|
+
|
87
|
+
def break_into_byte_strings
|
88
|
+
# https://i.gyazo.com/a3e13113125d56326517fa936c6011fc.png
|
89
|
+
# response signal (ture / false arrays) before data (useless)
|
90
|
+
|
91
|
+
# ture/false array pair
|
92
|
+
# data part is 5bytes = 40bits = 40pairs of true and false arrays = 80 arrays
|
93
|
+
# [false, false, false, ...]
|
94
|
+
# [true, true, true, ...]
|
95
|
+
# [false, false, false, ...]
|
96
|
+
# [true, true, true, ...]
|
97
|
+
# [false, false, false, ...]
|
98
|
+
# [true, true, true, ...]
|
99
|
+
# ...
|
100
|
+
# ...
|
101
|
+
# ...
|
102
|
+
|
103
|
+
# end_part (useless)
|
104
|
+
# after data, it ends with short period of falses then eternal trues
|
105
|
+
# [false, false, false, ...]
|
106
|
+
# [true, true, true, true, true, true, true, true, true, ...]
|
107
|
+
end_part, *low_high_pairs = break_by_high_or_low.reverse.each_slice(2).to_a
|
108
|
+
|
109
|
+
# https://i.gyazo.com/baba7ce475e945c732491a6afc9e4b9a.png
|
110
|
+
# low_high_pairs = [
|
111
|
+
# ture / false array pair = 1bit
|
112
|
+
# 8elements of them = 1byte worth of data
|
113
|
+
# [
|
114
|
+
# [[true, true ...], [false, false ...]], 1
|
115
|
+
# [[true, true ...], [false, false ...]], 2
|
116
|
+
# [[true, true ...], [false, false ...]], 3
|
117
|
+
# [[true, true ...], [false, false ...]], 4
|
118
|
+
# [[true, true ...], [false, false ...]], 5
|
119
|
+
# [[true, true ...], [false, false ...]], 6
|
120
|
+
# [[true, true ...], [false, false ...]], 7
|
121
|
+
# [[true, true ...], [false, false ...]], 8
|
122
|
+
# ]
|
123
|
+
|
124
|
+
# ...
|
125
|
+
# total of 5 bytes
|
126
|
+
# ]
|
127
|
+
|
128
|
+
response_signal_part_chopped_off =
|
129
|
+
low_high_pairs.each_slice(8).collect(&:reverse).to_a.reverse.last(
|
130
|
+
VALID_BYTE_SIZE
|
131
|
+
)
|
132
|
+
|
133
|
+
valid_bytes =
|
134
|
+
response_signal_part_chopped_off.select do |pair|
|
135
|
+
pair.all? { |x| x.is_a?(Array) }
|
136
|
+
end
|
137
|
+
|
138
|
+
unless valid_bytes.size == VALID_BYTE_SIZE
|
139
|
+
raise InvalidByteSetError.new(
|
140
|
+
"not valid byte set (#{valid_bytes.size}bytes, should be #{
|
141
|
+
VALID_BYTE_SIZE
|
142
|
+
}bytes)"
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
valid_bytes.each do |byte|
|
147
|
+
unless byte.size == BITS_IN_BYTE
|
148
|
+
raise InvalidByteError.new(
|
149
|
+
"not a byte (#{byte.size}bits, should be #{BITS_IN_BYTE}bits)"
|
150
|
+
)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# [
|
155
|
+
# [false, false, false, ...],
|
156
|
+
# [false, false, false, ...],
|
157
|
+
# [false, false, false, ...],
|
158
|
+
# ...
|
159
|
+
# ]
|
160
|
+
all_falses = valid_bytes.collect { |byte| byte.collect(&:last) }.flatten(1)
|
161
|
+
average_50us_false_size = all_falses.sum(&:size) / all_falses.size.to_f
|
162
|
+
|
163
|
+
# https://i.gyazo.com/085693e497f9105bc66392d05112e0d3.png
|
164
|
+
@byte_strings =
|
165
|
+
valid_bytes.collect do |byte|
|
166
|
+
byte.collect { |trues, _| average_50us_false_size <= trues.size ? 1 : 0 }.join
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def bytes
|
171
|
+
byte_strings.collect { |x| x.to_i(2) }
|
172
|
+
end
|
173
|
+
|
174
|
+
def check_parity!
|
175
|
+
humidity_high, humidity_low, temp_high, temp_low, parity = bytes
|
176
|
+
unless (humidity_high + humidity_low + temp_high + temp_low) == parity
|
177
|
+
raise ParityError.new("parity check failed")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def fahrenheit(celsius)
|
182
|
+
(celsius.to_f * 1.8 + 32).round(2)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RPi
|
2
|
+
module Dht
|
3
|
+
class Dht11 < Base
|
4
|
+
def convert
|
5
|
+
humidity_high, _, temp_high, _, _ = bytes
|
6
|
+
|
7
|
+
humidity = humidity_high
|
8
|
+
temperature = temp_high
|
9
|
+
|
10
|
+
{
|
11
|
+
humidity: humidity,
|
12
|
+
temperature: temperature,
|
13
|
+
temperature_f: fahrenheit(temperature)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RPi
|
2
|
+
module Dht
|
3
|
+
class Dht22 < Base
|
4
|
+
def convert
|
5
|
+
humidity_high, humidity_low, temp_high, temp_low, _ = bytes
|
6
|
+
|
7
|
+
is_negative = 0 < (temp_high & 0b10000000)
|
8
|
+
temp_high &= 0b01111111
|
9
|
+
|
10
|
+
humidity = ((humidity_high << 8) + humidity_low) / HUMIDITY_PRECISION
|
11
|
+
temperature = ((temp_high << 8) + temp_low) / TEMPERATURE_PRECISION
|
12
|
+
temperature *= -1 if is_negative
|
13
|
+
|
14
|
+
{
|
15
|
+
humidity: humidity,
|
16
|
+
temperature: temperature,
|
17
|
+
temperature_f: fahrenheit(temperature)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/rpi-dht.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "rpi/dht/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "rpi-dht"
|
7
|
+
spec.version = RPi::Dht::VERSION
|
8
|
+
spec.authors = %w[github0013]
|
9
|
+
spec.email = %w[github0013@gmail.com]
|
10
|
+
|
11
|
+
spec.summary = "Pure Ruby implementation of DHT11/22 sensor"
|
12
|
+
spec.description = "Fully written in Ruby (except external gems)"
|
13
|
+
spec.homepage = "https://github.com/github0013/rpi-dht"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
19
|
+
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/github0013/rpi-dht"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/github0013/rpi-dht/CHANGELOG.md"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files =
|
31
|
+
Dir.chdir(File.expand_path("..", __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = %w[lib]
|
37
|
+
|
38
|
+
spec.add_dependency "rpi_gpio"
|
39
|
+
|
40
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
41
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
42
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
43
|
+
spec.add_development_dependency "pry"
|
44
|
+
spec.add_development_dependency "naught"
|
45
|
+
spec.add_development_dependency "pry-byebug"
|
46
|
+
spec.add_development_dependency "guard-rspec"
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rpi-dht
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- github0013
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rpi_gpio
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: naught
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Fully written in Ruby (except external gems)
|
126
|
+
email:
|
127
|
+
- github0013@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- Guardfile
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/setup
|
142
|
+
- lib/rpi/dht.rb
|
143
|
+
- lib/rpi/dht/base.rb
|
144
|
+
- lib/rpi/dht/dht11.rb
|
145
|
+
- lib/rpi/dht/dht22.rb
|
146
|
+
- lib/rpi/dht/version.rb
|
147
|
+
- rpi-dht.gemspec
|
148
|
+
homepage: https://github.com/github0013/rpi-dht
|
149
|
+
licenses: []
|
150
|
+
metadata:
|
151
|
+
allowed_push_host: https://rubygems.org
|
152
|
+
homepage_uri: https://github.com/github0013/rpi-dht
|
153
|
+
source_code_uri: https://github.com/github0013/rpi-dht
|
154
|
+
changelog_uri: https://github.com/github0013/rpi-dht/CHANGELOG.md
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubygems_version: 3.0.3
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: Pure Ruby implementation of DHT11/22 sensor
|
174
|
+
test_files: []
|