FrontPage
objectPage http://www.yama-lab.org/fwb4pi/index.php?i2c-mpl3115a2-ex1 or http://www.yama-lab.org/fwb4pi/index.php?i2c-mpl3115a2-ex1
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: '
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: ex("pi4j", "i2c write1 0x60, 0x26, 0xb9")
program: delay(5)
program: ex("pi4j", "i2c write1 0x60, 0x13, 0x07")
program: delay(5)
program: ex("pi4j", "i2c write1 0x60, 0x26, 0x38")
program: '
program: '#define CTRL_REG1 0x26
program: '
program: ' - if (!pressureDataReady()) ... dataReady(0x04)
program: ' -- dataReady(0x04)
program: '--- int attempts=0
program: ' --- while((i2cRead(STATUS) & mask) == 0){
program: ' ---- attempts++
program: ' ---- if(attempts > MAX_DATA_READY_ATTEMPTS) return 0
program: ' ---- wait_ms(1)
program: ' ---- write fail
program: for i= 0 to 512
program: temps=ex("pi4j", "i2c read1 0x60,0x00")
program: f=s2i(temps)& 0x04
program: if f <> 0 then i=512
program: delay(1)
program: next i
program: ' _i2c->start()
program: ' if( _i2c->write(MPL3115A2_address!=1) write fail
program: ' if( _i2c->write(OUT_P_MSB)!=1) write fail
program: ' _i2c->read(MPL3115A2_address, (*p), pressure::size)
program: ' p->setPressure()
program: '
program: 'readPressure
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: 'vs=ex("pi4j", "i2c read2 0x60,0x01")
program: ex("pi4j", "i2c write-b 0x60,0x01")
program: v12=ex("pi4j", "i2c read-A-2 0x60")
program: 'ex("pi4j", "i2c write-b 0x60,0x03")
program: 'v3=ex("pi4j", "i2c read-A-1 0x60")
program: v3=ex("pi4j", "i2c read1 0x60,0x03")
program: 'v=s2i(vs) & 0xffff
program: 'v=(((s2i(v1) & 0xff)*256.0+ (s2i(v2) & 0xff))*256.0 + s2i(v3) & 0xff)/64
program: v=(s2i(v12) & 0xffff)*256.0
program: vv=s2i(v3) & 0xff
program: v=(v+vv)/64
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=pressure, Date=2019/2/24/ 0:23:24, v=2441.0853125
currentDevice="yamaRasPiDp1_1",Date=2019/2/24/ 0:23:24