Search code examples
luaesp8266uartnodemcu

NodeMCU cannot use uart 1 - Lua


i'm using NodeMCU v2 devkit with ESP8266 module. I'm programming in Lua, and i want to use alternative pins to transmit data through UART. I'm aware that UART 1 pins can only transmit, not receive data. So in my code i'm trying to change pins assignment using

uart.alt(1) 

but i got an error

attempt to call field 'alt' (a nil value)

No matter what i do, error still apears until i got this line in my code. I also tried to use it with uart.setup with first parameter 1 to define uart 1 but then another error appears:

uart.setup(1, 9600, 8, 0, 1, 1) 

error:

stdin:1 uart 1 does not exist

I'm asking for help because maybe i'm doing something wrong and the solution is easy or maybe there is a problem with uart 1 in Lua. I saw many topics but advices were only connected with firmware. I tried many versions and problem is still there.

details from documentation here : http://nodemcu.readthedocs.io/en/master/en/modules/uart/


Solution

  • uart.alt was added to the firmware on Nov 28, 2015.

    So, with near certainty you're using a firmware from before that. I suggest you build and flash a recent NodeMCU binary, one the matches what you find in the documentation.