esp32 向蜂窝/gnss 模块发送的测试 AT 命令没有反馈 [英] No feedback from test AT command sent by esp32 to cellular/gnss module

查看:85
本文介绍了esp32 向蜂窝/gnss 模块发送的测试 AT 命令没有反馈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试发送测试 AT 命令以确保我的 esp32 与蜂窝模块的连接正常工作.蜂窝模块为移远 BG95,ESP32 为 ESP-WROOM-32UE (

C++ 代码正在通过 Arduino IDE 上传.然后 ESP 分别使用其 RXD 和 TXD 引脚 GPIO 16 和 17 进行 UART 连接.代码如下:

#include 诠释绿色力量 = 32;国际领导= 33;无效设置(){Serial.begin(115200);//打开串口通信并等待端口打开:Serial2.begin(115200,SERIAL_8N1,16,17);pinMode(led,输出);//用于验证电路板的电源pinMode(绿色电源,输出);//用于允许辅助过程的电源数字写入(绿色电源,高);//允许给辅助设备供电数字写入(LED,高);//给验证电路加电延迟(1000);}无效循环(){Serial.println(开始");Serial2.write("AT\r");while (!Serial2.available()) 继续;而(Serial2.available()){int g = Serial2.read();串行写入(g);Serial.println(g);}延迟(1000);}

已编辑代码以解决评论/答案中的一些问题.这是在测试 AT 命令后添加延迟:Serial2.write("AT\r";); 并在末尾添加回车符.当我上传这个程序并检查串行监视器时,我看到开始"但只需从 Serial.println(g); 中获得一个 0.每个执行周期需要高达 15 秒.

有人建议我将:Serial2.write("AT\r");替换为Serial2.println("AT\r")Serial2.write("AT\r\n"); 作为调制解调器识别需要的新行AT 命令.第一次替换没有产生结果,但第二次产生了响应,如下所示.但似乎只是 MCU 错误,与调制解调器连接无关.

19:48:21.715 ->开始19:48:36.692 ->大师冥想错误:核心 1 恐慌(非法指令).异常未处理.19:48:36.692 ->0x400d1c6c 处的内存转储:b41f6520 92f01a64 a0a2002219:48:36.692 ->核心 1 寄存器转储:19:48:36.692 ->PC:0x400d1c70 PS:0x00060530 A0:0x800d0db4 A1:0x3ffb1f5019:48:36.692 ->A2:0x3ffbdc5c A3:0x00000000 A4:0x3f40012c A5:0x0000001019:48:36.692 ->A6:0xffffffff A7:0x00000008 A8:0x800d1c70 A9:0x3ffb1f1019:48:36.692 ->A10:0x00000001 A11:0x00000000 A12:0x3ffb8218 A13:0x0000000019:48:36.744 ->A14:0x00000000 A15:0xff000000 SAR:0x00000018 原因:0x0000000019:48:36.744 ->EXCVADDR:0x00000000 LBEG:0x4000c28c LEND:0x4000c296 LCOUNT:0x0000000019:48:36.744 ->19:48:36.744 ->ELF 文件 SHA256:000000000000000019:48:36.744 ->19:48:36.744 ->回溯:0x400d1c70:0x3ffb1f50 0x400d0db1:0x3ffb1f70 0x400d0c94:0x3ffb1f90 0x400d1499:0x3ffb1fb0 0x5008x301519:48:36.744 ->19:48:36.744 ->正在重新启动...19:48:36.744 ->2019 年 7 月 29 日 12:21:4619:48:36.744 ->19:48:36.744 ->rst:0xc (SW_CPU_RESET),boot:0x36 (SPI_FAST_FLASH_BOOT)19:48:36.744 ->configsip: 0, SPIWP:0xee19:48:36.744 ->clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x0019:48:36.744 ->模式:DIO,时钟格:119:48:36.791 ->负载:0x3fff0018,长度:419:48:36.791 ->负载:0x3fff001c,长度:104419:48:36.791 ->负载:0x40078000,长度:1012419:48:36.791 ->负载:0x40080400,长度:585619:48:36.791 ->条目 0x400806a819:48:37.869 ->开始

验证硬件有人问我是否已经验证了其他硬件项目中的 RXD 和 TXD 连接.我已经验证了 UART 连接,但为了让事情变得更加困难,esp 的 UART 引脚通过逻辑电平转换器将电压从 3.3V 转换为 1.8V.

为了获得这些读数,我使用了下面的代码(与上面的代码不同),因为我的循环仅每 15 秒执行一次,我无法获得读数,因此我将写入频率更改为 10 毫秒.

#include 诠释绿色力量 = 32;国际领导= 33;无效设置(){Serial.begin(115200);//打开串口通信并等待端口打开:Serial2.begin(115200,SERIAL_8N1,16,17);pinMode(led,输出);//用于验证电路板的电源pinMode(绿色电源,输出);//用于允许辅助过程的电源数字写入(绿色电源,高);//允许给辅助设备供电数字写入(LED,高);//给验证电路加电延迟(1000);}无效循环(){Serial.println(开始");Serial2.write(1);延迟(10);}

解决方案

您好像忘记用回车符终止每个 AT 命令行,因此没有响应.


附录

[我想我已经指出了您代码中的明显缺陷,但现在看来您的情况可能/可能有很多问题.]

您是否确认调制解调器已正确连接到 Arduino,即存在 接地 连接以及每个 RxDTxD 连接到互补引脚?
您是否已确认调制解调器已正确通电且功能正常?
你能用示波器探测那些 RxDTxD 线吗?

调制解调器在收到 AT 命令后可能不会立即响应,但您的代码确实希望如此.
可以在 Serial2.write("AT\r")while (Serial2.available()) {...} 语句之间插入(固定)延迟.
或者,我已经看到 while (!Serial2.available()) continue; 用于 wait 以等待响应变为可用(而不是使用任意硬编码延迟).


附录 2

范围照片"的添加清楚地表明您在硬件领域存在问题.

<块引用>

第三张图显示了 ESP/MCU 的 RXD 线上的读数,完全平坦.

不,这不是完全平坦"的轨迹,而是带有尖峰的噪声信号.
这是为什么?
当然,没有响应/数据,因为您以不正确的波特率发送垃圾值,而不是发送 AT 命令以预期的波特率.

Hello I am trying to send a test AT command to make sure my esp32 to cellular module connection is working correctly. The cellular module is a Quectel BG95 and the ESP32 is a ESP-WROOM-32UE (datasheet) The commands will be in a format like the image below, taken from the modem's manual.

The C++ code is being uploaded through Arduino IDE. And then the ESP uses its RXD and TXD pins GPIO 16 and 17 respectively to make a UART connection. Here is the code:

#include <HardwareSerial.h>
int greenpower = 32;
int led = 33;


void setup() {

  Serial.begin(115200);  // Open serial communications and wait for port to open:
  Serial2.begin(115200,SERIAL_8N1,16,17);
  pinMode(led, OUTPUT); //for verifying power to the board
  pinMode(greenpower, OUTPUT); //for allowing power to auxillary processes
  digitalWrite(greenpower, HIGH); //allow power to aux devices
  digitalWrite(led, HIGH);  //apply power to verification circuit
  delay(1000);

}

void loop() {
  Serial.println("Started");
  Serial2.write("AT\r");
  while (!Serial2.available()) continue;
  while (Serial2.available()) {
    int g = Serial2.read();
    Serial.write(g);
    Serial.println(g);
  }
  delay(1000);
}

The code has been edited to address some of the concerns in the comments/answers. That is adding a delay after the test AT command: Serial2.write("AT\r"); and added the carriage return character at the end. When I upload this program and check the serial monitor I see "Started" but just get a 0 from the Serial.println(g);. Each execution cycle takes a whopping 15s.

It was suggested that I replace: Serial2.write("AT\r");with either Serial2.println("AT\r") or Serial2.write("AT\r\n"); as a new line is needed for modem to recognize AT command. The first replacement yielded no result but the second yielded a response, which is below. But appears to be just an MCU error, nothing to do with a connection to the modem.

19:48:21.715 -> Started
19:48:36.692 -> Guru Meditation Error: Core  1 panic'ed (IllegalInstruction). Exception was unhandled.
19:48:36.692 -> Memory dump at 0x400d1c6c: b41f6520 92f01a64 a0a20022
19:48:36.692 -> Core 1 register dump:
19:48:36.692 -> PC      : 0x400d1c70  PS      : 0x00060530  A0      : 0x800d0db4  A1      : 0x3ffb1f50  
19:48:36.692 -> A2      : 0x3ffbdc5c  A3      : 0x00000000  A4      : 0x3f40012c  A5      : 0x00000010  
19:48:36.692 -> A6      : 0xffffffff  A7      : 0x00000008  A8      : 0x800d1c70  A9      : 0x3ffb1f10  
19:48:36.692 -> A10     : 0x00000001  A11     : 0x00000000  A12     : 0x3ffb8218  A13     : 0x00000000  
19:48:36.744 -> A14     : 0x00000000  A15     : 0xff000000  SAR     : 0x00000018  EXCCAUSE: 0x00000000  
19:48:36.744 -> EXCVADDR: 0x00000000  LBEG    : 0x4000c28c  LEND    : 0x4000c296  LCOUNT  : 0x00000000  
19:48:36.744 -> 
19:48:36.744 -> ELF file SHA256: 0000000000000000
19:48:36.744 -> 
19:48:36.744 -> Backtrace: 0x400d1c70:0x3ffb1f50 0x400d0db1:0x3ffb1f70 0x400d0c94:0x3ffb1f90 0x400d1499:0x3ffb1fb0 0x40086155:0x3ffb1fd0
19:48:36.744 -> 
19:48:36.744 -> Rebooting...
19:48:36.744 -> ets Jul 29 2019 12:21:46
19:48:36.744 -> 
19:48:36.744 -> rst:0xc (SW_CPU_RESET),boot:0x36 (SPI_FAST_FLASH_BOOT)
19:48:36.744 -> configsip: 0, SPIWP:0xee
19:48:36.744 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
19:48:36.744 -> mode:DIO, clock div:1
19:48:36.791 -> load:0x3fff0018,len:4
19:48:36.791 -> load:0x3fff001c,len:1044
19:48:36.791 -> load:0x40078000,len:10124
19:48:36.791 -> load:0x40080400,len:5856
19:48:36.791 -> entry 0x400806a8
19:48:37.869 -> Started

Verifying Hardware It was asked if I have verified the RXD and TXD connections among other hardware items. I have verified the UART connections but to make things more difficult the esp's UART pins go through a logic level shifter to take things from 3.3V to 1.8V.

Datasheet for logic level shifter

So I soldered 4 wires to the PCB. 2 wires to the ESP's pads for RXD and TXD and 2 wires on the 1.8V side of the level shifter headed to the modem's TXD and RXD. The first two images show readings from the scope on the ESP's TXD pad (yellow vary 0-2.7V) superimposed with a readings after the level shifter (purple vary 0-1.8V). The third picture shows the readings on the ESP/MCU's RXD line which are totally flat. On the MCU side of the level shifter it is 3.3V and on the Modem side it is 1.8V. Because the level shifter works on the ESP's TXD line, I presume it works on the ESP's RXD line.

To get these readings I used the code below (different from the code above) because with my loops executing only every 15s I couldn't get readings so I changed write frequency to 10ms.

#include <HardwareSerial.h>
int greenpower = 32;
int led = 33;


void setup() {

  Serial.begin(115200);  // Open serial communications and wait for port to open:
  Serial2.begin(115200,SERIAL_8N1,16,17);
  pinMode(led, OUTPUT); //for verifying power to the board
  pinMode(greenpower, OUTPUT); //for allowing power to auxillary processes
  digitalWrite(greenpower, HIGH); //allow power to aux devices
  digitalWrite(led, HIGH);  //apply power to verification circuit
  delay(1000);

}

void loop() {
  Serial.println("Started");
  Serial2.write(1);
  delay(10);
}

解决方案

Looks like you're forgetting to terminate each AT command line with a carriage return character, hence no response.


Addendum

[I think I've already pointed out the obvious flaw in your code, but now it seems that your situation could/may have a plethora of issues.]

Have you verified that the modem is properly connected to the Arduino, i.e. there is a ground connection as well as each RxD and TxD are connected to complementary pins?
Have you verified that the modem is properly powered up and functional?
Can you probe those RxD and TxD lines with an oscilloscope?

The modem may not respond instantaneously after receiving the AT command, yet your code does expect that.
A (fixed) delay could be inserted between the Serial2.write("AT\r") and while (Serial2.available()) {...} statements.
Alternatively I've seen a while (!Serial2.available()) continue; employed to wait for a response to become available (instead of using an arbitrary hardcoded delay).


Addendum 2

The addition of 'scope photos clearly indicate that you have a problem in the hardware domain.

The third picture shows the readings on the ESP/MCU's RXD line which are totally flat.

No, that's not a "totally flat" trace, but a noisy signal with spikes.
Why is that?
And of course there's no response/data because you're sending a garbage value at the improper baudrate, instead of an AT command at the expected baudrate.

这篇关于esp32 向蜂窝/gnss 模块发送的测试 AT 命令没有反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆