There's some lua modules and examples in the repo. hope it helps.
https://github.com/nodemcu/nodemcu-firmware/blob/master/modules/ds18b20/ds18b20.EN.md
print(node.heap())
ds18b20 = require("ds18b20")
-- do something with it
ds18b20 = nil
package.loaded["ds18b20"]=nil -- release and retrieve ram
print(node.heap())