-
Notifications
You must be signed in to change notification settings - Fork 12
Si7021
Nishikori Koji edited this page Feb 24, 2022
·
3 revisions
温湿度センサ
コードURL: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/mrblib/models/si7021.rb
サンプルコード: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/example/master.rb.si7021
Si7021.new(i2c)
- i2c : I2Cクラスのオブジェクト
example
i2c = I2C.new(22, 21)
si7021 = Si7021.new(i2c)
Si7021.begin()
example
if !si7021.begin
puts "Did not find Si7021 sensor!"
else
...
end
Si7021.read_temp()
example
temp = si7021.read_temp
Si7021.read_humid()
example
humid = si7021.read_humid
Si7021.set_heater_level()
- level : ヒーターのレベル(ハッシュHEAT_LEVELに定義)
HEAT_LEVEL = {"LOWEST" => 0x00, "LOW" => 0x01, "MEDIUM" => 0x02, "HIGH" => 0x04, "HIGHER" => 0x08, "HIGHEST" => 0x0F }
example
si7021.set_heater_level(Si7021::HEAT_LEVEL["MEDIUM"])
Si7021.heater(sw)
- sw : ヒーターの起動はtrue、停止はfalse
example
si7021.heater(true)
si7021.heater(false)
Si7021.heater_status()
example
si7021.heater_status ? puts("ENABLED") : puts("DISENABLE")