Created
April 10, 2015 15:55
-
-
Save analog-io/742cfb4a6c2d3499e172 to your computer and use it in GitHub Desktop.
Fixed point Si7020 Math
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local rh = read_reg(0x40,0xE5,true) | |
local t = read_reg(0x40,0xE0,false) | |
rh = string.byte(rh,1)*256+string.byte(rh,2) | |
t = string.byte(t,1)*256+string.byte(t,2) | |
t=(17572*t)/65536-4685 | |
t=tostring(t*18+32000) | |
rh=tostring(rh*12500/65536-600) | |
t=t:sub(1,t:len()-3).."."..t:sub(t:len()-2,t:len()) | |
rh=rh:sub(1,rh:len()-2).."."..rh:sub(rh:len()-1,rh:len()) | |
print(t.." : "..rh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment