Chat about current Lua tools and IDEs

User avatar
By engineer-of-stuff
#82377 I am unable to read the serial pins in the NodeMCU Lua environment. I have only been able to read the USB serial port.

I have connected a serial adapter to the rx, tx, and g pins.

I have tried this code:
Code: Select alluart.on("data","\n",function(data) print("receive from uart:", data) end, 0)


I enter text in the ESplorer console and it does read that. It doesn't read anything I send over a serial adapter plugged into the rx/tx/g pins.

Code: Select alluart.write(0, "hello")


I disconnected the USB cable and powered it with the serial adapter. Nothing was sent using this code. I tried `uart.write(0,` and `uart.write(1,`.


How do I read the pin serial ports instead of the usb serial port?
User avatar
By schufti
#82380 that is one of the major problems of nodemcu boards.
Depending on the used usb-serial chip and the actual design you won't ever be able to use rx/tx because the chip will allways interfere (not be in standby or similar).
possible solution: remap usart to alternativ pins (gpio13/15).
User avatar
By Bonzo
#82382 I had a similar problem with a Nodemcu but using the Arduino IDE and ended up using the Serial.swap() function that worked. Some information on the serial here: http://arduino.esp8266.com/Arduino/vers ... rence.html

There is also the SoftwareSerial() function.

From memory it was only a problem when the USB was plugged in but that is not very useful for development!

Might be worth swapping from Lau to Arduino although you might loose some function that is Lau that is not in the Arduino IDE