I wanted to get a wireless ESP32 debug solution and tried Telnet servers in MicroPython for that. Unfortunately there is an issue with "dupterm()" not being implemented in ESP32 MicroPython, see this thread:
https://forum.micropython.org/viewtopic.php?f=18&t=3997
In this thread user loboris pointed to his own MicroPython port for ESP32, with multi-core support, Telnet and FTP server.
I tried the last built, and while MicroPython worked flawlessly, the Telnet server was not enabled.
I asked him for a new build with Telnet server enabled, which he did provide!
https://forum.micropython.org/viewtopic ... 997#p23075
Just to have all in one place here you can find that version (small .zip) I used attached to this posting.
In case you are interested in his full distro and documentation, you can find it here:
https://forum.micropython.org/viewtopic ... 997#p22937
For installing on your ESP32 module you just need working "esptool.py" and modify "esp32/flash.sh" to your needs:
Code: Select all
$ unzip -l MPy_loboris_firmware_latest.zip
Archive: MPy_loboris_firmware_latest.zip
Length Date Time Name
--------- ---------- ----- ----
0 10-14-2017 15:47 esp32/
0 07-21-2017 15:21 esp32/bootloader/
19760 11-08-2017 21:06 esp32/bootloader/bootloader.bin
1258272 11-08-2017 21:06 esp32/MicroPython.bin
13384 11-08-2017 21:06 esp32/sdkconfig
403 11-08-2017 21:06 esp32/flash.sh
3072 11-08-2017 21:06 esp32/partitions_mpy.bin
144 11-08-2017 21:06 esp32/phy_init_data.bin
--------- -------
1295035 8 files
$
After "screen /dev/ttyUSB0 115200" and pressing Reset button on module you see bootup messages and command prompt.
The first I did yesterday evening was to start Telnet server and login to ESP32 via telnet, worked like a charm !
You can see telnet wireless into MicroPython command line, then do interactively a WiFi scan followed by Arduino "Blink" sketch (in micropython):
Next I made my Android a wireless Access Point and made ESP32 MicroPython connect to it (left side shows how do determine ESP32s IP address by clicking on mac address, needed for being able to open telnet session to ESP32 with
app):
Here is a 2min youtube video demonstrating how to work with Android as mobile wireless terminal for ESP32 MicroPython:
https://www.youtube.com/watch?v=8Batb22 ... e=youtu.be
- determined ESP32 IP address on Android
- opened telnet session to ESP32 in JuiceSSH app
- logged in as "micro" user with default password "python"
- created a syntax error intentionally by executing "oled.invert()"
- enabled JuiceSSH extended keyboard with arrow keys, CTRL, ...
- pressed arrow up to get last command, corrected by inserting "1" into parenthesis
- now OLED display got inverted
- executed "machine.reset()"
- ESP32 rebooted and boot messages appeared on OLED display
- JuiceSSH telnet session got terminated
- opened new telnet session and logged in again
- now executed "station.scan()" doing full WiFi scan
- all access points found got shown in telnet session
As described typos are not an issue because arrow keys allow to easily access complete MicroPython command line history and modify+execute them.
This is the listing of MicroPython "boot.py" I created and used for enabling OLED display, FTP server and Telnet server (allowing wireless telnet session from Android -- and from laptop, if that is connected to Android AP wireless). It imports modules network, machine, ssd1306, os and time which are available to you. And it defines variables station for WiFi and oled for display output for you:
Code: Select all
# This file is executed on every boot (including wake-boot from deepsleep)
import sys
sys.path[1] = '/flash/lib'
import network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect("HUAWEI Y360-U61_8621", "verySecret ;-)")
import machine, ssd1306
i2c = machine.I2C(scl=machine.Pin(4), sda=machine.Pin(5))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
oled.fill(0)
oled.text(' MicroPython on ', 0, 0)
oled.text('ESP32 board with', 0, 9)
oled.text('- SSD1306 OLED ', 0, 19)
oled.text('- FTP server ', 0, 28)
oled.text('- Telnet server ', 0, 37)
oled.text('ESP32 connects 2', 0, 48)
oled.text('Android AP(WiFi)', 0, 57)
oled.show()
network.telnet.start()
network.ftp.start()
import os, time
How do you get this onto your MicroPython?
After you had installed MicroPython the first time and connected via eg. "screen /dev/ttyUSB0", just execute these two commands interactively:
Code: Select all
import network
network.ftp.start()
Then ftp into your ESP32, after "cd flash" you can do "get boot.py" to download the version present, then modify it to your needs (like I did above) and put onto ESP32 with "put boot.py". You have to do this once only, since from next boot on Telnet and FTP server will be started automatically! This MicroPython mobile wireless debug+dev solution is self contained, no tools like ampy needed anymore for file upload/download (although you still can use them if you want).
Hermann.
P.S:
I just booted ESP32 and Android was not enabled as wireless AP.
ESP32 booted flawless.
Then I enabled wireless AP on Android, and a few seconds later the ESP32 got shown as connected.
So order of actions on ESP32 and Android is not important.
As hands on exercise for you, after installation as described above.
Do copy+paste these lines (including the last three empty lines) into your MicroPython session:
Code: Select all
while True:
oled.invert(1)
time.sleep(1)
oled.invert(0)
time.sleep(1)