-->
Page 1 of 2

yet-another-dht22 Is leaner on HEAP!

PostPosted: Wed Feb 04, 2015 7:57 pm
by iHaveESP
The alternative DHT module is leaner on heap ( ~700b). See https://github.com/nodemcu/nodemcu-firmware/tree/master/lua_examples

I have DHT11:

I made the following change to the module for DHT11 ( I don't have DHT22):

--h = 10 * b[1]
--t = 10 * b[3]
h = b[1]
t = b[3]

..it will return integer values for t and h.

This should be included in the usage example:

t, h = require("yet-another-dht22").read(4)
-- unload module
yet-another-dht22 = nil
package.loaded["yet-another-dht22"] = nil

-- t and h remain available to your program, call above to update variables and release
print(t)
print(h)

-Cheers!

Re: yet-another-dht22 Is leaner on HEAP!

PostPosted: Fri Feb 06, 2015 10:58 am
by Hans174
I tried yet-another-dht22 on my ESP-01 but instead of 700 bytes the module consumes 4100 bytes. Is there a trick to reduce the amount of memory to 700 bytes?

Re: yet-another-dht22 Is leaner on HEAP!

PostPosted: Fri Feb 06, 2015 7:48 pm
by iHaveESP
I should have been clearer, it's savings is the difference between the two:

" yet-another-dht22" not setting to "true", I have DHT11:
24056
> dht11 = require("dht11_dvv")
> =node.heap()
19848
>

"nodeMCU adopted module":
> =node.heap()
24056
> dht22 = require("dht22")
> =node.heap()
19104

...can mean the difference in stability vs reboots.

Re: yet-another-dht22 Is leaner on HEAP!

PostPosted: Sat Feb 07, 2015 11:29 am
by Fr4gg0r
If you implement it in C, it should only consume a few bytes (~ some function pointers and the name of the lua method) statically. ;)

Also you won't have any troubles with floats in C etc.