
InventOne & MicroPython
What you will learn
This tutorial will teach you how to install a python(micro) interpreter on the inventone board. You’d also learn how to program the board using micropython. Note that micropython has essentially the same syntax as python except that micropython as the name implies has limited resource as compared to the normal python.
Requirement
- Laptop
- Esp flash download tool (Windows users)
- esptool (linux, mac)
- InventOne board
- Serial monitor (picocom suggested)
- Internet
- USB type B code
Difficulty
Easy
Introduction
Being able to use the python interpreter on a microcontroller is something I find really exhilarating, it’s more like having a mini computer (at a very low cost) with exposed GPIO pins unlike the conventional intel processors whose pins are not accessible.
Step I
Firstly, you need to download the bin file for the micropython interpreter, http://micropython.org/resources/firmware/esp8266-20190125-v1.10.bin.

This gives you the latest stable release of micropython interpreter. Upon successfully downloading the interpreter you need to burn it into inventone.
Step II
I’d divide this section into two: The first for people using windows and the next for linux users.
Windows:
For windows users, you can use any of this tools to flash(upload) a bin file to inventone:
- Nodemcu flasher
- ESP flash download tool
Click on either of the tools above to take you to a tutorial on this same blog about using the selected tool to flash inventone.
Linux:
For linux I’m only aware of esptool which is the official flash tool provided for esp8266 (the native microcontroller on inventone). Check out this tutorial on how to upload bin files using esptool, if you are already conversant with uploading bin files just run:
$ esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 <DirectoryTo/esp8266-20190125-v1.10.bin>

Step III
You’d be communicating with the board via UART(USB) so you need a serial monitor. For linux users I recommend picocom, it runs directly from terminal. Windows users can download any of this great serial monitors (putty, termite…).
Terminal command to get picocom:
$ sudo apt-get install picocom

The default baud rate for the interpreter is 115200 , hence set your serial monitor baud rate to 115200 and you can leave the other settings as default.
Step IV
After powering up your serial monitor and completing the appropriate configurations, connect your serial monitor to the board. For picocom just run:
$ picocom /dev/ttyUSB0 -b115200

This should get your terminal connected to inventone (please ensure that you’ve connected the board to your laptop (desktop) via a usb cable before running the above command).
Windows users should see a connect button on whatever serial monitor the are using click on it and you’d be connected to inventone (also ensure the board is connected to the laptop via a usb cable before doing this).
Step V
Once you are connected, press enter twice and you’d see the standard python interpreter interface (>>>).

Well done you are officially programming in python on inventone. Run this commands to perform a demo on the in-built led on inventone.
>>> import machine
>>> from machine import Pin
>>> import time
>>> p = Pin (2, Pin.OUT)
>>>
>>> def pin_demo (timer):
… while True:
… p.value (not p.value())
… time.sleep_ms (timer)
…
>>> pin_demo (500)
>>>
The above snippet should blink the inbuilt led on the ESP chip on inventone. Press ctrl + C to interrupt the process.
Star Wars Demo
Configure the board to connect to your router, then perform this star wars demo.
>>> import network
>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.active(True)
>>> sta_if.connect('<your SSID>', '<your password>') //Input your wifi ssid and password
>>> sta_if.isconnected()
>>> import socket
>>> addr_info = socket.getaddrinfo("towel.blinkenlights.nl", 23)
>>> addr = addr_info[0][-1]
>>> s = socket.socket()
>>> s.connect(addr)
>>> while True:
... data = s.recv(500)
... print ( str (data, 'utf8'), end=' ')
…

Enjoy!!!!
Conclusion
This tutorial has given you an oversimplified use of micropython on the inventone board, that is because I want you to enjoy your first time programming the board with python. There are a lot of things you could implement this, note that the star-wars animation you see comes directly from the internet. Hence, you could have a lot of high computation somewhere on the internet and you’d make use of the result of such computations to control the board.
I’m talking of machine learning algorithms, computer vision algorithms, and the likes. I look forward to hearing from you, do well to comment on this tutorial and please share with your friends.