T-TWR Programming Guide
Get Started
This document is intended to guide users to build a software environment for T-TWR hardware development.
Introduction
T-TWR has the following hardware resources:
ESP32-S3-WROOM-1-N16R8
OLED display (128*64)
SA868 Embedded small size wailie talkie module
TP4054 battery charging chip
18650 battery holder
Encoder
What You Need
Hardware:
T-TWR
Computer running Windows, Linux, or macOS
Software:
arduino
platformio
Install prerequisites
Please complete the installation of the tool first. The specific steps are as follows:
Install dependent libraries
T-TWR supports the following versions of arduino-esp32:
T-TWR needs the support of the following dependent libraries, users can use the library management to install:
Warning
If there is a compilation error, please check whether the above dependent library versions are consistent.
Examples
Pinout
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 |
transmit/receive button |
BUTTON_UP_PIN |
3 |
volume+ |
BUTTON_DOWN_PIN |
0 |
volume1 |
ENCODER_A_PIN |
9 |
Encoder Pin1 |
ENCODER_B_PIN |
5 |
Encoder Pin2 |
ENCODER_OK_PIN |
7 |
Encoder OK button |
BATTERY_ADC_PIN |
6 |
Battery voltage detection pin |
OLED_POWER_PIN |
21 |
OLED screen power control pin |
LED_PIN |
1 |
User-Defined Indicators |
Datasheet
ESP32-S3-WROOM-1-N16R8 (Datasheet)
OLED Display Module (Datasheet)
SA868 (Datasheet)
Slide and Rotary Encoder Switches (Datasheet)
Troubleshooting
If something goes wrong, first see Troubleshooting. If Troubleshooting doesn’t cover the issue you’re having, please get technical support via GitHub Issue.
Examples
AT Debug
Communication protocol for debugging SA868.
The esp32s3 is used as a serial port transponder, and the PC sends the SA868 command to the esp32s3 through the serial port tool, and the esp32s3 forwards it to the SA868.
In the same way, the response command of SA868 is sent to esp32s3, and then forwarded to PC.
Arduino
The following configuration is recommended:

PlatformIO
Burning
The T-TWR is linked to the computer via USB. First press and hold Volume-, then lightly press the reset button, and finally release Volume- to enter the download mode.
Pinout
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 |
transmit/receive button |
Datasheet
ESP32-S3-WROOM-1-N16R8 (Datasheet)
SA868 (Datasheet)
Troubleshooting
If something goes wrong, first see Troubleshooting. If Troubleshooting doesn’t cover the issue you’re having, please get technical support via GitHub Issue.
Walkie Talkie
Arduino
The following configuration is recommended:

PlatformIO
Install dependent libraries
T-TWR supports the following versions of arduino-esp32:
T-TWR needs the support of the following dependent libraries, users can use the library management to install:
Warning
If there is a compilation error, please check whether the above dependent library versions are consistent.
Band selection
Note
Because the AT command cannot read the frequency band information of the SA868 module, it is necessary to manually select the frequency band in the source code.
The UHF_BAND
macro is used to select the UHF band, and the supported frequency range is 400 ~ 480 MHz
The _350_BAND
macro is used to select the VHF band, the supported band range is 320 ~ 400 MHz
The VHF_BAND
macro is used to select the VHF band, the supported band range is 134 ~ 174 MHz
Datasheet
ESP32-S3-WROOM-1-N16R8 (Datasheet)
OLED Display Module (Datasheet)
SA868 (Datasheet)
Slide and Rotary Encoder Switches (Datasheet)
Burning
The T-TWR is linked to the computer via USB. First press and hold Volume-, then lightly press the reset button, and finally release Volume- to enter the download mode.
Detailed Operation
pending upgrade.
Pinout
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 |
transmit/receive button |
BUTTON_UP_PIN |
3 |
volume+ |
BUTTON_DOWN_PIN |
0 |
volume- |
ENCODER_A_PIN |
9 |
Encoder Pin1 |
ENCODER_B_PIN |
5 |
Encoder Pin2 |
ENCODER_OK_PIN |
7 |
Encoder OK button |
BATTERY_ADC_PIN |
6 |
Battery voltage detection pin |
OLED_POWER_PIN |
21 |
OLED screen power control pin |
LED_PIN |
1 |
User-Defined Indicators |
Troubleshooting
If something goes wrong, first see Troubleshooting. If Troubleshooting doesn’t cover the issue you’re having, please get technical support via GitHub Issue.
Troubleshooting
1. How to enter download mode?
First press and hold the Volume- button, then lightly press the reset button, and finally release the Volume- button to enter the download mode.
2. SA868 power problem
The SA868 module supports low (1.6W) / high (1.8W) power; the power can be selected by controlling the level of Pin#7 of SA868. The program uses low power by default, if you choose high power, it will cause the temperature of T-TWR to be too high, please use it with caution.
Warning
When there is no program in esp32s3, Pin#39 of esp32s3 is floating, and the power of SA868 will be set to high power.
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.