Remote terminal/monitor for ESP8266 & ESP32

Hello

Here is a web terminal, to "stay in touch" with an ESP, even when it is no longer connected to your computer. Its use goes through the same functions as the Serial terminal : .print(), .available(), .read(), ...

Try it :

1) Firstly, install external library arduinoSockets.h

2) Install my library WiFiTerm.h

3) Look at examples provided with library, thru Arduino IDE examples menu. Run Full_Demo.ino first, while looking at http://(my.ESP.ip.address)/term.html

Enjoy

Any comments and suggestions are welcome

how big is it? I use Telnet https://github.com/jandrassy/TelnetStream

Not very big, but of course bigger than a telnet library, because it also hosts client ressources (html, javascript, ...).

My lib might be easier to use : no need of telnet software on client-side. Testing it is quite straight : just load example Full_Demo.ino and follow instructions.

I'm slightly surprised. Nobody interested in replacing the standard Serial monitor by a web monitor, available natively on any browser (smartphone, etc.)?

It may be useful to keep a few prints in a program, for later verification of right behavior. And combined with ArduinoOTA, you can easily work on a distant ESP without manipulating it.

Did I miss something?

Hello bricoleau,

Thank you for posting your library, this is great. I have been wanting a terminal like this for awhile and decided to do some googling again and found this post. I have run the full demo and it works very well.

One suggestion would be that whenever a screen is resized, it automatically forces on or locks out changes to autoscrolling. When using this on a phone and you click the text box your keyboard pops up, and it resizes the window. When this happens it has a way of tricking the screen into thinking you turned off auto scrolling because the window shrinks from bottom up and auto scrolling gets disabled. This happens as data is flying by and you phone keyboard opens up.

Right now I have been changing the demo into being used with an esp8266 in ap mode so it can host a wifi that any phone can easily connect to. I have it working, but would like to enable a captive portal to automatically load the page for the user when they connect. To do this, you can map the server.onNotFound( functionPointerHere ) to cause the loading of the web page. I am looking through your library and think a function built into the library to enable this would be awesome :-). Do you have a public function that would work for this?

esp8266 redirect examples

here is my code so far, requestNotFound needs to be replaced with a proper function to point to

//WiFiTerm full demo
//Please open Serial terminal and follow instructions

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>

#include "WiFiTerm.h"

ESP8266WebServer server(80);

#define DNS_PORT        53

IPAddress apIP(192, 168, 1, 1);
DNSServer dnsServer;

void setup()
{

  Serial.begin(115200);
  term.link(Serial); //optional : echo every print() on Serial

  term.println("");
  term.println("**************");
  term.println("Program Start");
  term.println("**************");

  term.println("Welcome to WiFiTerm full demo example");

  //******************************************************

  // enable the wifi with the proper settings
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP("ArduinoTerminal", "");

  // if DNSServer is started with "*" for domain name, it will reply with
  // provided IP to all DNS request
  dnsServer.start(DNS_PORT, "*", apIP);

  // replay to all requests with same HTML
  server.onNotFound(requestNotFound);
  server.begin();
  term.begin(server);

  //******************************************************

  Serial.print("I'm waiting for you at http://");
  Serial.print(WiFi.localIP());
  Serial.println("/term.html");

  //term.unlink(); //optional : stop echo on Serial
  term.println("Welcome here");
  term.println("Please note that previous lines were printed BEFORE WiFiTerm connection");
  term.println("Now send me some text...");
}

void loop()
{
 server.handleClient();
 term.handleClient();

 if (term.available())
 {
 term.print("Ok I received : ");
 while (term.available())         //standard way
 {
 char c = term.read();
 term.print(c);
 }
 term.println();
 }

}

Thanks a lot for the suggestions I will study them soon.

... studied, approved, coded, tested and published on github :grinning:

Thank you very much.

1) autoscroll is fixed when resizing window Trick also happened on phone when switching between portrait and landscape format.

2) redirect any unknown url to /term.html This feature doesn't fit every program, so you have to activate it with :

 term.setAsDefaultWhenUrlNotFound();

3) a default favicon.ico is provided If the main program doesn't handle favicon, you can activate it with :

 term.activateArduinoFavicon();

The returned image is If you don't use this feature, image is not hosted in flash memory.

Hi there, it's a while since I'm looking for having a wireless serial monitor to log numbers from my PID. I ran an ESPduino, made a fresh new installation of arduino and ESP32. I follwed you instructions, at compiling Webserver.h was missing I tried with this: https://github.com/zhouhan0126/WebServer-esp32

I succeeded in compiling, can read the seria:

Welcome to WiFiTerm full demo example

Connecting to WiFi.connected WiFiTerm started

I'm waiting for you at http://192.168.0.242/term.html

But I can't browse that link.

As you may guess, I'm a newbie in Arduino.

Hi

It looks like your web server is not properly set.
loop() must often call server.handleClient()

Can you show your main program?

I don’t really know what is an ESPDuino.
My lib is provided with examples for standard ESP32 and examples for standard ESP8266.

The first ones use standard lib <WebServer.h>, the seconde ones use standard lib <ESP8266WiFi.h>.
Both of them are provided by Arduino IDE, depending on target selection.
What did you chose in Arduino IDE ?

Thanks. I want to get a wireless serial monitor, and I hope your terminal to be the solution.

The board: https://it.aliexpress.com/item/32840815594.html?spm=a2g0s.9042311.0.0.39fd4c4dozy9Pw

-I choose ESP32 Dev Module board -I choose the EP32 Full_demo.ino

The Webserver.h was missing and I only manage to install using the instructions here: https://github.com/igorantolic/esp32-alexa-wemo-emulator/issues/2

Everything went fine, but I can't load the 192.168.0.242/term.html in any browser. I indeed see the Espressif from the router web manager.

I tried also the sketch of this example: https://lastminuteengineers.com/creating-esp32-web-server-arduino-ide/

but failed to load the web page

Yep my lib WiFiTerm is what you are looking for

But you must have something wrong with your Arduino IDE
Standard <WebServer.h> is missing for ESP32 boards

Examples given on https://lastminuteengineers.com/creating-esp32-web-server-arduino-ide/ should work without having to install any library.
Try to solve it first.

When choosing ESP32 Dev Module board I compile EP32 Full_demo.ino without any error.

One possible reason is that rhe board was used for another project, where I flashed Espruino using this command: esptool.py --port COM12 --baud 460800 write_flash --flash_size=detect 0x1000 bootloader.bin 0x10000 espruino_esp32.bin 0x8000 partitions_espruino.bin

following this: https://photopizza.org/#!instructions

Please forgive my ignorance. Could it be the problem? I tried erasing flash with esptool: esptool.py --chip esp32 erase_flash Compiled and loaded both WiFiTerm and the STA example are not accessible by web browser.

Yes, flashing an hazardous bootloader might be the root cause of your problem, even if that does not explain why a standard lib is missing within your IDE.

I suggest to flash it again with a standard bootloader.

bricoleau: Yes, flashing an hazardous bootloader might be the root cause of your problem, even if that does not explain why a standard lib is missing within your IDE.

I suggest to flash it again with a standard bootloader.

-I succedeed in making the AP example in https://lastminuteengineers.com/creating-esp32-web-server-arduino-ide/ but the Station mode and WiFiterm are still not working

-I realized I made a mistake trying to compile the WiFIterm choosgin Arduino Uno board. When choosing ESP32-dev the webserver is available.

-I don't know how to properly work on bootloader, any suggestion will be really appreciated

Many thanks for your kind help

Ok, missing library is explained.

But the example from lastminuteengineers with station mode should work. And then WiFiTerm will also work.

Sorry I can't help you much more on flashing an ESPDuino. It is out of range of this topic.

Hi there, I bought an ESP32 WLAN DEV Kit1: https://www.ebay.it/itm/Espressif-ESP32-WLAN-Dev-Kit-Board-Development-Bluetooth-Wifi-v1-WROOM32-NodeMCU/253059783728?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

Same issues as the other one: can't load the browser page of both examples (your Full Demo and the other one).

Seems that I have to work on my Zyxel router. The ESP32 is regularly present in the router device list, but is not accessible by PC or android.

btw thanks for your help. I'm looking forward to test your remote terminal!

Hi there! Well, it was something so simple that I felt bad and happy at the same time. The ESP32 was connected to the guest wi-fi network (while the laptop was in the main one). It worked at the first attempt, as soon as the ESP32 was connected to the main wifi network. Sorry for multiple questions and many thanks for your work with the terminal.

best wishes

francesco

Hello Bricoleur,

Will this work with am Ethernet shield? Or only Wifi? Cheers

Sorry this library is only designed for ESPs

But it could easily be forked for standard atmega arduino.