User avatar
HermannSW
Posts: 4938
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Wireless Pico Micropython REPL

Sun Mar 21, 2021 4:16 pm

Recently @incognitum provided Pico webserver over USB: https://github.com/maxnet/pico-webserver

I made a Pico webclient over USB based on that: https://github.com/Hermann-SW/pico-webclient

My plan is to access internet from Pico through ESP01 (8pin ESP8266 module) Wifi: viewtopic.php?f=145&t=307220


This thread is about the opposite direction of ESP01 use:
Allow for wireless access to Pico Micropython REPL through the ESP01.


First I wanted to do that with Micropython on the ESP01 as well.
But the project us2n I tried was just broken
(example JSON on README.md invalid, even with code changed was not able to work even against Pi400 RX/TX):
https://github.com/dmascord/us2n


Then I remembered having used ESP01 as telnet to serial bridge 6 years ago to telnet wireless into bitlash shell running on Arduino:
https://forum.arduino.cc/?topic=327327#msg2267092

So I downloaded Linux ARM 32bit Arduino IDE to my Pi400 and installed it:
https://www.arduino.cc/en/software

Next I followed instruction on adding ESP8266 boards to the IDE via Boards Manager according instructions:
https://github.com/esp8266/Arduino#inst ... ds-manager

I selected "Generic ESP8266" as board and used cheap USB programming board to program the ESP01 over /dev/ttyUSB0
(I did solder a switch below the board between GND and I00, in order to easily bring ESP01 into flash mode):
20210321_165740.10%.jpg
20210321_165740.10%.jpg
20210321_165740.10%.jpg (20.58 KiB) Viewed 1340 times

First I loaded Blink example, that compiled and flashed fine, but did not start. The last message from Arduino IDE stated restarting via RTS, and that did not work with my module. But removing and reinserting the module did work.

Then I downloaded "ESP8266Wifi/WifiTelnetToSerial" demo, compiled and flashed without changes.

Finally I connected the ESP01 without USB module to the Pi400:
3V3/GND/RX/TX/EN to 3V3/GND/GPIO14/GPIO15/GPIO4

The ESP01 got powered.

Below you can see session of wireless login into Pi400 through ESP01 (makes more sense to do that with a Pi0).
I had enabled serial interface with login prompt via "sudo raspi-config".

This is what you see:
  1. executing "finger" on Pi400, showing there is no serial login active
  2. start pigpiod, configure GPIO4 as output and write 0 (to disable ESP01 enable pin)
  3. ping 192.168.178.77 shows not able to connect
  4. writing 1 to GPIO4 enables ESP01 and pings become successful
  5. telnet 192.168.178.77 goes through ESP01 to Pi400
  6. for some reson (dirt on the wire) font gets scrambled in session
  7. after login as pi/verySecret command "reset" gives clear view again
  8. now "finger" command shows that serial login is active
  9. logout and leaving telnet work as they should
Image


What we have seen is that ESP01 after powered and enabled perfectly routes telnet session to what is connected serially.
ESP01 was powered by Pi400, will be powered from and serially connected to Pico next.
From what I have seen and reported here, wireless Pico Micropython REPL access should just work ... trying that now.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4938
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Wireless Pico Micropython REPL

Sun Mar 21, 2021 5:03 pm

Wow, that was fast, connected ESP01 GND/3V3/TX/RX/EN to Pico GND/3V3/GP1/GP0/GP2.

For first test I needed manually set ESP01 enable pin connected to GP2.
So I did that through /dev/ttyACM0 minicom session (USB).
But the telnet session then was wireless through ESP01:
Peek_2021-03-21_17-45.gif
Peek_2021-03-21_17-45.gif
Peek_2021-03-21_17-45.gif (173.8 KiB) Viewed 1300 times

OK, that works.

So next I connected ESP01 enable pin to Pico 3V3 as well, eliminating the need for any action besides powering Pico.

Even CTRL-A (to raw mode) and CTRL-B (back) work, only "CTRL-D" for "machine reset" did not.
But calling reset explicitly did work!
So this is first wirless Pico REPL session -- connecting Pico to Pi400 USB was done for powering only!
Peek_2021-03-21_17-59.gif
Peek_2021-03-21_17-59.gif
Peek_2021-03-21_17-59.gif (203.42 KiB) Viewed 1300 times

Summary sofar:
Wireless Pico Micropython REPL through ESP01 with WifiTelnetToSerial Arduino example just works.
That example does not let CTRL-D through, but anything else I tried.

This is the setup, with ESP01 3V3 and EN pins both connected to Pico 3V3 (USB only used to power the Pico):
20210321_180703.15%.jpg
20210321_180703.15%.jpg
20210321_180703.15%.jpg (42.82 KiB) Viewed 1294 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4938
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Wireless Pico Micropython REPL

Sun Mar 21, 2021 5:54 pm

I have 512MB flash ESP01 and 1MB flash ESP01S modules.
Just flashed WiFiTelnetToSerial on the blue ESP01 module, works fine as well.

In case you don't have ESP01 module, you can buy ESP01S plus programmer for only 1.69$ (1.05$ shipping to Germany):
https://de.aliexpress.com/item/32693314450.html
ESP01_plus_pogrammer.jpg
ESP01_plus_pogrammer.jpg
ESP01_plus_pogrammer.jpg (33.58 KiB) Viewed 1254 times

I did now a fully wireless Pico test by powering the Pico over USB from a power bank, nice:
(did set Pico GP25 to 1 in wireless Micropthon to enable the Pico LED)
20210321_183633.15%.jpg
20210321_183633.15%.jpg
20210321_183633.15%.jpg (27.57 KiB) Viewed 1254 times

P.S:
WiFiTelnetToSerial does not allow to use arrow up/down keys to navigate in Pico MicroPython command history,
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

blimpyway
Posts: 682
Joined: Mon Mar 19, 2018 1:18 pm

Re: Wireless Pico Micropython REPL

Mon Mar 22, 2021 9:16 pm

A while ago I used esp-link as a tcp-serial bridge to talk to a remote arduino.
It allowed me to even host a simple webpage on the ESP which was used as a browser/javascript front-end for the serially connected arduino.

https://github.com/jeelabs/esp-link

User avatar
HermannSW
Posts: 4938
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Wireless Pico Micropython REPL

Mon Mar 22, 2021 9:54 pm

That sounds interesting -- I will definitely look into that project's features before continuing.

I just wrote a simple ESP01 sketch allowing the Pico to do HTTPS GET requests via serially connected ESP01
(the opposite direction on what this thread is about):
https://gist.github.com/Hermann-SW/e945 ... c679f48b03
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “MicroPython”