Post your best Lua script examples here

User avatar
By rutierut
#24300
Will Guo wrote:Dear all,
I have try the code for controlling gpio2, but my esp8266-01 cannot connect MQTT node of node-red running by Raspberry pi. Who can show me the configuration of MQTT node in Node-red, I do not know where exist problems.


Check the two first links in the first post of this thread, they should help you out.
User avatar
By rutierut
#34404 Hey, the pull up is indeed the correct way of doing it. I am no longer active on this forum so will not be responding too often (I switched to the cpp version too since the Lua interpreter caused too many problems with larger programs) will check occasionally though. :D
User avatar
By jhaury
#36049 Hey guys, I am having some issues here with the DHT22. I was able to get the code working and posting to MQTT but not with the version of dht22.lua listed on Github. I had to find an older version somewhere out there on the web. The github version crashes my ESP with the last message being "Connected to MQTT:10.0.0.150:1883", then it reboots. Every time.

I was able to get it working but in the version I have working the temp and humidity are all over the place:

Temp:-3277.2.9999999999272
Humidity: -0.1.9

I did some reading and found that to use these scripts you must be using nodemcu-float. I have tried float and I have tried integer and both gave me the same exact results. What am I missing? There are so many copy/pasted versions in this thread. Does anyone have a working copy that can link the dht22.lua file they are using? Is it the same as the github version?

Using an ESP-01 if that makes any difference, its all breadboarded and using a 2a power supply.
User avatar
By ScheissSchiesser
#38902
jhaury wrote:Hey guys, I am having some issues here with the DHT22. I was able to get the code working and posting to MQTT but not with the version of dht22.lua listed on Github. I had to find an older version somewhere out there on the web. The github version crashes my ESP with the last message being "Connected to MQTT:10.0.0.150:1883", then it reboots. Every time.

I was able to get it working but in the version I have working the temp and humidity are all over the place:

Temp:-3277.2.9999999999272
Humidity: -0.1.9

I did some reading and found that to use these scripts you must be using nodemcu-float. I have tried float and I have tried integer and both gave me the same exact results. What am I missing? There are so many copy/pasted versions in this thread. Does anyone have a working copy that can link the dht22.lua file they are using? Is it the same as the github version?

Using an ESP-01 if that makes any difference, its all breadboarded and using a 2a power supply.


Not sure if you have solved this yet, but what version of the firmware are you using? You should be able to use the built-in "dht" module (not the dht22.lua file). Look it up on the nodemcu github. The command syntax is listed there for the integer and float versions of the firmware, I believe.