The work was to port the FT-857D CAT library and the corresponding display application on the ESP32 T-Display. This software was originally developed on an Arduino Nano (see article) The goal was to have a platform of the same size as the Arduino Nano but with in addition to the serial link, an on-board WiFi and Bluetooth.
The software changes included:
– taking into account a more rigorous C-compiler for the ESP32,
– replacing the 4×20 LCD screen with a 135 x 240 pixels TFT screen,
– managing the serial link with the FT-857D,
– fixing a bug in the string statement that stores the frequency (I forgot the end-of-chain character 🙂 ).
The physical connection with the FT-857D has also been modified to take into account the 3.3V max voltage on the ESP32 pins.
1 – C Language:
The compiler for ESP32 verifies the constant/variable differences at the declaration level and does not make an implicit conversion. The sprintf function “bugged” on a char byte conversion. The type of getSMeter function was changed from char to String; the code for Arduino was retrofitted to have a maximum compatibility.
2 – Screen replacement:
With the TFT screen you have to rewrite an entire area with the wallpaper color to “erase” the previous display completely. This was done by using the tft.fillRect (x, y, width, height, color) function of the tft_eSPI library . To avoid erasure with each update (about every 300/500ms) that gives a blinking effect, the values of previous data are stored and the data is written only if its value changed. The code for the display functions contained in the .ino program was therefore significantly changed but the code for Arduino was not retrofitted.
3 – Serial link:
The ESP32 has three UART (0 to 2). UART 0 is used for the system and UART 1 is used to program flash on some boards. Only UART 2 is available for the application. The UART 2 exit pins are by default 16 (Rx) and 17 (Tx) but on the TTGO T-Display board pin 16 is taken for the SPI bus. As it is possible to reallocate the exit pins on the pins 25 to 27 , the pins 26 (Rx) and 27 (Tx) were taken. Since the SoftwareSerial library does not exist on ESP32, the HardwareSerial library has be used.
The following changes were made to the files:
– CAT-FT857-ESP32.ino: replacing SoftwareSerial with the HardwareSerial Library (include),
– FT857D-ESP32.h: replacing SoftwareSerial with the library HardwareSerial (include),
– FT857D-ESP32.cpp: – replacement of SoftwareSerial by the HardwareSerial library (include),
– definition of UART 2 as a serial port:
extern HardwareSerial rigCat(2); // UART 3 of ESP32,
– change of the serial port initialization:
similar to Serial.begin (baud) void FT857D::begin (int baud) rigCat.begin (baud, SERIAL_8N2, 26, 27); // speed - 8 bits - No parity - 2 stop bits - Rx pin - Tx pin }
4 – Physical connection to FT-857D:
The FT-857D’s serial link is at a TTL level of 5V. The ESP32 max pin voltage being 3.3V an adaptation by a resistance voltage divider is required on the Rx input of the ESP32.
5 – Source code:
The following source codes are given “as is”; it may contain bugs. Its reuse is under the responsibility of the developer; any damage resulting from its use is beyond my responsibility.
Hereafter a GitHub link on the latest version of the FT857-ESP32 library and of the application. That application includes also a web server.
FT857-Web-browser-CAT-ESP32 – Version V1.0