Post your best Lua script examples here

User avatar
By w11
#25832 Sorry for pushing an old thread.
Quick question: Is it possible to wire the DHT22 to another Pin than GPIO2?

The documentation says, that GPIO has two more functions as: I2SO_WS and U1TXD.
For me I need UART1 for debuggung purposes, so GPIO2 is reserved for me.
What does I2SO_WS mean? Is it nessesary for the DHT22? Or is there another logic, why everyone is using GPIO2 for the DHT22.
Thanks!
User avatar
By jsgalway8266
#26179 So, I have improved the power supply on my sensor and got the following results via the WOTS.LUA code.

dofile(wots.lua) Sunday, August 16, 2015 12:17:48

dofile("wots.lua")
checksum 123
checksumTest 122
humidity - timing of bits 1 5 1 1 4 1 1 1 1 1 1 1 1 1 2 1
temperat - timing of bits 1 1 5 4 1 1 5 1 1 1 1 1 1 1 1 1
checksum - timing of bits 1 5 5 4 4 1 4 10
Humidity: 0%
Temperature: 50 deg C
>

What am I missing? :?:
User avatar
By Oetsch
#30369 Hi Everybody,

I´m starting my first ESP8266 project so please let me kindly ask for your understanding if a question might be too stupi. I have also no lua expirence so your support is appriacited very much. I was very happy to find your examples and inputs by this topic because it really catches my point and what i like to do.

What I have:
ESP8266-12 (flashed with nodemcu 0.9.6_20150704 float)
BreadBoard with Power Supply
DHT11 sensor

What I like to do:
Simple webpage with the actual temperature and humidity (no thinkspeak etc.)
so first I like to test based on the code of reply #11189 (wots.lua & testdht.lua)

But I got no plausible results and please let me kindly ask for your support and ideas what can be wrong.

Thanks in advance!

Code: Select all> dofile("wots.lua")
checksum    207
checksumTest    201
humidity - timing of bits      0 1 4 1 4 1 1 1 1 1 1 1 1 1 1 1
temperat - timing of bits      4 1 5 1 1 1 1 1 1 1 1 1 1 1 1 5
checksum - timing of bits      5 4 1 1 4 10 10 10
Humidity:    0%
Temperature: -32.00390625 deg C
User avatar
By CaqKa
#32388 Thanks, the wots.lua and testdht.lua combination is also working for me.
My config is NodeMCU devkit 0.9 with a lots of RSV pins on the left upper side. my sensor is DHT11.

I suggest that the forum moderators put such working post somewhere pined on the top.

aventrax wrote:
jankop wrote:Test it!
1. Is your sensor really connected to GPIO2 ?
2. Is sensor properly connected to ground?
3. Is your terminals wiring okay?
Save test program wots.lua and modul testdht.lua
Load it to esp8266 and run wots.lua.
Bring result.
Then we can talk of an additional cases.

This is proper communication with DHT11. DHT22 is very similar.
Code: Select alldofile("wots.lua")
checksum    58
checksumTest    58
humidity - timing of bits      0 1 5 1 1 5 1 4 1 1 1 1 1 1 1 1
temperat - timing of bits      1 1 1 5 1 5 1 4 1 1 1 1 1 1 1 1
checksum - timing of bits      1 1 5 5 5 1 5 1
Humidity:    37%
Temperature: 21 deg C


And here the sensor is disconnected .
Code: Select alldofile("wots.lua")
checksum    255
checksumTest    252
humidity - timing of bits      10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
temperat - timing of bits      10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
checksum - timing of bits      10 10 10 10 10 10 10 10
Humidity:    0%
Temperature: -127.99609375 deg C



Here's mine:

Code: Select allNodeMCU 0.9.5 build 20150318  powered by Lua 5.1.4
lua: cannot open init.lua
>
dofile(wots.lua)  martedì 28 luglio 2015  10:02:15

dofile("wots.lua")
checksum    239
checksumTest    239
humidity - timing of bits      0 1 2 1 1 2 1 5 5 5 5 2 1 5 1 1
temperat - timing of bits      2 2 1 1 1 1 1 5 1 1 1 1 5 1 1 5
checksum - timing of bits      5 5 5 2 5 5 5 5
Humidity:    1.890625%
Temperature: 1.03515625 deg C


With the ufficial code I'm able to get the right temperature but the humidity is always "-0.1", "-0.1.9" or "-1".... I tried another DHT22 (working on the GPIO of the raspberryPI) without any luck. I tried with or without the pullup between the data and vcc (3.3v).

As you can see the nodeMCU version is 0.9.5-20150318 but I tried 20150212, 20150213 with the same results. My ESP is version ESP-01 (tried two of them).

How can I get the right humidity?



[UPDATE]: I missed to set the sensortype to DHT22. It works!! Using your dhttest.lua even my scripts are working, not only temperature but also humidity! Can you explain what can be different from the "ufficial" library https://github.com/javieryanez/nodemcu- ... /dht22.lua compared to yours? Thanks Again!