From b3ae9d143db157fa8cb17125baf1a2b7bd14d582 Mon Sep 17 00:00:00 2001 From: Vowstar Date: Sat, 5 Dec 2015 13:49:31 +0800 Subject: [PATCH 1/3] Add DHT sensor lib description in ReadMe A lot of people don't know DHT sensor lib. --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 7d140e72..e0b73768 100644 --- a/README.md +++ b/README.md @@ -638,3 +638,31 @@ The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain. -- Read ch A with 128 gain. raw_data = hx711.read(0) ``` + +####Universal DHT Sensor support +Support DHT11, DHT21, DHT22, DHT33, DHT44, etc. +Use all-in-one function to read DHT sensor. +```lua + +pin = 5 +status,temp,humi,temp_decimial,humi_decimial = dht.readxx(pin) +if( status == dht.OK ) then + -- Integer firmware using this example + print( + string.format( + "DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n", + math.floor(temp), + temp_decimial, + math.floor(humi), + humi_decimial + ) + ) + -- Float firmware using this example + print("DHT Temperature:"..temp..";".."Humidity:"..humi) +elseif( status == dht.ERROR_CHECKSUM ) then + print( "DHT Checksum error." ); +elseif( status == dht.ERROR_TIMEOUT ) then + print( "DHT Time out." ); +end + +``` From 1217b477791f0288714a0cabb72dd12f6652ab32 Mon Sep 17 00:00:00 2001 From: Nick Andrew Date: Sun, 6 Dec 2015 11:21:52 +1100 Subject: [PATCH 2/3] Update README SDK; remove todo list Based on @vowstar edits: * Note that the SDK is the NONOS one * Add links for NodeMCU devkit v1.0 and distinguish from v0.9 * Remove the ToDo list (as all are complete but for 1 item) --- README.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e0b73768..03ffaa0f 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ [![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware) ###A lua based firmware for wifi-soc esp8266 - - Build on [ESP8266 sdk 1.4.0](http://bbs.espressif.com/viewtopic.php?f=46&t=1124) + - Build on [ESP8266 NONOS SDK 1.4.0](http://bbs.espressif.com/viewtopic.php?f=46&t=1124) - Lua core based on [eLua project](http://www.eluaproject.net/) - cjson based on [lua-cjson](https://github.com/mpx/lua-cjson) - File system based on [spiffs](https://github.com/pellepl/spiffs) - - Open source development kit for NodeMCU [nodemcu-devkit](https://github.com/nodemcu/nodemcu-devkit) + - Open source development kit for NodeMCU [nodemcu-devkit-v0.9](https://github.com/nodemcu/nodemcu-devkit) [nodemcu-devkit-v1.0](https://github.com/nodemcu/nodemcu-devkit-v1.0) # Summary @@ -33,15 +33,6 @@ | ESPlorer GUI | https://github.com/4refr0nt/ESPlorer | | NodeMCU Studio GUI | https://github.com/nodemcu/nodemcu-studio-csharp | -# To Do List (pull requests are very welcome) - -- loadable c module -- fix wifi smart connect -- add spi module (done) -- add mqtt module (done) -- add coap module (done) -- cross compiler (done) - # Programming Examples Because Lua is a high level language and several modules are built into the firmware, you can very easily program your ESP8266. Here are some examples! From 570bddcfe5ad1a0d7d8108a231f9c8ac4c3ed9d2 Mon Sep 17 00:00:00 2001 From: Nick Andrew Date: Sun, 6 Dec 2015 11:36:19 +1100 Subject: [PATCH 3/3] More README tweaks now that master was updated * Remove the "0.9.6; deprecated" comment regarding the master branch * Add a paragraph on enabling debugging * Clarify (I hope) the conditions under which you need to reformat your flash filesystem. * Remove trailing blanks Signed-off-by: Nick Andrew --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 03ffaa0f..e60b9972 100644 --- a/README.md +++ b/README.md @@ -211,8 +211,7 @@ There are several options for building the NodeMCU firmware. Please try Marcel's [NodeMCU custom builds](http://frightanic.com/nodemcu-custom-build) cloud service and you can choose only the modules you need, and download the firmware once built. -NodeMCU custom builds can build from the master branch (0.9.6; deprecated) and dev -branch (1.4.0). +NodeMCU custom builds can build from the master branch and dev branch (with the latest fixes). ## Docker containerised build @@ -316,6 +315,16 @@ editing `app/include/user_config.h` and change BIT_RATE_DEFAULT, e.g.: #define BIT_RATE_DEFAULT BIT_RATE_115200 ``` +## Debugging + +To enable runtime debug messages to serial console, edit `app/include/user_config.h` + +```c +#define DEVELOP_VERSION +``` + +`DEVELOP_VERSION` changes the startup baud rate to 74880. + # Flash the firmware ## Flash tools for Windows @@ -349,7 +358,8 @@ Otherwise, if you built your own firmware from source code: Also, in some special circumstances, you may need to flash `blank.bin` or `esp_init_data_default.bin` to various addresses on the flash (depending on flash size and type). -If upgrading from `spiffs` version 0.3.2 to 0.3.3 or later, or after flashing any new firmware, you should run `file.format()` to re-format your flash filesystem. +If upgrading from `spiffs` version 0.3.2 to 0.3.3 or later, or after flashing any new firmware (particularly one with a much different size), you may need to run `file.format()` to re-format your flash filesystem. +You will know if you need to do this because your flash files disappeared, or they exist but seem empty, or data cannot be written to new files. # Connecting to your NodeMCU device @@ -607,7 +617,7 @@ cc:post(coap.NON, "coap://192.168.18.100:5683/", "Hello") ####cjson ```lua -- Note that when cjson deal with large content, it may fails a memory allocation, and leaks a bit of memory. --- so it's better to detect that and schedule a restart. +-- so it's better to detect that and schedule a restart. -- -- Translate Lua value to/from JSON -- text = cjson.encode(value) @@ -622,7 +632,7 @@ json_text = cjson.encode(value) ####Read an HX711 load cell ADC. Note: currently only chanel A with gain 128 is supported. -The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain. +The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain. ```lua -- Initialize the hx711 with clk on pin 5 and data on pin 6 hx711.init(5,6) @@ -631,7 +641,7 @@ The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain. ``` ####Universal DHT Sensor support -Support DHT11, DHT21, DHT22, DHT33, DHT44, etc. +Support DHT11, DHT21, DHT22, DHT33, DHT44, etc. Use all-in-one function to read DHT sensor. ```lua @@ -639,7 +649,7 @@ pin = 5 status,temp,humi,temp_decimial,humi_decimial = dht.readxx(pin) if( status == dht.OK ) then -- Integer firmware using this example - print( + print( string.format( "DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n", math.floor(temp),