javieryanez / nodemcu-modules

Modules for nodeMcu (LUA intepreter for ESP8266)
76 stars 47 forks source link

Problem in the bmp180.lua #7

Open jimbolimbo3 opened 8 years ago

jimbolimbo3 commented 8 years ago

The terminal says:

bmp180.lua:95: divide by zero

The line 95 is this: local X1 = (UT - AC6) * AC5 / 32768

Do you have any idea why?

vxf commented 8 years ago

I can see a possible division by zero on the line below that: https://github.com/javieryanez/nodemcu-modules/blob/master/bmp180/bmp180.lua#L96

Which as you can see on Bosch provided driver, based on the same algorithms, does a check before to avoid the division by zero: https://github.com/BoschSensortec/BMP180_driver/blob/master/bmp180.c#L227-L229

So there's indeed a possible division by zero but is not checked by this lua module.