Setup WebREPL
Realize remote debugging and upload script
Last updated
Realize remote debugging and upload script
Last updated
The previous tutorial realized the function of the robot to perform sequence actions by editing Python code offline. But this is very inconvenient. Whenever we need to modify the code, we need to unplug the WiFi module for modification, and we cannot flexibly pause and modify parameters during execution. The reason is that ESP8266 only has one serial port, and we need to use it to communicate with NyBoard. Fortunately, MicroPython uses the WiFi function provided by ESP to realize remote wireless Python debugging - WebREPL.
On the basis of official documents, combined with the characteristics of ESP8266, we wrote the following tutorials:
After connecting the device, enter import webrepl_setup
in the shell interface, and input according to the prompt information:
Enable it running on boot: E
Set password for it: your own password(e.g. 1234)
Repeat the password to confirm
Reboot the ESP8266: y
2. The script to setup webREPL
We use the demo script below, to replace the SSID and password with the network information your own around you.
After running the script, it will keep trying to connect to the WiFi network. Once connected, it will automatically start the WebREPL service of the device.
Remember this IP address (automatically assigned by router DHCP), useful when configuring WebREPL.
We are now debugging the Python script through WebREPL, and the previous serial port is used to communicate with NyBoard. So in the options, change the previous USB-COMx interface to WebREPL.
Then we fill in the IP address, port and password of WebREPL, and click OK.
When WebREPL Connected
is displayed, the connection is successful.
We can try some simple scripts, such as blink.py
.
WebREPL saves serial ports and supports wireless debugging. The disadvantage is that the speed is slow (because of network delay), and the waiting time for software reset is relatively long.
Now we can use webREPL to debug the script, but when we open the serial port monitor, we will find that whenever we run the script, the serial port will send out a series of debugging content: These massive strings will cause the NyBoard to be too late to process and crash. As shown below:
We hope that when debugging the program, the serial port only outputs the commands we want to output, not the Debug information. Open the boot.py
on the device, uncomment the line of code uos.dupterm(None, 1)
and save it , and unbind the serial port and REPL debug. Restart the module, and the serial port debugging assistant will no longer print the debug information.
As a supplement, we can output debug information through the print()
statement, which will be displayed in the Shell through WiFi.
So far, you can easily use the ESP8266 to debug robot through webREPL to edit action sequences based on MicroPython.