Setting uos.dupterm() on boot

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Posts: 2
Joined: Tue Oct 30, 2018 12:12 pm

Setting uos.dupterm() on boot

Post by timk_ » Tue Oct 30, 2018 12:27 pm


I am using MicroPython v1.9.4-272-g46091b8a (daily build) so I can make use of the two uos.dupterm() slots. I can see that by enabling WebREPL and doing nothing else, WebREPL is attached to slot 0 and UART 0 is attached to slot 1.

While developing and testing I'd like to exclusively use WebREPL, and use UART 0 for talking to my solar inverter via a MAX3232 (so disable REPL on/from UART 0).

I thought putting "uos.dupterm(None, 1)" at the end of my would do the trick, but is this not allowed as a safety measure?

It works fine if I manually type it into WebREPL after booting. This is displayed and the serial port no longer responds or updates:

>>> uos.dupterm(None, 1)
UART(0, baudrate=115200, bits=8, parity=None, stop=1, timeout=0, timeout_char=1)

I want to also say MicroPython is awesome, great job! :D


User avatar
Posts: 1368
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Setting uos.dupterm() on boot

Post by Roberthh » Tue Oct 30, 2018 1:41 pm

The default enables the UART for REPL. So if you comment out or delete that statement, UART will not even enabled for REPL.

Posts: 2
Joined: Tue Oct 30, 2018 12:12 pm

Re: Setting uos.dupterm() on boot

Post by timk_ » Wed Oct 31, 2018 11:27 am

Hi Robert,

Thanks for your reply!

I was using my own that did not have those default commands in it anymore. Just as a sanity check I wiped and reflashed the device and left the as-is, except for commenting out the two relevant lines, and running 'import webrepl_setup', which uncommented the webrepl.start() line. I also ran through the network setup to get the device to join my network (WebREPL connectivity has never been an issue though).

Here's what my looks like, and the UART still gets connected:

# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#import uos, machine
#uos.dupterm(machine.UART(0, 115200), 1)
import gc
import webrepl

The only two files I have are and the password file for WebREPL:

>>> uos.listdir()
['', '']

Does anyone else experience the same?


Post Reply