'GAUGE FAST 1 (LDR)
Dim b(8) ' ADC DATA
Dim c(24)' CAL DATA P/T
Dim h(7) ' CAL DATA HUM
i2c.setup(D2,D1)
adr = hextoint("76")
reg = hextoint("88")' TEMP/PRESS calibration data
i2c.begin(adr)
i2c.write(reg)
i2c.end()
delay 10
i2c.requestfrom(adr,24)
for i = 0 to 23
c(i) = i2c.read()
'Print i&" "&c(i)
next i
dig_T1=c(0)+c(1)<<8
dig_T2=c(2)+c(3)<<8
dig_T3=c(4)+c(5)<<8
dig_P1 = c(6) + 256 * c(7)
dig_P2 = c(8) + 256 * c(9)
dig_P3 = c(10) + 256 * c(11)
dig_P4 = c(12) + 256 * c(13)
dig_P5 = c(14) + 256 * c(15)
dig_P6 = c(16) + 256 * c(17)
dig_P7 = c(18) + 256 * c(19)
dig_P8 = c(20) + 256 * c(21)
dig_P9 = c(22) + 256 * c(23)
'Signed!
if dig_T2 > 32767 then dig_T2 = dig_T2 - 65536
if dig_T3 > 32767 then dig_T3 = dig_T3 - 65536
if dig_P2 > 32767 then dig_P2 = dig_P2 - 65536
if dig_P3 > 32767 then dig_P3 = dig_P3 - 65536
if dig_P4 > 32767 then dig_P4 = dig_P4 - 65536
if dig_P5 > 32767 then dig_P5 = dig_P5 - 65536
if dig_P6 > 32767 then dig_P6 = dig_P6 - 65536
if dig_P7 > 32767 then dig_P7 = dig_P7 - 65536
if dig_P8 > 32767 then dig_P8 = dig_P8 - 65536
if dig_P9 > 32767 then dig_P9 = dig_P9 - 65536
'HUMIDITY
reg = hextoint("A1") 'HUM calibration data
i2c.begin(adr)
i2c.write(reg)
i2c.end()
delay 10
i2c.requestfrom(adr,1)
dig_H1 = i2c.read()
reg = hextoint("E1") 'HUM calibration data
i2c.begin(adr)
i2c.write(reg)
i2c.end()
delay 10
i2c.requestfrom(adr,7)
for i = 0 to 6
h(i) = i2c.read()
'Print i&" "&h(i)
next i
dig_H2 = h(0) + (h(1) * 256) 'int16
dig_H3 = h(2) 'uint8
dig_H4 = h(3) * 16 + (h(4) and 15) 'uint16
dig_H5 = h(5) * 16 + (h(4) and 240) / 16 'uint16
dig_H6 = h(6) ' int8
if dig_H2 > 32767 then dig_H2 = dig_H2 - 65536
if dig_H6 > 127 then dig_H6 = dig_H6 - 256
reg = hextoint("F2") 'HUM MODE
i2c.begin(adr)
i2c.write(reg)
i2c.write(5) 'Reg F2 = 00000101
i2c.end()
reg = hextoint("F4")' PRESS/TEMP Mode
i2c.begin(adr)
i2c.write(reg)
i2c.write(32+7)'Reg F4 = 00100111
i2c.end()
html "from ESP8266 LDR - Berndt 2016
"
meter h,960,1060
idh = htmlid()
Textbox dat
meter T,-50,50
idt = htmlid()
Textbox hum
html " %