Skip to content
Nishikori Koji edited this page Feb 24, 2022 · 4 revisions

TMP007

非接触温度センサ

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

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

コンストラクタ

TMP007.new(i2c)

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

example

i2c = I2C.new(22, 21)
tmp007 = TMP007.new(i2c)

センサの接続と初期化

TMP007.init(samplerate)

  • samplerate : サンプルレートの指定(CFG_1SAMPLE、CFG_2SAMPLE、CFG_4SAMPLE、CFG_8SAMPLE、CFG_16SAMPLE)

戻り値はtrue or false

example

if !tmp007.init(TMP007::CFG_16SAMPLE)
  puts "No sensor found"
else
  ...
end

ダイ温度(TDIE)を取得(℃)

TMP007.read_die_temp_c()

example

diet = tmp007.read_die_temp_c

計測対象の温度を取得(℃)

TMP007.read_obj_temp_c()

example

objt = tmp007.read_obj_temp_c