T-TWR 编程指南
快速入门
本文档旨在指导用户搭建 T-TWR 硬件开发的软件环境。
概述
T-TWR 拥有以下硬件资源:
ESP32-S3-WROOM-1-N16R8
OLED 显示屏(128 * 64)
SA868 集成专业对讲机模块
TP4054 电池充电芯片
18650电池座
编码器按键
准备工作
硬件:
T-TWR
烧录器
电脑(Windows、Linux 或 Mac OS)
软件:
arduino
platformio
安装准备
请先完成工具的安装,具体步骤见下:
安装依赖
T-TWR 支持以下版本的arduino-esp32:
T-TWR 需要以下依赖库支持,用户可以用过库管理安装。
警告
如果出现编译错误,请先检查以上依赖是否一致。
例程
管脚布局
Name |
Pin |
Note |
SA868_TX_PIN |
47 |
Serial transmit data pin |
SA868_RX_PIN |
48 |
Serial receive data pin |
SA868_PTT_PIN |
41 |
SA868 Transmitting/receiving control, “0” force the module to enter TX state; and “1” to Rx state. |
SA868_PD_PIN |
40 |
Power Down control, “0” for power down mode; “1” for the normal work |
SA868_RF_PIN |
39 |
high/low output power control; Leave open for high output power, low level to low output power. |
BUTTON_PTT_PIN |
38 |
发射/接收按钮 |
BUTTON_UP_PIN |
3 |
音量键 |
BUTTON_DOWN_PIN |
0 |
音量键 |
ENCODER_A_PIN |
9 |
编码器 Pin1 |
ENCODER_B_PIN |
5 |
编码器 Pin2 |
ENCODER_OK_PIN |
7 |
编码器确认按键 |
BATTERY_ADC_PIN |
6 |
电池电压检测 |
OLED_POWER_PIN |
21 |
OLED屏幕电源控制 |
LED_PIN |
1 |
用户自定义指示灯 |
数据手册
ESP32-S3-WROOM-1-N16R8 (Datasheet)
OLED Display Module (Datasheet)
SA868 (Datasheet)
Slide and Rotary Encoder Switches (Datasheet)
Troubleshooting
如果出现故障,请先查阅 故障排查。如果 故障排查 不存在你遇到的问题,请通过 GitHub Issue 获得技术支持。
Examples
AT Debug
用于调试SA868的通讯协议。
esp32s3作为串口转发器,PC通过串口工具,将SA868的指令发送到esp32s3,esp32s3转发到SA868。 同理,SA868的应答指令发送到esp32s3,然后转发到PC。
Arduino
推荐使用以下配置:

PlatformIO
烧录
T-TWR 通过 USB 链接到电脑。先按住 音量键-,再轻按复位键,最后松开 音量键-,即可进入到下载模式。
引脚定义
Name |
Pin |
Note |
SA868_TX_PIN |
47 |
Serial transmit data pin |
SA868_RX_PIN |
48 |
Serial receive data pin |
SA868_PTT_PIN |
41 |
SA868 Transmitting/receiving control, “0” force the module to enter TX state; and “1” to Rx state. |
SA868_PD_PIN |
40 |
Power Down control, “0” for power down mode; “1” for the normal work |
SA868_RF_PIN |
39 |
high/low output power control; Leave open for high output power, low level to low output power. |
BUTTON_PTT_PIN |
38 |
发射/接收按钮 |
数据手册
ESP32-S3-WROOM-1-N16R8 (Datasheet)
SA868 (Datasheet)
Troubleshooting
如果出现故障,请先查阅 故障排查。如果 故障排查 不存在你遇到的问题,请通过 GitHub Issue 获得技术支持。
Walkie Talkie
Arduino
推荐使用以下配置:

PlatformIO
安装依赖
T-TWR 支持以下版本的 arduino-esp32:
T-TWR 需要以下依赖库支持,用户可以用过库管理安装。
警告
如果出现编译错误,请先检查以上依赖是否一致。
频段选择
备注
因为AT指令不能读取到 SA868 模块的频段信息,所以需要在源代码在手动选择频段。
UHF_BAND
宏用于选择 UHF 频段,支持的频段范围是 400 ~ 480 MHz
_350_BAND
宏用于选择 VHF 频段,支持的频段范围是 320 ~ 400 MHz
VHF_BAND
宏用于选择 VHF 频段,支持的频段范围是 134 ~ 174 MHz
数据手册
ESP32-S3-WROOM-1-N16R8 (Datasheet)
OLED Display Module (Datasheet)
SA868 (Datasheet)
Slide and Rotary Encoder Switches (Datasheet)
Detailed Operation
待更新。
引脚定义
Name |
Pin |
Note |
SA868_TX_PIN |
47 |
Serial transmit data pin |
SA868_RX_PIN |
48 |
Serial receive data pin |
SA868_PTT_PIN |
41 |
SA868 Transmitting/receiving control, “0” force the module to enter TX state; and “1” to Rx state. |
SA868_PD_PIN |
40 |
Power Down control, “0” for power down mode; “1” for the normal work |
SA868_RF_PIN |
39 |
high/low output power control; Leave open for high output power, low level to low output power. |
BUTTON_PTT_PIN |
38 |
发射/接收按钮 |
BUTTON_UP_PIN |
3 |
音量键加 |
BUTTON_DOWN_PIN |
0 |
音量键减 |
ENCODER_A_PIN |
9 |
编码器 Pin1 |
ENCODER_B_PIN |
5 |
编码器 Pin2 |
ENCODER_OK_PIN |
7 |
编码器确认按键 |
BATTERY_ADC_PIN |
6 |
电池电压检测 |
OLED_POWER_PIN |
21 |
OLED屏幕电源控制 |
LED_PIN |
1 |
用户自定义指示灯 |
Troubleshooting
如果出现故障,请先查阅 故障排查。如果 故障排查 不存在你遇到的问题,请通过 GitHub Issue 获得技术支持。
故障排查
1. 如何进入下载模式?
先按住 音量键-,再轻按复位键,最后松开 音量键-,即可进入到下载模式。
2. SA868功率的问题
SA868模块支持 低(1.6W) / 高(1.8W) 两种功率;可以通过控制 SA868 的 Pin#7 的电平选择功率。 程序默认使用低功率,如果选择高功率,会导致T-TWR温度过高,请谨慎使用。
警告
当 esp32s3 没有程序的时候后,esp32s3的 Pin#39 为悬空,SA868的功率会被设置成高功率。
Copyrights and Licenses
Software Copyrights
All original source code in this repository is Copyright (C) 2022 LILYGO.
Third Party
RotaryEncoder Copyright (c) 2005-2014 by Matthias Hertel and licensed under the BSD license.
OneButton Copyright (c) 2005-2014 by Matthias Hertel and licensed under the BSD license.
U8g2_Arduino Copyright (c) 2016, olikraus@gmail.com and licensed under new-bsd license.
ArduinoJson Copyright © 2014-2022, Benoit BLANCHON and licensed under MIT License.
Documentation
HTML version of the T-Wristband Programming Guide uses the Sphinx theme sphinx_idf_theme, which is Copyright (c) 2013-2020 Dave Snider, Read the Docs. It is licensed under the MIT license.