Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #2461

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Make sure you read and understand http://nodemcu.readthedocs.io/en/dev/en/support/.
Use one of the two templates below and delete the rest.
Use one of the two templates below and **DELETE THE REST**.

8<------------------------ BUG REPORT -----------------------------------------
### Expected behavior
Expand Down
20 changes: 20 additions & 0 deletions docs/en/modules/io.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
If you came here looking for the Lua `io` module that doesn't exist in NodeMCU, read on.

The only mention of the `io` module in NodeMCU is in the [NodeMCU Developer FAQ](https://nodemcu.readthedocs.io/en/master/en/lua-developer-faq/), where it says
"For example, the standard `io` and `os` libraries don't work, but have been largely replaced by the NodeMCU `node` and `file` libraries."

Unfortunately, if you are new to NodeMCU and Lua, there is little to go on to understand how to proceed.

If you have read the Lua documentation on [The Simple I/O Model](https://www.lua.org/pil/21.1.html),
you might be looking for io.write as a way to output text similar to print() but with more control.
With NodeMCU, the `file` library is suggested as a replacement, but it will not write to stdout like io.write. `file.write(string)` will not work because there is no file open.

It is not clear how to proceed without the `io` module. There is nothing analagous to stdout to open.

The solution is to use the uart module.

The Lua example `io.write("hello", "Lua")` would be written `uart.write(0,"hello", "Lua")`

Note that the UART ID value of 0 has to be added. UART 0 is the same one the the print() function uses.