FrontPage
objectPage http://www.yama-lab.org/fwb4pi/index.php?i2c-sensors-ex3 or http://www.yama-lab.org/fwb4pi/index.php?i2c-sensors-ex3
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: '
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: humid=s2i(v2s)/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: '
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: ' init barometer , MPL3115A2
program: ex("pi4j", "i2c write1 0x60,0x26,0xbb") 'set to altmeter with an OSR=128
program: ex("pi4j", "i2c write1 0x60,0x13,0x07") 'enable data flags in PT_DATA_CFG
program: ex("pi4j", "i2c write1 0x60,0x28,0x11") 'set int to acive low open drain
program: ex("pi4j", "i2c write1 0x60,0x29,0x80") 'enabledrdy interrupt
program: ex("pi4j", "i2c write1 0x60,0x26,0x39") 'Active mode, OSR=128, barometer mode(0x39)
program: delay(10)
program: '
program: 'get the barometer value
program: v1=ex("pi4j", "i2c read1 0x60,0x01")
program: v2=ex("pi4j", "i2c read1 0x60,0x02")
program: v3=ex("pi4j", "i2c read1 0x60,0x03")
program: v=s2i(v1)*1.0
program: v=v*256.0+s2i(v2)*1.0
program: v=v*4.0+(s2i(v3) /64)*1.0
program: v=v/100
program: ex("service","putSendBuffer device=pressure, 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/2/23/ 0:4:56, v=22.02606201171875
device=humid, Date=2019/2/23/ 0:4:56,v=47.2412109375
device=lux, Date=2019/2/23/ 0:4:56, v=12
device=pressure, Date=2019/2/23/ 0:4:56, v=0.0
device=temp, Date=2019/2/23/ 0:5:26, v=22.0159912109375
device=humid, Date=2019/2/23/ 0:5:26,v=47.4365234375
device=lux, Date=2019/2/23/ 0:5:26, v=12
device=pressure, Date=2019/2/23/ 0:5:26, v=0.0
currentDevice="yamaRasPiDp1_1",Date=2019/2/23/ 0:5:26