esp32-wroom32 为什么不能通过串口与外设通讯

硬件小白一枚
Posts: 4
Joined: Sun Oct 15, 2023 2:42 am

esp32-wroom32 为什么不能通过串口与外设通讯

Postby 硬件小白一枚 » Sun Oct 15, 2023 3:05 am

各位前辈:
我是硬件小白,以前做软件开发,最近刚自学一个月单片机开发,我自学实验项目: 通过esp32-wroom32 这个开发板通过串口与支持串口TTL 通讯的数码管通讯(这个数码管是在某宝购买的中盛科技的数码管),希望数码管可以显示数字,我使用PC的串口助手通过usb转TTL模块给数码管发送指令 ,数码管能够正常显示数字,但是使用esp32-wroom32 给数码管发指令,数码管始终不显示,不知道是什么原因? 能否给些建议, 谢谢。
具体接线是 开发板 数码管
Rx16 <----> Tx(A)
Tx17 <----> Rx(B)
Vcc <----> 外部24伏直流供电
Gnd <----> Gnd

使用arduino IDE 编写代码如下:

#include <HardwareSerial.h>
static const int C_Baut = 9600;
HardwareSerial SerialPort(2);
unsigned char tmp[] = {0x01,0x10,0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x30, 0x00, 0x31,0x00,0x30, 0x00,0x32,0x7A,0x67}; //应该显示0102,在PC串口助手发送,数码管可以正常显示
void setup() {
// put your setup code here, to run once:
Serial.begin(C_Baut);
SerialPort.begin(C_Baut, SERIAL_8N1,16,17);
}

void loop() {
SerialPort.write(tmp,sizeof tmp/sizeof(tmp[0]));
SerialPort.print(1);
delay(1000);
SerialPort.print(0);
delay(1000);
delay(1000);
// put your main code here, to run repeatedly:

}

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: esp32-wroom32 为什么不能通过串口与外设通讯

Postby bidrohini » Sun Oct 15, 2023 11:58 am

what can you see in the serial monitor?

Who is online

Users browsing this forum: No registered users and 11 guests