Post your best Lua script examples here

User avatar
By javiery
#6913 I just finished the module to DHT22. This in https://github.com/javieryanez/nodemcu-modules/tree/master/dht22.

There is also an example that provides humidity in %, and temperature in Farenheit and Celsius.

I've put Pigs FLy in the credits, please watch it and tell me if you agree. Maybe you prefer a real name.
User avatar
By Pigs Fly
#6990 Well done Javiery, thanks!

Re your note on the modulus calc, I see my error now, thanks for clearing it up. I had meant to make that an AND operation but used the mod operator instead. Good catch.
User avatar
By javiery
#7019
alko wrote:Highest bit of temperature is '1' it means that temperature is below '0'.

Code: Select allif bit.isset(temperature, 15) then
     temperature = -bit.clear(temperature , 15)
end

True!, my module does not work for negative temperatures. I'll fix it.