From f5fcd0d9849b2320057b68c8e53c01df0abc9235 Mon Sep 17 00:00:00 2001 From: galjonsfigur <44552519+galjonsfigur@users.noreply.github.com> Date: Sun, 16 Dec 2018 21:39:43 +0100 Subject: [PATCH] Recreate and unify documentation for Lua modules (#2592) * Recreate and unify documentation for Lua modules * Fix typos in docs * Added/modified READMES to link to new documentation --- docs/en/lua-modules/bh1750.md | 73 ++++++++ docs/en/lua-modules/ds18b20.md | 78 ++++++++ docs/en/lua-modules/ds3231.md | 302 +++++++++++++++++++++++++++++++ docs/en/lua-modules/ftpserver.md | 88 +++++++++ docs/en/lua-modules/hdc1000.md | 108 +++++++++++ docs/en/lua-modules/http.md | 46 +++++ docs/en/lua-modules/imap.md | 148 +++++++++++++++ docs/en/lua-modules/lm92.md | 207 +++++++++++++++++++++ docs/en/lua-modules/mcp23008.md | 113 ++++++++++++ docs/en/lua-modules/redis.md | 86 +++++++++ docs/en/lua-modules/yeelink.md | 58 ++++++ lua_modules/bh1750/README.md | 3 + lua_modules/ds18b20/README.md | 66 +------ lua_modules/ds3231/README.md | 3 + lua_modules/email/README.md | 3 + lua_modules/ftp/README.md | 108 +---------- lua_modules/hdc1000/README.md | 47 +---- lua_modules/http/README.md | 3 + lua_modules/lm92/README.md | 278 +--------------------------- lua_modules/mcp23008/README.md | 3 + lua_modules/redis/README.md | 3 + lua_modules/yeelink/README.md | 3 + mkdocs.yml | 23 ++- 23 files changed, 1352 insertions(+), 498 deletions(-) create mode 100644 docs/en/lua-modules/bh1750.md create mode 100644 docs/en/lua-modules/ds18b20.md create mode 100644 docs/en/lua-modules/ds3231.md create mode 100644 docs/en/lua-modules/ftpserver.md create mode 100644 docs/en/lua-modules/hdc1000.md create mode 100644 docs/en/lua-modules/http.md create mode 100644 docs/en/lua-modules/imap.md create mode 100644 docs/en/lua-modules/lm92.md create mode 100644 docs/en/lua-modules/mcp23008.md create mode 100644 docs/en/lua-modules/redis.md create mode 100644 docs/en/lua-modules/yeelink.md create mode 100644 lua_modules/bh1750/README.md create mode 100644 lua_modules/ds3231/README.md create mode 100644 lua_modules/email/README.md create mode 100644 lua_modules/http/README.md create mode 100644 lua_modules/mcp23008/README.md create mode 100644 lua_modules/redis/README.md create mode 100644 lua_modules/yeelink/README.md diff --git a/docs/en/lua-modules/bh1750.md b/docs/en/lua-modules/bh1750.md new file mode 100644 index 00000000..dbcef38b --- /dev/null +++ b/docs/en/lua-modules/bh1750.md @@ -0,0 +1,73 @@ +# BH1750 Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-01-30 | [Martin Han](https://github.com/MarsTechHAN) | [Martin Han](https://github.com/MarsTechHAN) | [bh1750.lua](../../../lua_modules/bh1750/bh1750.lua) | + +This Lua module provides access to [BH1750](https://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf) I²C ambient light sensor. + +!!! note + This module requires `i2c` C module built into firmware. + +### Require +```lua +bh1750 = require("bh1750") +``` + +### Release +```lua +bh1750 = nil +package.loaded["bh1750"] = nil +``` + +## bh1750.init() +Initializes the module and sets up I²C with hardcoded device address. + +#### Syntax +`bh1750.init(sda, scl)` + +#### Parameters +- `sda` SDA pin number. +- `scl` SCL pin number. + +#### Returns +`nil` + +## bh1750.read() +Reads lux value from the sensor. + +#### Syntax +`bh1750.read()` + +#### Parameters +None + +#### Returns +Lux value. + +## bh1750.getlux() +Function used to return last read lux value. + +#### Syntax +`bh1750.getlux()` + +#### Parameters +None + +#### Returns +Last known lux value. + +#### Example +```lua +SDA_PIN = 6 -- sda pin, GPIO12 +SCL_PIN = 5 -- scl pin, GPIO14 + +bh1750 = require("bh1750") +bh1750.init(SDA_PIN, SCL_PIN) +bh1750.read() +l = bh1750.getlux() +print("lux: "..(l / 100).."."..(l % 100).." lx") + +-- release module +bh1750 = nil +package.loaded["bh1750"] = nil +``` \ No newline at end of file diff --git a/docs/en/lua-modules/ds18b20.md b/docs/en/lua-modules/ds18b20.md new file mode 100644 index 00000000..12d9e887 --- /dev/null +++ b/docs/en/lua-modules/ds18b20.md @@ -0,0 +1,78 @@ +# DS18B20 Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2014-12-08 | [Huang Rui](https://github.com/vowstar) | [Huang Rui](https://github.com/vowstar) | [ds18b20.lua](../../../lua_modules/ds18b20/ds18b20.lua) | + +This Lua module provides access to [DS18B20](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) 1-Wire digital thermometer. + +!!! note + The module requires `ow` C module built into firmware. + +### Require +```lua +ds18b20 = require("ds18b20") +``` + +### Release +```lua +ds18b20 = nil +package.loaded["ds18b20"] = nil +``` + +## enable_debug() +Enables debug output of the module. + +#### Parameters +None + +#### Returns +`nil` + +## ds18b20.read_temp() +Scans the bus for DS18B20 sensors (optional), starts a readout (conversion) for all sensors and calls a callback function when all temperatures are available. Powered sensors are read at once first. Parasite-powered sensors are read one by one. The first parasite-powered sensor is read together with all powered sensors. + +#### Syntax +`read_temp(callback, pin, unit, force_search, save_search)` + +#### Parameters +- `callback` function that receives all results when all conversions finish. The callback function has one parameter - an array addressed by sensor addresses and a value of the temperature (string for integer version). +- `pin` pin of the one-wire bus. If nil, GPIO0 (3) is used. +- `unit` unit can be Celsius ("C" or ds18b20.C), Kelvin ("K" or `ds18b20.K`) or Fahrenheit ("F" or `ds18b20.F`). If not specified (`nil`) latest used unit is used. +- `force_search` if not nil a bus search for devices is performed before readout. If nil the existing list of sensors in memory is used. If the bus has not been searched yet the search performed as well. +- `save_search` if not nil found sensors are saved to the file `ds18b20_save.lc`. When `read_temp` is called, list of sensors in memory is empty and file `ds18b20_save.lc` is present then sensor addresses are loaded from file - useful when running from batteries & deepsleep - immediate readout is performed (no bus scan). + +#### Returns +`nil` + +#### Example +```lua +local t = require("ds18b20") +local pin = 3 -- gpio0 = 3, gpio2 = 4 + +local function readout(temp) + if t.sens then + print("Total number of DS18B20 sensors: ".. #t.sens) + for i, s in ipairs(t.sens) do + print(string.format(" sensor #%d address: %s%s", i, ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(s:byte(1,8)), s:byte(9) == 1 and " (parasite)" or "")) + end + end + for addr, temp in pairs(temp) do + print(string.format("Sensor %s: %s °C", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(addr:byte(1,8)), temp)) + end + + -- Module can be released when it is no longer needed + t = nil + package.loaded["ds18b20"] = nil +end + +t:read_temp(readout, pin, t.C) +``` + +## ds18b20.sens +A table with sensors present on the bus. It includes its address (8 bytes) and information whether the sensor is parasite-powered (9-th byte, 0 or 1). + +## ds18b20.temp +A table with readout values (also passed as a parameter to callback function). It is addressed by sensor addresses. + +#### Notes +Other examples of using this module can be found in [ds18b20-example.lua](../../../lua_modules/ds18b20/ds18b20-example.lua) and [ds18b20-web.lua](../../../lua_modules/ds18b20/ds18b20-web.lua) files. \ No newline at end of file diff --git a/docs/en/lua-modules/ds3231.md b/docs/en/lua-modules/ds3231.md new file mode 100644 index 00000000..d2a4934e --- /dev/null +++ b/docs/en/lua-modules/ds3231.md @@ -0,0 +1,302 @@ +# DS3231 Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-01-19 | [Tobie Booth](https://github.com/tobiebooth) | [Tobie Booth](https://github.com/tobiebooth) | [ds3231.lua](../../../lua_modules/ds3231/ds3231.lua) | + +This Lua module provides access to [DS3231](https://datasheets.maximintegrated.com/en/ds/DS3231.pdf) I²C real-time clock. + +!!! note + This module requires `i2c` C module built into firmware. + +### Require +```lua +ds3231 = require("ds3231") +``` + +### Release +```lua +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231.setTime() +Sets the current date and time. If _disableOscillator_ is set to 1 the oscillator will **stop** on battery. + +#### Syntax +`ds3231.setTime(second, minute, hour, day, date, month, year[, disableOscillator])` + +#### Parameters +- `second`: 00-59 +- `minute`: 00-59 +- `hour`: 00-23 +- `day`: 1-7 (Sunday = 1, Saturday = 7) +- `date`: 01-31 +- `month`: 01-12 +- `year`: 00-99 +- `disableOscillator`: (optional) 0-1, defaults to 0 if omitted + +#### Returns +`nil` + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231 = require("ds3231") + +-- Set date and time to Sunday, January 18th 2015 6:30PM +ds3231.setTime(0, 30, 18, 1, 18, 1, 15); + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231.getTime() +Get the current date and time. + +#### Syntax +`ds3231.getTime()` + +#### Parameters +None + +#### Returns +- `second`: integer. Second 00-59 +- `minute`: integer. Minute 00-59 +- `hour`: integer. Hour 00-23 +- `day`: integer. Day 1-7 (Sunday = 1, Saturday = 7) +- `date`: integer. Date 01-31 +- `month`: integer. Month 01-12 +- `year`: integer. Year 00-99 + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +-- Get date and time +second, minute, hour, day, date, month, year = ds3231.getTime(); + +-- Print date and time +print(string.format("Time & Date: %s:%s:%s %s/%s/%s", + hour, minute, second, date, month, year)) + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231setAlarm() +Set an alarm to be triggered on SQW pin. _alarm1_ has a precision of **seconds**; _alarm2_ has a precision of **minutes** (`second` parameter will be ignored). Alarms sets gpio.LOW over the SQW pin and let it unchanged until reloaded. When reloaded sets gpio.HIGH. Alarms trigger **only once**, after that, if you want them to trigger again, you need to call `reloadAlarms()` or `setAlarm(...)` again. + +Alarm type set the alarm match conditions: + +- `ds3231.EVERYSECOND` works only with _alarm1_ and triggers every second; +- `ds3231.EVERYMINUTE` works only with _alarm2_ and triggers every minute (at 00 seconds); +- `ds3231.SECOND` triggers when time match given `seconds` parameter; +- `ds3231.MINUTE` triggers when time match given `seconds` and `minutes` parameters; +- `ds3231.HOUR` triggers when time match given `seconds`, `minutes`, and `hours` parameters; +- `ds3231.DAY` triggers when time match given `seconds`, `minutes`, and `hours` on week day `date/day` parameters; +- `ds3231.DATE` triggers when time match given `seconds`, `minutes`, and `hours` on date (day of the month) `date/day` parameters; + +#### Syntax +`ds3231.setAlarm(alarmId, alarmType, seconds, minutes, hours, date/day)` + +#### Parameters +- `alarmId`: 1-2 +- `alarmType`: 1-7 +- `seconds`: 00-59 +- `minutes`: 00-59 +- `hours`: 00-23 +- `date/day`: 01-31 or 1-7 (Sunday = 1, Saturday = 7) + +#### Returns +`nil` + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +-- Setting PIN1 to triggers on interrupt when alarm triggers +gpio.mode(1,gpio.INT) +gpio.trig(1,'down',function(level) + print('Time is passing') + -- If not reloaded it will be triggered only once + ds3231.reloadAlarms() +end) + +ds3231.setAlarm(2,ds3231.EVERYMINUTE) + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231.reloadAlarms() +Reload an already triggered alarm. Otherwise it will never be triggered again. There are two different alarms and they have to be reloaded both to let, even only one, to be triggered again. So there isn't a param to select which alarm to reload. + +#### Syntax +`ds3231.reloadAlarms()` + +#### Parameters +None + +#### Returns +`nil` + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +-- Setting PIN1 to triggers on interrupt when alarm triggers +gpio.mode(1,gpio.INT) +gpio.trig(1,'down',function(level) + print('Time is passing') + -- If not reloaded it will be triggered only once + ds3231.reloadAlarms() +end) + +ds3231.setAlarm(2,ds3231.EVERYMINUTE) + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231.enableAlarm() +Enable an already setted alarm with the previous matching conditions. It reloads alarms internally. + +#### Syntax +`ds3231.enableAlarm(alarmId)` + +#### Parameters +`alarmId`: 1-2 + +#### Returns +`nil` + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +-- Trigger on x:20:15 +ds3231.setAlarm(1,ds3231.MINUTE,15,20) + +if badThing == 1 then + ds3231.disableAlarm(1) +end + +if goodThing == 1 then + ds3231.enableAlarm(1) +end + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231.disableAlarm() +Disable an already set alarm with the previous matching conditions. + +if _alarmId_ is not 1 or 2 it disables both alarms. + +**Warning**: `disableAlarm()` prevent alarms to trigger interrupt over SQW pin but alarm itself will triggers at the matching conditions as it could be seen on _status byte_. + +#### Syntax +`ds3231.disableAlarm(alarmId)` + +#### Parameters +`alarmId: 0-2` + +#### Returns +`nil` + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +-- Trigger on x:20:15 +ds3231.setAlarm(1,ds3231.MINUTE,15,20) + +if badThing == 1 then + ds3231.disableAlarm(1) +end + +if goodThing == 1 then + ds3231.enableAlarm(1) +end + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## ds3231.getBytes() +Get bytes of control, for debug purpose, and status of DS3231. To see what they means check the [datasheet](http://datasheets.maximintegrated.com/en/ds/DS3231.pdf). + +#### Syntax +`ds3231.getBytes()` + +#### Parameters +None + +#### Returns +- `control`: integer. Control 0-255 +- `status`: integer. Status 0-143 (bit 6-5-4 unused) + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +control,status = ds3231.getBytes() +print('Control byte: '..control) +print('Status byte: '..status) + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +## da3231.resetStopFlag() +Stop flag on status byte means that the oscillator either is stopped or was stopped for some period and may be used to judge the validity of the timekeeping data. When set to 1 this flag keeps that values until changed to 0. Call `resetStopFlag()` if you need to check validity of time data after that. + +#### Syntax +`ds3231.resetStopFlag()` + +#### Parameters +None + +#### Returns +`nil` + +#### Example +```lua +i2c.setup(3, 4, scl, i2c.SLOW) -- call i2c.setup() only once + +ds3231=require("ds3231") + +control,status = ds3231.getBytes() +if bit.band(bit.rshift(status, 7),1) == 1 then + print('[WARNING] RTC has stopped') + ds3231.resetStopFlag() +end + +-- Don't forget to release it after use +ds3231 = nil +package.loaded["ds3231"] = nil +``` + +#### Notes +Other examples of using this module can be found in [ds3231-example.lua](../../../lua_modules/ds3231/ds3231-example.lua) and [ds3231-web.lua](../../../lua_modules/ds3231/ds3231-web.lua) files. \ No newline at end of file diff --git a/docs/en/lua-modules/ftpserver.md b/docs/en/lua-modules/ftpserver.md new file mode 100644 index 00000000..8b2260a9 --- /dev/null +++ b/docs/en/lua-modules/ftpserver.md @@ -0,0 +1,88 @@ +# FTPServer Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2018-07-02 | [Terry Ellison](https://github.com/TerryE) | [Terry Ellison](https://github.com/TerryE) | [ftpserver.lua](../../../lua_modules/ftp/ftpserver.lua) | + +This Lua module implementation provides a basic FTP server for the ESP8266. It has been tested against a number of Table, Windows and Linux FTP clients and browsers. + +It provides a limited subset of FTP commands that enable such clients to transfer files to and from the ESP's file system. Only one server can be started at any one time, but this server can support multiple connected sessions (some FTP clients use multiple sessions and so require this feature). + +!!! warning + This module is too big to load by standard `require` function or compile on ESP8266 using `node.compile()`. The only option to load and use it is to use [LFS](../lfs.md). + +### Limitations +- FTP over SSH or TLS is not currently supported so transfer is unencrypted. +- The client session , must, authentical against a single user/password. +- Only the SPIFFS filesystem is currently supported, so changing directories is treated as a NO-OP. +- This implementation has been optimized for running in LFS. +- Only PASV mode is supported as the `net` module does not allow static allocation of outbound sockets. + +### Notes +The coding style adopted here is more similar to best practice for normal (PC) module implementations, as using LFS permits a bias towards clarity of coding over brevity. It includes extra logic to handle some of the edge case issues more robustly. It also uses a standard forward reference coding pattern to allow the code to be laid out in main routine, subroutine order. + +Most FTP clients are capable of higher transfer rates than the ESP SPIFFS write throughput, so the server uses TCP flow control to limit upload rates to the ESP. + +The following FTP commands are supported: + +- with no parameter: CDUP, NOOP, PASV, PWD, QUIT, SYST +- with one parameter: CWD, DELE, MODE, PASS, PORT, RNFR, RNTO, SIZE, TYPE, USER +- xfer commands: LIST, NLST, RETR, STOR + +This implementation is by [Terry Ellison](https://github.com/TerryE), but I wish to acknowledge the inspiration and hard work by [Neronix](https://github.com/NeiroNx) that made this possible. + +## createServer() +Create the FTP server on the standard ports 20 and 21. The global variable `FTP` is set to the server object. + +#### Syntax +`FTP.createServer(user, pass[, dbgFlag])` + +#### Parameters +- `user`: Username for access to the server +- `pass`: Password for access to the server +- `dbgFlag`: optional flag. If set true then internal debug output is printed + +#### Returns +`nil` + +#### Example +```Lua +require("ftpserver").createServer('user', 'password') +``` + +## open() +Wrapper to createServer() which also connects to the WiFi channel. + +#### Syntax +`FTP.open(user, pass, ssid, wifipwd, dbgFlag)` + +#### Parameters +- `user`: Username for access to the server +- `pass`: Password for access to the server +- `ssid`: SSID for WiFi service +- `wifipwd`: password for WiFi service +- `dbgFlag`: optional flag. If set true then internal debug output is printed + +#### Returns +`nil` + +#### Example +```Lua +require("ftpserver").open('myWifi', 'wifiPassword', 'user', 'password') +``` + +## close() +Close down server including any sockets and return all resources to Lua. Note that this include removing the FTP global variable and package references. + +#### Syntax +`FTP.close()` + +#### Parameters +None + +#### Returns +`nil` + +#### Example +```Lua +FTP.close() +``` \ No newline at end of file diff --git a/docs/en/lua-modules/hdc1000.md b/docs/en/lua-modules/hdc1000.md new file mode 100644 index 00000000..8c6cceba --- /dev/null +++ b/docs/en/lua-modules/hdc1000.md @@ -0,0 +1,108 @@ +# HDC1000 Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-03-07 | [Francesco Truzzi](https://github.com/ftruzzi) | [Francesco Truzzi](https://github.com/ftruzzi) | [hdc1000.lua](../../../lua_modules/hdc1000/HDC1000.lua) | + +This Lua module provides access to [HDC1000](https://www.ti.com/lit/ds/symlink/hdc1000.pdf) I²C digital humidity and temperature sensor. It should also work with HDC1008 sensor bout this haven't been tested. + +!!! note + This module requires `i2c` C module built into firmware. + +### Require +```lua +HDC1000 = require("HDC1000") +``` + +### Release +```lua +HDC1000 = nil +package.loaded["HDC1000"] = nil +``` + +## HDC1000.setup() +Function to setup the HDC1000 sensor. + +#### Syntax +`HDC1000.setup(drdyn)` + +#### Parameters +- `drdyn`: DRDYn pin number. If set to `false`, this feature will not be used and after each read request a 20ms delay will be added. + +#### Returns +`nil` + +#### Example +```lua +local sda, scl = 3, 4 -- Pins 3 and 4 will be used +local drdyn = 6 -- Pin 6 will be used to connect with DRDYn pin +i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once +HDC1000.setup(drdyn) +``` + +## HDC1000.config() +Function to configure various options of HDC1000 sensor. + +#### Syntax +`HDC1000.config(address, resolution, heater)` + +#### Parameters +- `address`: I²C sensor address. Default value is `0x40`. +- `resolution`: Temperature and humidity sensor resolution. Can be set to 14 bits for both temperature and humidity (`0x00`), 11 bits for temperature (`0x40`), 11 bits for humidity (`0x01`) or 8 bits for humidity (`0x20`). Default value is `0x00`. +- `heater`: Heater setting. `0x20` to enable and `0x00` to disable. Default value is `0x20`. + +#### Returns +`nil` + +## HDC1000.getTemp() +Reads the temperature from HDC1000 sensor. + +#### Syntax +`HDC1000.getTemp()` + +#### Parameters +None + +#### Returns +Temperature in Celsius degrees. + +## HDC1000.getHumi() +Reads the humidity value from HDC1000 sensor. + +#### Syntax +`HDC1000.getHumi()` + +#### Parameters +None + +#### Returns +Humidity in percents. + +## HDC1000.batteryDead() +Function that checks if voltage of sensor power supply is bellow or above 2.8V. + +#### Syntax +`HDC1000.batteryDead()` + +#### Parameters +None + +#### Returns +`true` if battery voltage is bellow 2.8V, `false` otherwise. + +#### Example +```lua +HDC1000 = require("HDC1000") + +sda = 1 +scl = 2 +drdyn = false + +i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once +HDC1000.setup(drdyn) +HDC1000.config() -- default values are used if called with no arguments. prototype is config(address, resolution, heater) + +print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi())) + +HDC1000 = nil +package.loaded["HDC1000"] = nil +``` \ No newline at end of file diff --git a/docs/en/lua-modules/http.md b/docs/en/lua-modules/http.md new file mode 100644 index 00000000..c250aa34 --- /dev/null +++ b/docs/en/lua-modules/http.md @@ -0,0 +1,46 @@ +# HTTP Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-01-19 | [Vladimir Dronnikov](https://github.com/dvv) | [Vladimir Dronnikov](https://github.com/dvv) | [http.lua](../../../lua_modules/http/http.lua) | + +This Lua module provides a simple callback implementation of a [HTTP 1.1](https://www.w3.org/Protocols/rfc2616/rfc2616.html) server. + +### Require +```lua +httpserver = require("http") +``` + +### Release +```lua +httpserver = nil +package.loaded["http"] = nil +``` + +## httpserver.createServer() +Function to start HTTP 1.1 server. + +#### Syntax +`httpserver.createServer(port, handler(req, res))` + +#### Parameters +- `port`: Port number for HTTP server. Most HTTP servers listen at port 80. +- `handler`: callback function for when HTTP request was made. + +#### Returns +`net.server` sub module. + +#### Notes +Callback function has 2 arguments : `req` (request) and `res` (response). The first object holds values: + +- `conn`: net.server sub module +- `method`: Request method like `POST` or `GET` +- `url`: Request URL +- `onheader`: value to setup handler function for HTTP headers +- `ondata`: value to setup handler function HTTP data like `content-type` + +The second object holds functions: +- `send(self, data, [response_code])`: Function to send data to client. `self` is `req` object, `data` is data to send and `response_code` is HTTP response code like 200 or 404 (for example) +- `send_header(self, header_name, header_data)` Function to send HTTP headers to client. `self` is `req` object, `header_name` is HTTP header name and `header_data` is HTTP header data for client. +- `finish([data])`: Function to finalize connection, optionally sending data. `data` is optional data to send on connection finalizing. + +Full example can be found in [http-example.lua](../../../lua_modules/http/http-example.lua) \ No newline at end of file diff --git a/docs/en/lua-modules/imap.md b/docs/en/lua-modules/imap.md new file mode 100644 index 00000000..3291b043 --- /dev/null +++ b/docs/en/lua-modules/imap.md @@ -0,0 +1,148 @@ +# IMAP Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-03-12 | [AllAboutEE](https://github.com/AllAboutEE) | [AllAboutEE](https://github.com/AllAboutEE) | [imap.lua](../../../lua_modules/email/imap.lua) | + +This Lua module provides a simple implementation of an [IMAP 4rev1](http://www.faqs.org/rfcs/rfc2060.html) protocol that can be used to read e-mails. + + +### Require +```lua +imap = require("imap.lua") +``` + +### Release +```lua +imap = nil +package.loaded["imap"] = nil +``` + +## imap.response_processed() +Function used to check if IMAP command was processed. + +#### Syntax +`imap.response_processed()` + +#### Parameters +None + +#### Returns +The response process status of the last IMAP command sent. If return value is `true` it means the command was processed. + + +## imap.config() +Initiates the IMAP settings. + +#### Syntax +`imap.config(username, password, tag, [debug])` + +#### Parameters +- `username`: IMAP username. For most e-mail providers e-mail address is used as username. +- `password`: IMAP password. +- `tag`: IMAP tag. With current implementation any tag like "t1" should work. +- `debug`: (boolean) if set to true entire conversation between the ESP8266 and IMAP server will be shown. Default setting is false. + +#### Returns +`nil` + +## imap.login() +Logs into a new email session. + +#### Syntax +`imap.login(socket)` + +#### Parameters +- `socket`: IMAP TCP socket object created using `net.createConnection` + +#### Returns +`nil` + +## imap.get_most_recent_num() +Function to check the most recent email number. Should only be called after `examine` function. + +#### Syntax +`imap.get_most_recent_num()` + +#### Parameters +None + +#### Returns +The most recent email number. + +## imap.examine() +IMAP examines the given mailbox/folder. Sends the IMAP EXAMINE command. + +#### Syntax +`imap.examine(socket, mailbox)` + +#### Parameters +- `socket`: IMAP TCP socket object created using `net.createConnection` +- `mailbox`: E-mail folder name to examine like example `"INBOX"` + +#### Returns +`nil` + +## imap.get_header() +Function that gets the last fetched header field. + +#### Syntax +`imap.get_header()` + +#### Parameters +None + +#### Returns +The last fetched header field. + +## imap.fetch_header() +Fetches an e-mails header field e.g. SUBJECT, FROM, DATE. + +#### Syntax +`imap.fetch_header(socket, msg_number, field)` + +#### Parameters +- `socket`: IMAP TCP socket object created using `net.createConnection` +- `msg_number`: The email number to read e.g. 1 will read fetch the latest/newest email +- `field`: A header field such as SUBJECT, FROM, or DATE +#### Returns +`nil` + +## imap.get_body() +Function to get the last email read's body. + +#### Syntax +`imap.get_body()` + +#### Parameters +None + +#### Returns +The last email read's body. + +## imap.fetch_body_plain_text() +Sends the IMAP command to fetch a plain text version of the email's body. + +#### Syntax +`imap.fetch_body_plain_text(socket, msg_number)` + +#### Parameters +- `socket`: IMAP TCP socket object created using `net.createConnection` +- `msg_number`: The email number to obtain e.g. 1 will obtain the latest email. + +#### Returns +`nil` + +## imap.logout() +Sends the IMAP command to logout of the email session. + +#### Syntax +`imap.logout(socket)` + +#### Parameters +- `socket`: IMAP TCP socket object created using `net.createConnection` + +#### Returns +`nil` + +#### Example +Example use of `imap` module can be found in [read_email_imap.lua](../../../lua_examples/email/read_email_imap.lua) file. \ No newline at end of file diff --git a/docs/en/lua-modules/lm92.md b/docs/en/lua-modules/lm92.md new file mode 100644 index 00000000..f101184d --- /dev/null +++ b/docs/en/lua-modules/lm92.md @@ -0,0 +1,207 @@ +# LM92 Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-05-17 | [Levente Tamas](https://github.com/elgarbe) | [Levente Tamas](https://github.com/elgarbe) | [lm92.lua](../../../lua_modules/lm92/lm92.lua) | + +This Lua module provides access to [LM92](http://www.ti.com/lit/ds/symlink/lm92.pdf) I²C ±0.33C 12bit+sign temperature sensor. + +!!! note + This module requires `i2c` C module built into firmware. + +### Require +```lua +lm92 = require("lm92") +``` + +### Release +```lua +lm92 = nil +package.loaded["lm92"] = nil +``` + +## lm92.setup() +Function used to setup the address for lm92. + +#### Syntax +`lm92.setup(address)` + +#### Parameters +- `address`: I²C address used by LM92. Depends on the connection of `A0` and `A1` pins. Can be either `0x48`, `0x49`, `0x4a` or `0x4b` according to page 9 of [LM92 datasheet](http://www.ti.com/lit/ds/symlink/lm92.pdf) + +#### Returns +`nil` + +#### Example +```lua +lm92 = require("lm92") +sda = 3 -- GPIO 0 +scl = 4 -- GPIO 2 +addr = 0x48 +i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once +lm92.setup(addr) +``` + +## lm92.getTemperature() +Returns the temperature register's content. + +#### Syntax +`lm92.getTemperature()` + +#### Parameters +None + +#### Returns +Temperature in degree Celsius. + +## lm92.shutdown() +Makes the chip enter the low power shutdown mode. + +#### Syntax +`lm92.shutdown()` + +#### Parameters +None + +#### Returns +`nil` + +## lm92.wakeup() +Makes the chip exit the low power shutdown mode. + +#### Syntax +`lm92.wakeup()` + +#### Parameters +None + +#### Returns +`nil` + +## lm92.setThyst() + +Set hysteresis Temperature. + +#### Syntax +`lm92.setThyst(htemp)` + +#### Parameters +- `htemp`: Hysteresis temperature from 130 to -55 in ºC + +#### Returns +`nil` + +## lm92.setTcrit() +Set Critical Temperature. + +#### Syntax +`lm92.setTcrit(ctemp)` + +#### Parameters +`ctemp`: Critical temperature from 130 to -55 in ºC + +#### Returns +`nil` + +## lm92.setTlow() +Set Low Window Temperature. + +#### Syntax +`lm92.setTlow(lwtemp)` + +####Parameters +- `lwtemp`: Low window temperature from 130 to -55 in ºC + +#### Returns +`nil` + +## lm92.setThigh() +Set High Window Temperature. + +#### Syntax +`lm92.setThigh(hwtemp)` + +#### Parameters +- `hwtemp`: High window temperature from 130 to -55 in ºC + +#### Returns +`nil` + +## lm92.getThyst() +Get hysteresis Temperature. + +#### Syntax +`lm92.getThyst()` + +#### Parameters +None + +#### Returns +Hysteresis Temperature in degree Celsius. + +## lm92.getTcrit() +Get Critical Temperature. + +#### Syntax +`lm92.getTcrit()` + +#### Parameters +None + +#### Returns +Critical Temperature in degree Celsius. + +## lm92.getTlow() +Get Low Window Temperature. + +#### Syntax +`lm92.getTlow()` + +#### Parameters +None + +#### Returns +Low Window Temperature in degree Celsius. + +## lm92.getThigh() +Get High Window Temperature. + +#### Syntax +`lm92.getThigh()` + +#### Parameters +None + +#### Returns +High Window Temperature in degree Celsius. + +#### Example +```lua +--node.compile("lm92.lua") +lm92 = require("lm92") +sda = 3 -- GPIO 0 +scl = 4 -- GPIO 2 +addr = 0x48 +i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once +lm92.setup(addr) + +t = lm92.getTemperature() +print("Got temperature: "..t.." C") + +--Seting comparison temperatures +lm92.setThyst(3) +lm92.setTcrit(40.75) +lm92.setTlow(28.5) +lm92.setThigh(31.625) + +t = lm92.getThyst() +print("Got hyster: "..t.." C") +t = lm92.getTcrit() +print("Got Crit: "..t.." C") +t = lm92.getTlow() +print("Got Low: "..t.." C") +t = lm92.getThigh() +print("Got High: "..t.." C") +``` + +#### TODO: +- add full support of the features, including interrupt and critical alert support \ No newline at end of file diff --git a/docs/en/lua-modules/mcp23008.md b/docs/en/lua-modules/mcp23008.md new file mode 100644 index 00000000..891f3247 --- /dev/null +++ b/docs/en/lua-modules/mcp23008.md @@ -0,0 +1,113 @@ +# MCP23008 Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-03-02 | [AllAboutEE](https://github.com/AllAboutEE) | [AllAboutEE](https://github.com/AllAboutEE) | [mcp23008.lua](../../../lua_modules/mcp23008/mcp23008.lua) | + +This Lua module provides access to [MCP23008](http://ww1.microchip.com/downloads/en/DeviceDoc/21919e.pdf) I²C I/O Expander. + +!!! note + This module requires `i2c` C module built into firmware. + +### Require +```lua +mcp32008 = require("mcp32008") +``` + +### Release +```lua +mcp32008 = nil +package.loaded["mcp32008"] = nil +``` + +## mcp32008.begin() +Sets the MCP23008 device address's last three bits. + +!!! note + The address is defined as binary `0100[A2][A1][A0]` where `A2`, `A1`, and `A0` are defined by the connection of the pins, e.g. if the pins are connected all to GND then the parameter address will need to be `0x0`. + +#### Syntax +`mcp23008.begin(address, pinSDA, pinSCL, speed)` + +#### Parameters +- `address`: The 3 least significant bits (LSB) of the address +- `pinSDA`: The pin to use for SDA +- `pinSCL`: The pin to use for SCL +- `speed`: The speed of the I2C signal + +#### Returns +`nil` + +## mcp23008.writeGPIO() +Writes a byte of data to the GPIO register. + +#### Syntax +`mcp23008.writeGPIO(dataByte)` + +#### Parameters +- `dataByte`: The byte of data to write + +#### Returns +`nil` + +## mcp23008.readGPIO() +Reads a byte of data from the GPIO register + +#### Syntax +`mcp23008.readGPIO()` + +#### Parameters +None + +#### Returns +One byte of data + +## mcp23008.writeIODIR() +Writes one byte of data to the IODIR register. + +#### Syntax +`mcp23008.writeIODIR(dataByte)` + +#### Parameters +- `dataByte`: The byte of data to write + +#### Returns +`nil` + +## mcp23008.readIODIR() +Reads a byte from the IODIR register + +#### Syntax +`mcp23008.readIODIR()` + +#### Parameters +None + +#### Returns +The byte of data in IODIR + +## mcp23008.writeGPPU() +Writes a byte of data to the GPPU (Pull-UP resistors register) + +#### Syntax +`mcp23008.writeIODIR(dataByte)` + +#### Parameters +- `dataByte`: the value to write to the GPPU register. Each bit in this byte is assigned to an individual GPIO pin + +#### Returns +`nil` + +## mcp23008.readGPPU() +Reads the GPPU (Pull-UP resistors register) byte + +#### Syntax +`mcp23008.readGPPU()` + +#### Parameters +None + +#### Returns +The GPPU byte i.e. state of all internal pull-up resistors + +#### Notes +Other examples of using this module can be found in [mcp23008_buttons.lua](../../../lua_examples/mcp23008/mcp23008_buttons.lua) and [mcp23008_leds.lua](../../../lua_examples/mcp23008/mcp23008_leds.lua) files. \ No newline at end of file diff --git a/docs/en/lua-modules/redis.md b/docs/en/lua-modules/redis.md new file mode 100644 index 00000000..e9d58666 --- /dev/null +++ b/docs/en/lua-modules/redis.md @@ -0,0 +1,86 @@ +# Redis Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-02-06 | [Vladimir Dronnikov](https://github.com/dvv) | [Vladimir Dronnikov](https://github.com/dvv) | [redis.lua](../../../lua_modules/redis/redis.lua) | + +This Lua module provides a simple implementation of a [Redis](https://redis.io/) client. + +### Require +```lua +redis = dofile("redis.lua") +``` + +### Release +```lua +redis = nil +``` + +## redis.connect() +Function used to connect to Redis server. + +#### Syntax +`redis.connect(host, [port])` + +#### Parameters +- `host`: Redis host name or address +- `port`: Redis database port. Default value is 6379. + +#### Returns +Object with rest of the functions. + +## subscribe() +Subscribe to a Redis channel. + +#### Syntax +`redis:subscribe(channel, handler)` + +#### Parameters +- `channel`: Channel name +- `handler`: Handler function that will be called on new message in subscribed channel + +#### Returns +`nil` + +## redis:publish() +Publish a message to a Redis channel. + +#### Syntax +`redis:publish(channel, message)` + +#### Parameters +- `channel`: Channel name +- `message`: Message to publish + +#### Returns +`nil` + +## redis:unsubscribe() +Unsubscribes from a channel. + +#### Syntax +`redis:unsubscribe(channel)` + +#### Parameters +- `channel`: Channel name to unsubscribe from + +#### Returns +`nil` + +#### redis:close() +Function to close connection to Redis server. + +#### Syntax +`redis:close()` + +#### Parameters +None + +#### Returns +`nil` + +#### Example +```lua +local redis = dofile("redis.lua").connect(host, port) +redis:publish("chan1", foo") +redis:subscribe("chan1", function(channel, msg) print(channel, msg) end) +``` \ No newline at end of file diff --git a/docs/en/lua-modules/yeelink.md b/docs/en/lua-modules/yeelink.md new file mode 100644 index 00000000..8db53ce8 --- /dev/null +++ b/docs/en/lua-modules/yeelink.md @@ -0,0 +1,58 @@ +# Yeelink Module +| Since | Origin / Contributor | Maintainer | Source | +| :----- | :-------------------- | :---------- | :------ | +| 2015-04-14 | [Martin Han](https://github.com/MarsTechHAN) | [Martin Han](https://github.com/MarsTechHAN) | [yeelink_lib.lua](../../../lua_modules/yeelink/yeelink_lib.lua) | + +This Lua module provides a simple implementation of an [Yeelink](http://www.yeelink.net/) client. + +### Require +```lua +yeelink = require("yeelink_lib") +``` + +### Release +```lua +yeelink = nil +package.loaded["yeelink_lib"] = nil +``` + +## yeelink.init() +Initializes Yeelink client. + +#### Syntax +`yeelink.init(device, sensor, apikey)` + +#### Parameters +- `device`: device number +- `sensor`: sensor number +- `apikey`: Yeelink API key string + +#### Returns +IP address of `api.yeelink.net`, if not obtained then `false` + +## yeelink.getDNS() +Function to check DNS resolution of `api.yeelink.net` status. + +#### Syntax +`yeelink.getDNS()` + +#### Parameters +None + +#### Returns +IP address of `api.yeelink.net` or `nil` when name resolution failed. + +## yeelink.update() +Send data to Yeelink Sever. + +#### Syntax +`yeelink.update(datapoint)` + +#### Parameters +- `datapoint`: Data to send to Yeelink API + +#### Returns +`nil` + +#### Notes +Example of using this module can be found in [Example_for_Yeelink_Lib.lua](../../../lua_modules/yeelink/Example_for_Yeelink_Lib.lua) file. \ No newline at end of file diff --git a/lua_modules/bh1750/README.md b/lua_modules/bh1750/README.md new file mode 100644 index 00000000..57cf1106 --- /dev/null +++ b/lua_modules/bh1750/README.md @@ -0,0 +1,3 @@ +# BH1750 Module + +Documentation for this Lua module is available in the [bh1750.md](../../docs/en/lua-modules/bh1750.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/ds18b20/README.md b/lua_modules/ds18b20/README.md index 6e574846..d78013d2 100644 --- a/lua_modules/ds18b20/README.md +++ b/lua_modules/ds18b20/README.md @@ -1,67 +1,3 @@ # DS18B20 Module -This is a Lua module for the DS18B20 1-Wire digital thermometer. - -## Require -```lua -ds18b20 = require("ds18b20") -``` -## Release -```lua -ds18b20 = nil -package.loaded["ds18b20"]=nil -``` - -# Methods - -## read_temp() -Scans the bus for DS18B20 sensors (optional), starts a readout (conversion) for all sensors and calls a callback function when all temperatures are available. Powered sensors are read at once first. Parasite-powered sensors are read one by one. The first parasite-powered sensor is read together with all powered sensors. - -The module requires `ow` module. - -#### Syntax -`read_temp(callback, pin, unit, force_search, save_search)` - -#### Parameters -- `callback` function that receives all results when all conversions finish. The callback function has one parameter - an array addressed by sensor addresses and a value of the temperature (string for integer version). -- `pin` pin of the one-wire bus. If nil, GPIO0 (3) is used. -- `unit` unit can be Celsius ("C" or ds18b20.C), Kelvin ("K" or ds18b20.K) or Fahrenheit ("F" or ds18b20.F). If not specified (nil) latest used unit is used. -- `force_search` if not nil a bus search for devices is performed before readout. If nil the existing list of sensors in memory is used. If the bus has not been searched yet the search performed as well. -- `save_search` if not nil found sensors are saved to the file `ds18b20_save.lc`. When `read_temp` is called, list of sensors in memory is empty and file `ds18b20_save.lc` is present then sensor addresses are loaded from file - usefull when running from batteries & deepsleep - immediate readout is performed (no bus scan). - -#### Returns -nil - -#### Example -```lua -local t = require("ds18b20") -local pin = 3 -- gpio0 = 3, gpio2 = 4 - -local function readout(temp) - if t.sens then - print("Total number of DS18B20 sensors: ".. #t.sens) - for i, s in ipairs(t.sens) do - print(string.format(" sensor #%d address: %s%s", i, ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(s:byte(1,8)), s:byte(9) == 1 and " (parasite)" or "")) - end - end - for addr, temp in pairs(temp) do - print(string.format("Sensor %s: %s °C", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X'):format(addr:byte(1,8)), temp)) - end - - -- Module can be released when it is no longer needed - t = nil - package.loaded["ds18b20"]=nil -end - -t:read_temp(readout, pin, t.C)``` - -## enable_debug() -Enables debug output of the module. - -# Properties - -## sens -A table with sensors present on the bus. It includes its address (8 bytes) and information whether the sensor is parasite-powered (9-th byte, 0 or 1). - -## temp -A table with readout values (also passed as a parameter to callback function). It is addressed by sensor addresses. \ No newline at end of file +Documentation for this Lua module is available in the [ds18b20.md](../../docs/en/lua-modules/ds18b20.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/ds3231/README.md b/lua_modules/ds3231/README.md new file mode 100644 index 00000000..716d7426 --- /dev/null +++ b/lua_modules/ds3231/README.md @@ -0,0 +1,3 @@ +# DS3231 Module + +Documentation for this Lua module is available in the [ds3231.md](../../docs/en/lua-modules/ds3231.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/email/README.md b/lua_modules/email/README.md new file mode 100644 index 00000000..0dc730ae --- /dev/null +++ b/lua_modules/email/README.md @@ -0,0 +1,3 @@ +# IMAP Module + +Documentation for this Lua module is available in the [imap.md](../../docs/en/lua-modules/imap.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/ftp/README.md b/lua_modules/ftp/README.md index 818c7828..9b952a3e 100644 --- a/lua_modules/ftp/README.md +++ b/lua_modules/ftp/README.md @@ -1,107 +1,3 @@ -# FTPServer Module +# FTP Server Module -This Lua module implementation provides a basic FTP server for the ESP8266. -It has been tested against a number of Table, Windows and Linux FTP clients -and browsers. - -It provides a limited subset of FTP commands that enable such clients to -tranfer files to and from the ESP's file system. Only one server can be -started at any one time, but this server can support multiple connected -sessions (some FTP clients use multiple sessions and so require this -feature). - -### Limitations - -- FTP over SSH or TLS is not currently supported so transfer is unencrypted. -- The client session , must, authentical against a single user/password. -- Only the SPIFFS filesystem is currently supported, so changing directories is treated as a NO-OP. -- This implementation has been optimised for running in LFS. -- Only PASV mode is supported as the `net` module does not allow static allocation of outbound sockets. - -### Notes - -The coding style adopted here is more similar to best practice for normal (PC) -module implementations, as using LFS permits a bias towards clarity of coding -over brevity. It includes extra logic to handle some of the edge case issues more -robustly. It also uses a standard forward reference coding pattern to allow the -code to be laid out in main routine, subroutine order. - -Most FTP clients are capable of higher transfer rates than the ESP SPIFFS write -throughput, so the server uses TCP flow control to limit upload rates to the -ESP. - -aThe following FTP commands are supported: - -- with no parameter: CDUP, NOOP, PASV, PWD, QUIT, SYST -- with one parameter: CWD, DELE, MODE, PASS, PORT, RNFR, RNTO, SIZE, TYPE, USER -- xfer commands: LIST, NLST, RETR, STOR - -This implementation is by Terry Ellison, but I wish to acknowledge the inspration -and hard work by [Neronix](https://github.com/NeiroNx) that made this possible. - -## createServer() - -Create the FTP server on the standard ports 20 and 21. The global variable `FTP` -is set to the server object. - -#### Syntax -`FTP.createServer(user, pass[, dbgFlag])` - -#### Parameters - -- `user` - Username for access to the server -- `pass` - Password for access to the server -- `dbgFlag` - optional flag. If set true then internal debug output is printed - -#### Returns -- N/A - -#### Example - -```Lua -require("ftpserver").createServer('user', 'password') -``` - -## open() - -Wrapper to createServer() which also connects to the WiFi channel. - -#### Syntax - -`FTP.open(user, pass, ssid, wifipwd, dbgFlag)` - -#### Parameters - -- `user` - Username for access to the server -- `pass` - Password for access to the server -- `ssid` - SSID for Wifi service -- `wifipwd` - password for Wifi service -- `dbgFlag` - optional flag. If set true then internal debug output is printed - -#### Returns -- N/A - -#### Example - -```Lua -require("ftpserver").open('myWifi', 'wifiPassword', 'user', 'password') -``` - -## close() - -Close down server including any sockets and return all resouces to Lua. Note that -this include removing the FTP global variable and package references. - -#### Syntax -`FTP.close()` - -#### Parameters -- none - -#### Returns -- nil - -#### Example -```Lua -FTP.close() -``` +Documentation for this Lua module is available in the [ftpserver.md](../../docs/en/lua-modules/ftpserver.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/hdc1000/README.md b/lua_modules/hdc1000/README.md index d8085ead..1b8d7707 100644 --- a/lua_modules/hdc1000/README.md +++ b/lua_modules/hdc1000/README.md @@ -1,46 +1,3 @@ -HDC1000 NodeMCU module -======================= +# HDC1000 Module -Here's my NodeMCU module for the TI HDC1000 temperature and humidity sensor. It should work with the HDC1008 too but I haven't tested it. - -### Setup your sensor: -First, require it: - -`HDC1000 = require("HDC1000")` - -Then, initialize it: - -```lua -i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once -HDC1000.setup(drdyn) -``` - -If you don't want to use the DRDYn pin, set it to false: a 20ms delay will be automatically set after each read request. - -`HDC1000.init(sda, scl, false)` - -Configure it: - -`HDC1000.config()` - -Default options set the address to 0x40 and enable both temperature and humidity readings at 14-bit resolution, with the integrated heater on. You can change them by initializing your sensor like this: - -`HDC1000.config(address, resolution, heater);` - -"resolution" can be set to 14 bits for both temperature and humidity (0x00 - default) 11 bits for temperature (0x40), 11 bits for humidity (0x01), 8 bits for humidity (0x20) -"heater" can be set to ON (0x20 - default) or OFF (0x00) - -### Read some values -You can read temperature and humidity by using the following commands: - -`temperature = HDC1000.getTemp()` in Celsius degrees. - -`humidity = HDC1000.getHumi()` in % - -### Check your battery - -The following code returns true if the battery voltage is <2.8V, false otherwise. - -`isDead = HDC1000.batteryDead();` - -Happy making! Also, check out my Breakout Board and Arduino library for this chip: http://b.truzzi.me/hdc1000-temperature-and-humidity-sensor-breakout-with-arduino-library/. +Documentation for this Lua module is available in the [hdc1000.md](../../docs/en/lua-modules/hdc1000.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/http/README.md b/lua_modules/http/README.md new file mode 100644 index 00000000..f103b496 --- /dev/null +++ b/lua_modules/http/README.md @@ -0,0 +1,3 @@ +# HTTP Server Module + +Documentation for this Lua module is available in the [http.md](../../docs/en/lua-modules/http.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/lm92/README.md b/lua_modules/lm92/README.md index e2e6b2fb..1827228c 100644 --- a/lua_modules/lm92/README.md +++ b/lua_modules/lm92/README.md @@ -1,277 +1,3 @@ -# LM92 module -This module adds basic support for the LM92 +-0.33C 12bit+sign temperature sensor. More details in the [datasheet](http://www.ti.com/lit/ds/symlink/lm92.pdf). -Works: -- 06/01/2016: Add get/set comparison registers. Thyst, Tlow, Thigh and Tcrit -- getting the temperature -- entering the chip's to shutdown mode (350uA -> 5uA power consumption) -- waking up the chip from shutdown +# HTTP Server Module -## Require -```lua -LM92 = require("lm92") -``` -## Release -```lua -LM92 = nil -package.loaded["lm92"]=nil -``` - -## setup() -#### Description -Setting the address for lm92. - -#### Syntax -setup(sda, scl, address) - -#### Parameters -address: 0x48~0x4b, i2c address (depends on tha A0~A1 pins) -#### Returns -nil - -#### Example -```lua -LM92 = require("lm92") -gpio0 = 3 -gpio2 = 4 -sda = gpio0 -scl = gpio2 -addr = 0x48 -i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once -LM92.setup(addr) -``` -## getTemperature() -#### Description -Returns the temperature register's content. - -#### Syntax -getTemperature() - -#### Parameters -- - -#### Returns -Temperature in degree Celsius. - -#### Example -```lua -t = LM92.getTemperature() -print("Got temperature: "..t.." C") -``` - -## wakeup() -#### Description -Makes the chip exit the low power shutdown mode. - -#### Syntax -wakeup() - -#### Parameters -- - -#### Returns -- - -#### Example -```lua -LM92.wakeup() -tmr.delay( 1 * 1000 * 1000 ) -``` - -## shutdown() -#### Description -Makes the chip enter the low power shutdown mode. - -#### Syntax -shutdown() - -#### Parameters -- - -#### Returns -- - -#### Example -```lua -LM92.shutdown() -``` - -## setThyst() -#### Description -Set hysteresis Temperature. - -#### Syntax -setThyst(data_wr) - -#### Parameters -data_wr: 130~-55 ºC, hysteresis Temperature - -#### Returns -nil - -#### Example -```lua -LM92.setThyst(3) -``` - -## setTcrit() -#### Description -Set Critical Temperature. - -#### Syntax -setTcrit(data_wr) - -#### Parameters -data_wr: 130~-55 ºC, Critical Temperature - -#### Returns -nil - -#### Example -```lua -LM92.setTcrit(100.625) -``` - -## setTlow() -#### Description -Set Low Window Temperature. - -#### Syntax -setTlow(data_wr) - -####Parameters -data_wr: 130~-55 ºC, Low Window Temperature - -#### Returns -nil - -#### Example -```lua -LM92.setTlow(32.25) -``` -## setThigh() -####Description -Set High Window Temperature. - -#### Syntax -setThigh(data_wr) - -#### Parameters -data_wr: 130~-55 ºC, High Window Temperature - -#### Returns -nil - -####Example -```lua -LM92.setThigh(27.5) -``` - -## getThyst() -#### Description -Get hysteresis Temperature. - -#### Syntax -getThyst() - -#### Parameters --- - -#### Returns -Hysteresis Temperature in degree Celsius. - -#### Example -```lua -t = LM92.getThyst() -print("Got hysteresis temperature: "..t.." C") -``` - -## getTcrit() -#### Description -Get Critical Temperature. - -#### Syntax -getTcrit() - -#### Parameters --- - -#### Returns -Critical Temperature in degree Celsius. - -#### Example -```lua -t = LM92.getTcrit() -print("Got Critical temperature: "..t.." C") -``` - -## getTlow() -#### Description -Get Low Window Temperature. - -#### Syntax -getTlow() - -#### Parameters --- - -#### Returns -Low Window Temperature in degree Celsius. - -#### Example -```lua -t = LM92.getTlow() -print("Got Low Window temperature: "..t.." C") -``` - -## getThigh() -#### Description -Get High Window Temperature. - -#### Syntax -getThigh() - -#### Parameters --- - -#### Returns -High Window Temperature in degree Celsius. - -#### Example -```lua -t = LM92.getThigh() -print("Got High Window temperature: "..t.." C") -``` - -## Full example -```lua ---node.compile("lm92.lua") -LM92 = require("lm92") -gpio0 = 3 -gpio2 = 4 -sda = gpio0 -scl = gpio2 -addr = 0x48 -i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once -LM92.setup(addr) - -t = LM92.getTemperature() -print("Got temperature: "..t.." C") - ---Seting comparison temperatures -LM92.setThyst(3) -LM92.setTcrit(40.75) -LM92.setTlow(28.5) -LM92.setThigh(31.625) - -t = LM92.getThyst() -print("Got hyster: "..t.." C") -t = LM92.getTcrit() -print("Got Crit: "..t.." C") -t = LM92.getTlow() -print("Got Low: "..t.." C") -t = LM92.getThigh() -print("Got High: "..t.." C") -``` - -#### TODO: -- add full support of the features, including interrupt and critical alert support +Documentation for this Lua module is available in the [lm92.md](../../docs/en/lua-modules/lm92.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/mcp23008/README.md b/lua_modules/mcp23008/README.md new file mode 100644 index 00000000..303429a2 --- /dev/null +++ b/lua_modules/mcp23008/README.md @@ -0,0 +1,3 @@ +# MCP23008 Module + +Documentation for this Lua module is available in the [mcp23008.md](../../docs/en/lua-modules/mcp23008.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/redis/README.md b/lua_modules/redis/README.md new file mode 100644 index 00000000..8d51fe63 --- /dev/null +++ b/lua_modules/redis/README.md @@ -0,0 +1,3 @@ +# Redis Module + +Documentation for this Lua module is available in the [redis.md](../../docs/en/lua-modules/redis.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/lua_modules/yeelink/README.md b/lua_modules/yeelink/README.md new file mode 100644 index 00000000..a48dccd1 --- /dev/null +++ b/lua_modules/yeelink/README.md @@ -0,0 +1,3 @@ +# Yeelink Module + +Documentation for this Lua module is available in the [yeelink.md](../../docs/en/lua-modules/yeelink.md) file and in the [Official NodeMCU Documentation](https://nodemcu.readthedocs.io/) in `Lua Modules` section. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index f4766cac..253281ed 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -4,7 +4,7 @@ repo_url: https://github.com/nodemcu/nodemcu-firmware/ theme: name: "readthedocs" -strict: true +strict: false #Allows to build and test documentation in local enviroment where some links are unreachable markdown_extensions: #http://pythonhosted.org/Markdown/extensions/admonition.html @@ -12,7 +12,7 @@ markdown_extensions: - toc: permalink: True -#requird due to https://github.com/rtfd/readthedocs.org/issues/1313 +#required due to https://github.com/rtfd/readthedocs.org/issues/1313 #see http://mkdocs.readthedocs.org/en/latest/user-guide/styling-your-docs/#customising-a-theme extra_css: - css/extra.css @@ -37,10 +37,21 @@ pages: - Internal filesystem: 'en/spiffs.md' - Lua Compact Debug (LCD): 'en/lcd.md' - Lua Flash Store (LFS): 'en/lfs.md' -- Modules: +- Lua Modules: + - 'bh1750': 'en/lua-modules/bh1750.md' + - 'ds18b20': 'en/lua-modules/ds18b20.md' + - 'ds3231': 'en/lua-modules/ds3231.md' + - 'ftpserver': 'en/lua-modules/ftpserver.md' + - 'hdc1000': 'en/lua-modules/hdc1000.md' + - 'imap': 'en/lua-modules/imap.md' + - 'lm92': 'en/lua-modules/lm92.md' + - 'mcp23008': 'en/lua-modules/mcp23008.md' + - 'redis': 'en/lua-modules/redis.md' + - 'yeelink': 'en/lua-modules/yeelink.md' +- C Modules: - 'adc': 'en/modules/adc.md' - - 'ads1115' : 'en/modules/ads1115.md' - - 'adxl345': 'en/modules/adxl345.md' + - 'ads1115': 'en/modules/ads1115.md' + - 'adxl345' : 'en/modules/adxl345.md' - 'am2320': 'en/modules/am2320.md' - 'apa102': 'en/modules/apa102.md' - 'bit': 'en/modules/bit.md' @@ -105,4 +116,4 @@ pages: - 'ws2801': 'en/modules/ws2801.md' - 'ws2812': 'en/modules/ws2812.md' - 'ws2812-effects': 'en/modules/ws2812-effects.md' - - 'xpt2046': 'en/modules/xpt2046.md' + - 'xpt2046': 'en/modules/xpt2046.md' \ No newline at end of file