esp8266 webImport


MicroPython Repl command line is very nice, because you can telnet to the chip and read-and-evaluate python code. It is a great way of learning embedded IoT. The bad thing you cannot copy file while it is running, so experimenting get bad.

Also an automatic module update would be a very nice thing to have.

So I have created a small module called webImport which is able to

  1. download a from a known http server
  2. write it in the esp8266 and import it
  3. enable your esp8266 to be hacked by a worm :) (see below for caveats)

The idea is to serve your remote module via a HTTP server and load it on the repl (or programmatically) with

After a while you edit your and you make a newMethod. So you want to reload it…with…


The code is below and was tested on esp8266. It should work on Pyboard and more powerful board too.



As a bonus you can cross-compile the module, using the MicroPython cross compiler, which runs under any Unix-like system and compiles .py scripts into .mpy files.

This step is optional but offer to you less memory usage and better performance


Final thoughts

Be warned: having a remote download and execution code is a security risk. Node.js’ Npm package manager face this risk again and again, so you should consider some sort of password protection and / or https authentication using the ussl module which does not protect you but Man in the middle attack.

Comments are closed.