我希望在esp8266上使用alt uart并尝试以下方法:
uart.alt(1)
uart.setup(0, 19200, 8, uart.PARITY_NONE, uart.STOPBITS_1, 0)
不幸的是,它给了我一个错误"尝试拨打电话' alt' (零值)"。为什么?我认为在这种情况下我将uart设置为alt(1)。不知道为什么它的价值为零。有什么意见吗?
答案 0 :(得分:2)
“尝试调用字段'alt'(零值)”
此错误表示uart
是表,但字段 alt
为nil
。由于您无法像函数一样调用nil
,因此会出现此错误。该错误与您提供的参数无关。
uart.alt
在NodeMCU环境中可用,documentation和implementation表示。
您是否曾在程序或固件编译中做过任何事情,导致alt
字段变为nil
?
答案 1 :(得分:0)
可能是UART模块在某种程度上缺失,但默认情况下它在https://nodemcu-build.com/
中为ON当您在启动时从ESPlorer连接到您的主板时,您应该会看到有关固件及其模块的初步信息。 喜欢:
NodeMCU custom build by frightanic.com
branch: master
commit: b96e31477ca1e207aa1c0cdc334539b1f7d3a7f0
SSL: true
modules: adc,bit,bme280,cjson,crypto,encoder,file,gpio,http,i2c,mdns,mqtt,net,node,pwm,sntp,spi,tmr,uart,websocket,wifi,ws2812,tls
您是否在启动控制台中看到了UART?