Esp8266 is the super cheap chip which can run Micropython. You can buy it on Amazon for as little as €8 or less, and as little as $5 or less on Bangood/AliExpress.
The ESP8266 (ESP-12E spec) has a 4MB Flash RAM and about 96KB of RAM.
One nice thing is you can use an async mode easily and it works great. So I took this very good complete tutorial on asyncio, and hacked a bit the micropython source code to offer to you a super-breeze async version
First of all I taken the last version of Micropython (1.10) and started to push to its limit to offer at least 44Kb to the interpreter. 51Kb is the theoretical limit, but you must left some space for the interpreter to work correctly.
To increase Micropython available memory, you must download Micropython source code and hack it. It is a bit complex, so a Linux machine is recommended, anyway I managed to to it on a Windows10 with linux subsystem (WSL) which is a bit slow but it is a nice environemnt to work with.
On this forum [1] I found some specific information, then I forked micropython code base (below you will find my proposed modifications, also a pre-made image is provided).
Overview
First of all edit heap size in main.c
This step needs a bit of caution, because the interpreter needs RAM to work correctly, but you can try to grab a few kilobytes
// From 36Kb.... STATIC char heap[36 * 1024]; // to whoppy 44Kb STATIC char heap[44 * 1024];
Then we will liste all the C modules pre-compiled, using the help function:
>>> help('modules') __main__ hashlib socket upip _boot inisetup ssl upip_utarfile _onewire io struct urandom _webrepl json sys ure apa102 lwip time uselect array machine uasyncio/__init__ usocket binascii math uasyncio/core ussl btree micropython ubinascii ustruct builtins neopixel ucollections utime collections network ucryptolib utimeq dht ntptime uctypes uzlib ds18x20 onewire uerrno webrepl errno os uhashlib webrepl_setup esp port_diag uheapq websocket flashbdev random uio websocket_helper framebuf re ujson zlib gc select uos
Now the best way is to “scaffold” your micropython for the final target use. For instance I do not plan to use neopixel or frameuffers, because my little esp8266 will act like a server for tuning stuff on and off.
Also webrepl and websocket could be ripped off. At the end of my work, I ended with the following module list
__main__ io struct uos _boot json sys upip _onewire lwip time upip_utarfile apa102 machine uasyncio/__init__ urandom array math uasyncio/core ure binascii micropython uasyncio/queues uselect builtins network uasyncio/synchro usocket collections ntptime ubinascii ussl dht onewire ucollections ustruct ds18x20 os ucryptolib utime errno port_diag uctypes utimeq esp random uerrno uzlib flashbdev re uhashlib websocket gc select uheapq websocket_helper hashlib socket uio zlib inisetup ssl ujson
I have prepared a forked git hub repository with my hacks [3]: look at the daitan-hacks branch.
Download the ready made image!
- “Super Expander” version (Work in progress) 40Kb with basic uasyncio and no webrepl
- esp8266-experimental-v1.10.bin.zip Simpler version with asyncio and more RAM
Reference
[1] https://forum.micropython.org/viewtopic.php?t=4813
[2] Micropython reference
[3] GitHub source