-
Notifications
You must be signed in to change notification settings - Fork 12
MCP9808
Nishikori Koji edited this page Feb 24, 2022
·
3 revisions
温度センサ
コードURL: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/mrblib/models/mcp9808.rb
サンプルコード: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/example/master.rb.mcp9808
MCP9808.new(i2c)
- i2c : I2Cクラスのオブジェクト
example
i2c = I2C.new(22, 21)
mcp9808 = MCP9808.new(i2c)
MCP9808.begin()
example
if !mcp9808.begin
puts "Couldn't find MCP9808! Check your connections and verify the address is correct."
else
...
end
MCP9808.wake
example
mcp9808.wake
MCP9808.shutdown
example
mcp9808.shutdown
MCP9808.set_resolution(value)
- value : 分解能のモードを0〜3で指定
Mode | Resolution | SampleTime |
---|---|---|
0 | 0.5 ℃ | 30ms |
1 | 0.25 ℃ | 65ms |
2 | 0.125 ℃ | 130ms |
3 | 0.625 ℃ | 250ms |
example
mcp9808.set_resolution(3)
MCP9808.get_resolution()
example
reso = mcp9808.get_resolution
MCP9808.read_temp_c()
example
temp_c = mcp9808.read_temp_c
MCP9808.read_temp_f()
example
temp_f = mcp9808.read_temp_f