Skip to content

ENV.Ⅱ(SHT30, BMP280)

Nishikori Koji edited this page Feb 24, 2022 · 1 revision

ENV.Ⅱ(SHT30, BMP280)

サンプルコード: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/example/master.rb.env2

SHT3X

温度/湿度センサ

コードURL: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/mrblib/models/sht3x.rb

コンストラクタ

SHT3X.new(i2c)

  • i2c : I2Cクラスのオブジェクト

example

i2c = I2C.new(22, 21)
sht3x = SHT3X.new(i2c)

気温の取得(°C)

SHT3X.readTemperature()

example

temp = sht3x.readTemperature

湿度の取得(%)

SHT3X.readHumidity()

example

humi = sht3x.readHumidity

BMP280

温度/気圧センサ

コードURL: https://github.com/gfd-dennou-club/iotex-esp32-mrubyc/blob/master/mrblib/models/bmp280.rb

コンストラクタ

BMP280.new(i2c)

  • i2c : I2Cクラスのオブジェクト

example

i2c = I2C.new(22, 21)
bmp280 = BMP280.new(i2c)

気温の取得(°C)

BMP280.readTemperature()

example

temp = bmp280.readTemperature

気圧の取得(Pa)

BMP280.readPressure()

example

pa = bmp280.readPressure