本文介绍了GSM模块与NodeMCU的接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了这段代码来连接gsm模块,有人可以检查代码并给我一些建议吗?

I wrote this code to interface the gsm module, can anyone check the code and give me some propositions ?

hex1= '0x1A';
function delay_s(delay)
delay = delay or 1
local time_to = os.time() + delay
while os.time() < time_to do end
end
uart.alt(1);
uart.setup(0, 9600, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1)
uart.write(0,"AT+IPR=9600\n")
for j = 1, 10 do
uart.write(0, "AT\n")
end
delay_s(1000)
uart.write(0, "AT\n")
delay_s(1000)
uart.write(0, 'AT+CSCS="GSM"\n')
delay_s(1000)
uart.write(0, 'AT+CMGF=1\n')
delay_s(1000)
uart.write(0, 'AT+CMGS="+21654102832"\n')
delay_s(1000)
uart.write(0, " Salut tout le mond !!!\n")
delay_s(1000)
uart.write(0, hex1)
delay_s(1000)

推荐答案

uart.alt(x);

0 - standard pins
1 - alternate the pins

您没有指定要用于通信的引脚,或者将uart.alt(0);用作标准引脚

You havent specify which pins you are gonna use for the communication, or else use uart.alt(0); for standard pins

这篇关于GSM模块与NodeMCU的接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 16:22