[[FrontPage]]
 objectPage http://www.yama-lab.org/fwb4pi/index.php?i2c-sensors-ex5 or http://www.yama-lab.org/fwb4pi/index.php?i2c-sensors-ex5
 device yamaRasPiDp9_1 or yamaRasPiDp9_2 start after no write for 10 min.
 command: set readInterval=30000
 command: set execInterval=0
 command: set reportLength=120
 command: program sensors
 program: 'ex("service","clear sendBuffer")
 program: '
 program: ' init i2c
 program: ex("pi4j", "i2c use 1")
 program: '
 program: ' init hdc1080 
 program: ex("pi4j", "i2c write2 0x40,0x02,0x10,0x00") ' config
 program: '
 program: 'get temp
 program: ex("pi4j", "i2c write-b 0x40,0x00") ' temp
 program: delay(15)
 program: v1s=ex("pi4j", "i2c read-A-2 0x40") ' get temp
 program: 'temp=s2i(v1s)/65536.0*165-40
 program: v1=s2i(v1s)
 program: if v1<0 then v1x=2.0*(v1/2+0x8000) else v1x=1.0*v1
 program: temp=v1x/65536.0*165-40
 program: '
 program: 'delay(20)
 program: '
 program: 'get humidity
 program: ex("pi4j", "i2c write-b 0x40,0x01") ' get humidity
 program: delay(15)
 program: v2s=ex("pi4j", "i2c read-A-2 0x40") 'humid
 program: v2=s2i(v2s)
 program: if v2<0 then v3=2.0*(v2/2 + 0x8000) else v3=v2*1.0
 program: humid=(v3/65536.0) *100
 program: ex("service","putSendBuffer device=temp, Date="+ex("service","getCurrentDate.")+", v="+temp)
 program: ex("service","putSendBuffer device=humid, Date="+ex("service","getCurrentDate.")+",v="+humid)
 program: delay(40)
 program: '
 program: ' init lux sensor 
 program: ex("pi4j", "i2c write1 0x29,0x80,0x03") 'power up the tsl2561 lux sensor
 program: ex("pi4j", "i2c write1 0x29,0x81,0x00")
 program: ex("pi4j", "i2c write1 0x29,0x86,0x00") 'scale
 program: ex("pi4j", "i2c write1 0x29,0x80,0x00") 'power down
 program: ex("pi4j", "i2c write1 0x29,0x80,0x03") ' power up again
 program: delay(50)
 program: '
 program: 'get the lux value
 program: v1=ex("pi4j", "i2c read1 0x29,0x8c")
 program: v2=ex("pi4j", "i2c read1 0x29,0x8d")
 program: v=s2i(v2)*256+s2i(v1)
 program: ex("service","putSendBuffer device=lux, Date="+ex("service","getCurrentDate.")+", v="+v)
 program: '
 program: 'Ardino-I2C PIR sensor 
 program: '
 program: 'get 30sec. motions
 program: v1=ex("pi4j", "i2c read1 0x12,0x01")
 program: v2=ex("pi4j", "i2c read1 0x12,0x02")
 program: v=s2i(v1)*256+s2i(v2)
 program: ex("service","putSendBuffer device=pir, Date="+ex("service","getCurrentDate.")+", v="+v)
 program: '
 program: '
 program: 'Ardino-I2C CO2 sensor 
 program: '
 program: v1=ex("pi4j", "i2c read1 0x13,0x01")
 program: v2=ex("pi4j", "i2c read1 0x13,0x02")
 program: v=s2i(v1)*256+s2i(v2)
 program: ex("service","putSendBuffer device=co2, Date="+ex("service","getCurrentDate.")+", v="+v)
 program: '
 program: ex("pi4j", "i2c close.")
 program: ex("service","sendResults.")
 command: end sensors
 command: run sensors
 result:
 device=temp, Date=2019/6/13/ 21:41:20, v=27.04132080078125
 device=humid, Date=2019/6/13/ 21:41:20,v=64.703369140625
 device=lux, Date=2019/6/13/ 21:41:20, v=1
 device=pir, Date=2019/6/13/ 21:41:20, v=60
 device=co2, Date=2019/6/13/ 21:41:20, v=0
 device=temp, Date=2019/6/13/ 21:41:50, v=27.11181640625
 device=humid, Date=2019/6/13/ 21:41:50,v=64.501953125
 device=lux, Date=2019/6/13/ 21:41:50, v=1
 device=pir, Date=2019/6/13/ 21:41:50, v=60
 device=co2, Date=2019/6/13/ 21:41:50, v=13848
 device=temp, Date=2019/6/13/ 21:42:20, v=27.18231201171875
 device=humid, Date=2019/6/13/ 21:42:20,v=64.202880859375
 device=lux, Date=2019/6/13/ 21:42:20, v=1
 device=pir, Date=2019/6/13/ 21:42:20, v=60
 device=co2, Date=2019/6/13/ 21:42:20, v=13848
 device=temp, Date=2019/6/13/ 21:42:50, v=27.232666015625
 device=humid, Date=2019/6/13/ 21:42:50,v=64.07470703125
 device=lux, Date=2019/6/13/ 21:42:50, v=1
 device=pir, Date=2019/6/13/ 21:42:50, v=43
 device=co2, Date=2019/6/13/ 21:42:50, v=410
 currentDevice="yamaRasPiDp1_1",Date=2019/6/13/ 21:42:50

 device=temp, Date=2019/6/13/ 21:43:20, v=27.232666015625
 device=humid, Date=2019/6/13/ 21:43:20,v=64.373779296875
 device=lux, Date=2019/6/13/ 21:43:20, v=1
 device=pir, Date=2019/6/13/ 21:43:20, v=21
 device=co2, Date=2019/6/13/ 21:43:20, v=410
 currentDevice="yamaRasPiDp1_1",Date=2019/6/13/ 21:43:20


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS