Labels

Saturday, 21 November 2026

Remote Serial Console

Intro

For a couple of months I have been investigating mechanisms for connecting remotely to ESP32 SBCs.  My interest was stimulated by the Breezybox terminal, which can be accessed through SSH.

I previously looked at SSH and Telnet remote connections and have now investigated remote serial console connectivity.

Local Console Connections

Arduino and IDF IDEs have a Serial Monitor for viewing ESP32 output and entering commands.
There are many alternatives to an IDE monitor; Putty and TeraTerm are my most used PC applications.


Recently I found a simple but useful web page console called web serial terminal.  It comprises a single HTML file and doesn't have many features but is easy and accomodating.  It works on PC COM ports so can be used for ESP32 or other devices with a serial port.


Plink is a simple terminal, integrated with Putty, which runs on the WSL command line.  An add on called Simply Serial allows you to integrate serial terminal options into Windows terminal alongside, Command Line, Powershell, WSL etc.

We now have a wider range of local serial console options.  However they do depend on ESP32 being attached to PC via a USB serial cable.  I expect that my practical ESP32 systems do not usually need to be situated near or attached to a PC.

WebSerial

WebSerial is a popular choice for a Remote Serial Console.  It is propriety code but has free and paid versions.  I installed the free version and ran their demo example.  Once you have added the library header to a sketch you simply replace any "Serial" function calls with "WebSerial".

The library uses ESPAsyncWebserver to provide HTTP and websocket communication.  ESPAsyncWebServer appears to be a solid and widely-used library which is non-blocking so shouldn't interfere with your own code.

WebSerial command input and console output work well and provide a practical solution.  The downside is that you need to alter all "Serial" statements in your sketch to "WebSerial".  This isn't a problem for your own code but may not be possible when integrating other libraries / code with the remote console.


Duplicate Serial Console Output

I spent some time trying to re-route Serial output to a different destination so that I can direct it to telnet or a web console.  Eventually I found it is not possible to re-route Serial from the UART but a reddit post pointed out that you can connect the TX pin on one UART as RX on another, which provides the potential to copy Serial output.
ESP32-S3 has three UARTs, UART0, UART1 and UART2.  It also has two USB-C connectors labelled USB (on the left) and COM (on the right).  By default UART0 uses pins TX=1, RX=2 while UART1 uses TX=17, RX=18 and UART2 pins are not assigned.  

By default Serial writes/reads the COM connector.  If you set "USB CDC on boot enabled in Arduino IDE, Serial writes reads the "USB" connector and "USB" becomes the serial monitor.

I wasted plenty of time experimenting with USB and COM ports trying to duplicated output from one to the other, without success.  I probably need better hardware knowledge to understand intracies of the ESP32 "GPIO Mux".

Solution

My working solution is as follows:
1)    Set USB-CDC disabled.
2)    Use UART0 (TX1=1, RX=2) as Serial (Serial0 is a synonym), it is also the COM port
3)    Use UART1 (TX=17, RX=18) as Serial1 (which is a pre-defined name)
4)    Set UART2 (TX=3, RX=4) as mySerial2 (you have to define these pins).
5)    Physically connect TX0 (pin1) to RX2 (pin4).
Now any character output on Serial, which is also the Serial Monitor, is also received on Serial2.

Using this hardware configuration I can write a sketch which has a callback on Serial2 and copies any character received to UART1 TX.  It is important to use a callback so that character copying is asynchronous / non-blocking.
For simplicaity I attach an FTDI serial cable to Serial1.    Now any character appearing on Serial Monitor is duplicated on a TeraTerm terminal attached to Serial1.  Alternatively, it could be redirected to a Telnet or WebSerial session.

Duplicate Input

This scheme works as UART0 TX is shared between the output to Serial Monitor/Teraterm and UART2 RX.
It is not possible to share UART0 RX in the same way.  If characters were typed on two terminal sessions simultaneously and received on a single RX pin they could corrupt each other.

The solution is to take any input from UART0 (Serial.read) or UART1 (callback) and echo it to bother terminals.   Clearly Serial Monitor on UART0 works on a line-by-line basis so we collect input from Teraterm/Serial1 upto a newline (NL) character then process it.  As usual we need to ensure input processing is non-blocking, a helpful post from Nick Gammon clarifies this technique. 


Serial Monitor

Serial1







We now have a practical implimentation of duplicated consoles.  One can enter commands on either and see output on both.


Triplicate Serial Console


once we can duplicate the Serial Monitor on another UART we can easily extend the functionality to WebSerial.  All Serial output can be duplicated to WebSerial (as well as Serial1) and WebSerial input can be triplicated to Serial0 and Serial1.  All our processing is non-blocking so our terminals can be used in parallel with whatever functionality is implemented in our sketch.


Whereas all Serial I/O can be duplicated with Serial1 we must wait for wifi and webserver/websocket communication to be established before seeing Serial Monitor output on WebSerial and being able to enter commands, as if they are on the console.

The good news is that we no longer have to use Serial or Serial1 I/O at all, we can just use WebSerial.  We have severed the connection from our PC and can control ESP32 remotely.

This is proved by disconnecting ESP32 from PC and connecting to 5V USB wall socket (or a battery pack).  We can then use an iPad browser session to communicate with ESP32.  We have a prototype remote terminal.

Monday, 9 November 2026

Music

The Macaroons

On Friday 6th November we saw The Macaroons play at The Sound Lounge in Sutton.
They are a group of local musicians who perform small gigs in the area.
Their music is described as Jazz/Blues.  At the front are trumpet/vocal and sax players, backed by drums, guitar, base and keyboards.

We saw them, briefly, playing at the Wallington Music festival (facebook link, sorry) so I was looking forward to the Sutton event.  They are so good.  Each is an experienced musician and their sound is wonderful, well-balanced between the different instruments.  They are usually led by trumpet and sax with the otheres contributing to a harmonius whole.  Mostly, music is written by band members; none is dull and there is plenty of variety.  Their music is available on Soundcloud.


Marianne Leigh

At 10am on a Sunday morning in August, I had driven to Heathrow, Terminal 2 to collect my family who were returning from Los Angeles.  I was feeling a bit tired, jaded, slow and grumpy so I dropped in to Costas for a coffee.
Without any warning or introduction a girl sat at the piano and started to sing.  She has a beautiful voice, skilled piano playing and a variety of songs.  It cant be an easy gig playing an Airport coffee shop but Marianne Leigh soon caught everyone's attention and started to receive enthusiastic applause.  It was magical and certainly transformed my morning.


The music was the result of an innovative arrangement between Costa and Bandcamp to arrange pop-up gigs for "upcoming" artists who are not yet established - a great idea.  Her own music is available on Spotify.


Thursday, 5 November 2026

Waveshare


As part of my investigation into using Breezybox as an ESP32 Shell program, I saw in Valentyn Danylchuk's documentation that he had tailored his Breezybox product for a Waveshare Touch system.  This comprises a 1024x600 pixel 7" touch screen with an ESP32S3 attached and costs £40.  It looked exciting so I purchased one from Waveshare.



















Although Breezybox dictates ESP-IDF is used to build firmware Waveshare provide a wide range of examples with instructions for both ESP-IDF and Arduino.  Instructions and examples are high quality making it easy to test out functionality.

06_LCD test shows the screens ability to display, colours, text and pictures.
07_SD does a quick SD card test.
08_TOUCH is amazing, you can touch up to 5 points on the screen (a right handful) simultaneously. The screen registers all of them and the demo shows a circle at each location.
LVGL tests show how it can provide all manner of GUI elements and includes a touch controlled slideshow.


My experience of IDF is that it is harder to build firmware.  However the IDF examples are clearly written so I was able to build and run the same demo tutorials. 





Outro

The Waveshare Touch is a splendid bit of hardware. Waveshare have produced some excellent documentation for hobbyists.  They have interesting products and I will certainly look to purchase "toys" from them in the future.

Unfortunately, I couldn't get the Breezybox software to work properly with the screen.  I will update this post if and when I have sorted the problems out.


Wednesday, 4 November 2026

AI stunned me

Google AI, in the form of detailed answers to search requests, has been very useful to me recently as I search for information to resolve programming problems.  Often, reading the "AI summary" tells me what I need to know or points me at a solution.  My programming skills are deteriorating and I often need a reminder or guidance to progress my projects.

One particular programming problem with an Arduino C program was causing me grief.  On a whim I simply pasted the program text into Google, without even telling it what the error was.  I was astounded at the answer.

I have copied in the complete dialogue below as I think it is so wonderful.  It provides a clear and detailed explanation of the problem, a corrected and improved version of the code and a list of enhancements.  Not only has it fixed my problem which was an incorrect definition of variables but it has also improved other areas and has adeed comments for various code features.



Out of interest I asked Gemini about moving the variables to the class definition as I thought this may be the original intention of the programmer and I was gobsmacked to get another detailed tutorial on how to improve my C code.



Outro 

For the first time I can see what all the AI excitement is about.  It is truly magical. The explanation relates directly to my problem, even though I didn't know what my problem was.  Gemini clearly understands the code and best practice for C++ programming and is able to apply that knowledge confidently.  It can be summed up in Gemini's confident observation: "here is THE corrected and ROBUST coding for your project".

It only remains to say that Gemini's answer worked immediately and I have had an epiphany.

As a start I will experiment with AI for help with my failing programming skills.  There is even a tailed version of Claude for Ardunio to get me started.



ESP32 Telnet

ESPTelnet

After successfully investigating SSH terminal access to ESP32 and recognising that SSH security is complex and not required for my purposes I decided to try telnet.

Google gives some choices for a telnet server, I chose to install ESPTelnet


As this is back in Arduino land testing becomes easier.  I simply installed ESP Telnet library by Lennart Hennings and found in the examples "TelnetServerExample.  After uploading I see console messages to show that Telnet is up and running.  I can then Telnet in from my PC.  As usual there are not much of a shell provided, text typed in is echoed. Input from the client is processed by a function "onTelnetInput" which has a couple of commands "ping" and "bye".
 


I want to run programs on my ESP32 as well as controlling / monitoring it through remote access.  To test this I added a simple blink program to the example. When ESP32 is started the system LED is turned on/off each second.  The sketch works fine.  The only snag is that Telnet response drops.  When you type something you have to wait about 10s for a response.  The blink loop repeats every two seconds meaning the telnet loop can only work between loops.  Clearly the loop() function cycle time needs to be kept short to allow telnet processing.  For example a non-blocking version of blink would  need to be written.

Google Telnet

I googled "esp32 remote terminal" to identify potentially useful resources.  Google AI came up with an informative answer.  When I clarified my request it gave me a complete program!

I couldn't resist taking Google up on its offer. I copied code into a sketch entered my user/password and compiled it.  It didn't require installation of libaries and did exactly what I wanted!

Async Telnet

It is very pleasing to setup a telnet server with so little effort.  To be a practical tool, telnet needs to interfere as little as possible with useful work, the job for which we are using ESP32.  To do this we need non-blocking code, in practice this means we shouldn't need to include telnet commands within arduino loop() function.  Telnet functions should be invoked when needed using callback functions.

"Async Telnet for ESP32" by Frank Boesing seems to be perfect.
  

I copied source code snippetes into a sketch, added wifi initialisation code to setup() built the sketch and it worked.  I see a console message "Telnet server active" and I can telnet into ESP32 from a WSL command prompt.
By default the sketch is setup as a "log server" where communication is one way, so that ESP32 can transmit information to the telnet client.  Once I enabled the "handle incoming data" variable anything typed on Telnet client was returned to ESP32 and handled by a callback function.  Typically, this function will allow commands to be transmitted to ESP32 for control purposes.

Outro


AsyncTelnet gives me a much easier, appropriate solution to my desire for remote access.  It can be implemented without obstructing other software running on ESP32 and should be part of my overall ESP32 remote access objective.

I did have one problem getting AsyncTelnet code to work which led to my first productive use of AI which I will write about next.


Sunday, 1 November 2026

ESP32 SSH

breezy_ssh

My breezybox project provided me with a terminal shell for ESP32 through a PC USB COM port complete with unix-style commands.  This was a very good start but I really want remote access to ESP32 which would give me freedom to connect from various devices and wouldn't require the ESP32 device to be attached to my PC.

Breezybox has an additional component called breezy_ssh which implements an SSH server alongside breezybox to meet this requirement.  Building on knowledge gained from the breezybox install breezy_ssh installation was very straightforward (it was a breeze ;)).

I downloaded an example provided by Valentin Danylchuk which included an sdkconfig and partition table.  After a little tweak the build was successfully flashed to ESP32-S3 and started up. Using the serial console I could see that breezybox was working and I could use the file system as previously.  In addition there was a prompt to start the ssh server.

The first action is to connect to wifi ("wifi connect") and bring up the ssh server ("sshd start").  I could then start an ssh client session on the PC😊😊.

Using breezy_ssh

The SSH client session works much better than a serial console.  I/O redirection works so I can echo text and redirect (">") it to a file.  wget is now working so I can download files using http.  vi works so I can edit files locally.  This gives me everything I need to set up a simple web site, just containing an index.html file.  I then start a web server ("httpd web") and access it from my browser.

The "big picture" below shows COM ports, serial console, ssh session and web access.


One downside with breezy_ssh is that I need to use the serial console to start wifi and ssh.  Generously, Valentin does provide the ability to run shell scripts and a script "init.sh" is executed when you start up.  Unfortunately the script didn't work for me when I put "wifi connect" in init.sh, so I have to start it manually.  With further effort I could probably arrange for wifi and sshd to start within the program or diagnose how to make init.sh work.

libssh

I felt breezybox + breezy_ssh looked a bit complicated for my needs and wanted to look at alternatives.

libssh, written by David Cermak, is the ssh library for ESP32 IDF and is used within breezybox. I decided to test the example he provides (esp_ssh).  Initially I tried to use IDFv6 both VSC and CLI versions.  Surprisingly it wouldn't compile.  I found this is due to "breaking changes" introduced between ESPv5 and ESPv6.  David does provide a "Shim" to enable libssh to work with IDFv6 but I didn't have much success with it.
Instead I used IDFv5 to and the libssh example builds and flashes without problems. I can start ESP32S3, wifi and ssh server are started automatically.  I can ssh in from WSL or Putty, which works better.  Any text typed into SSH client is echoed on the serial console. There are only three command reset, hello (hello world message) and exit.

The example is much simpler than breezybox which is good.  Naturally it has less functionality and I would need to write my own terminal shell.  

Libssh is the base library used for ssh on ESP32 with IDF and therefore the simplest possible implementation.  Looking at the source code I see that there is much complexity to deal with ssh authentication, creating and checking keys etc.  

For my purposes I don't actually need any security as I only intend to use CLI access on the local network.  This thought leads me to try telnet access in the next stage of my investigation.

 


Breezybox Terminal

 Rationale

The idea of running a terminal shell on an ESP32 appeals to me.  Normally you download a program to ESP which then does what it has been instructed in the source code.  Input and output are either carried out through peripherals (buttons, keypad, OLED screen, LEDs, etc.) or a web page which is built to display results or accept instructions (buttons, text boxes etc).

A terminal shell allows typing inputs on a keyboard and showing outputs on a screen.  You can run a command and display results using a Command Line Interface (CLI).  I have used CLI for over 40 years and it makes me feel I have a real computer under my control rather than pre-programmed hardware.

Previously I have tried out Shellminator on an ESP32-C3.  However, I am interested in using Breezybox which has many more capabilities including a file system, together with associated commands, and SSH access.

ESPShell

I purchased an ESP32-S3 N16R8 for the new project.  Although most current ESP32 models are RISC-V, ESP32-S3 runs more powerful Xtensa cores.  This model comes with an extra 8MB PSRAM (pseudo-static RAM, memory contents are preserved when powered off) and 16MB flash memory.  It has no SD card or screen.

As a first test, before working on Breezybox I tried ESPShell.  Installation is as simple as installing the library and adding the header ("#include espshell.h") to your Arduino sketch.  There is no need to amend setup() or loop() functions!  Results are very impressive, a set of commands to tell you about your system.  Arduino serial monitor doesn't display well so a TeraTerm session is preferred. It gives a lot more information than Shellminator.


Breezybox Headaches

Although ESPShell is very good I would like to try the Unix like interface, SSH access and other features available on Breezybox.


In contrast to ESPShell, breezybox required plenty of time and patience.  It hasn't been developed for Arduino meaning I had to use the more complex/advanced/complete ESP-IDF environment.

At first I had no success, I could not build an image either using ESP-IDF CLI or VSC (Visual Studio Code).   Firstly there were errors mainly relating to "json" not found which I circumvented.  Then came "usb_serial_jtag not found" errors.

Eventually it occurred to me that I am using a recent major new version ESP-IDF v6.0.1.  Perhaps  Breezybox had been developed using IDF v5.  It turns out there are major "breaking" changes in the new IDF version.  I installed IDF v5.5.5 which was the last one before IDF v6 and the breezybox build worked.

Breezybox Build

In fact, with the correct environment, installation and build are incredibly easy using the ESP-IDF framework.



Although the build was successful, I had more work to do using "IDF menuconfig" to configure appropriate options.

The image was bigger than the default 0x100000.  So we need to add a partitions.csv file which gives us 0x2000000 in the "factory partition".


Next I had to configure 16MB RAM
Finally I had to configure the USB COM port to be used as the system console.

At last I have a working image.




















Using Breezybox

Breezybox has its own virtual filesystem in Flash memory.  Its initial size is 1.5M.  The only file existing initially is "init.sh" which echoes a message "Welcome to Breezybox".  A set of commands  is provided to manage files.  
Other useful shell commands are also provided for system status, networking.
More interestingly there is a command "httpd" to start a web server and "eget" to download executable apps to the system.



Adding memory


The first thing we want to do is use eget to download some apps to provide us with extra functionality.  Unfortunately the system is severly memory constrained.  We only have 300k SRAM (static RAM) available.
The solution is to configure to configure our 8MB PSRAM for our use.  In menuconfig we enable PSIRAM.  It happens that our PSRAM is "Octal" which also needs to specified.



Now when the image is rebuilt we have 8MB PSRAM available.


Now we can download apps from valdanylchuk/breezybox.   The ones I want to use are wget (to download files via http) and vi (to edit files locally).  Unfortunately neither appear to work on the serial console.  In addition I/O redirection wasn't working for me, so I had no way of creating webpages so that I could bring up the web server (httpd).

Instead I tried adding a custom command to breezybox source code.  This was a very helpful example as  it worked straightaway and showed me how to register an ESP console command so that it can be used on the command line.

Outro

At this stage I have working breezybox environment although it is not fully functional through the serial console.
A lot of progress has been made, with Google's help, in understanding my ESP32S3 N16R8 system memory/flash and how to use IDF menuconfig.

It is rewarding to understand the complexity of ESP-IDF a little bit more.  It also helps me appreciate the magic which Arduino does to hide/disguise most of this to give casual users the ability to build ESP32 images.

I don't really want to use a serial console to control ESP32, I would like a remote console.  Breezybox provides a component breezy_ssh which provides an ssh server and allows standard access over wifi.  This is the next area to test.