- Tue Dec 16, 2014 8:24 am
#4931
JohnPap70 wrote:Thank you for your answer! I am new to Lua and I was trying to write a few sensor drivers.
How I will define that a variable of mine is a float in the Lua running on the ESP chip?
I would suggest to take a look into the example for DS1820 - you can see the temperature calculation, which should be done by multiplication of resulting integer by 0.0625 to get degrees Celsius.
However, instead of this, the number is multiplied by 625, resulting in 4 decimal places.
Than, you can display the number as
Code: Select allprint(resultValue/10000 .. "." .. string.format("%04d", resultValue%10000))
Does it help?