MicroPython
UNIHIKER K10 with MicroPython¶
MicroPython is a Python interpreter that runs on microprocessors, enabling us to write Python scripts to control hardware. It is highly consistent with the standard Python interpreter (CPython) in terms of syntax and runs on microprocessors with limited resources. In this tutorial, we will guide you through the process of downloading and installing MicroPython and it's IDE "Thonny" on your computer.

Download¶
Note
Before using micropython to program the UNIHIKER K10, the Micropython firmware has to be uploaded into the UNIHIKER K10.
Flash Download Tool now only support on Windows. MacOS/GNU Linux user can flash firmware by ESP LAUNCHPAD.
The MicroPython Firmware and Thonny support Windows/MacOS/GNU Linux.
| Download | |
|---|---|
| MicroPython Firmware: | Google Drive Download |
| Flash Download Tool(Only support windows): | Click to download |
| ESP LaunchPad(Web Tool For All OS): | Click to visit |
| Thonny | Click to download |
Note
The Micropython firmware for the Unihiker K10 is currently in the early access phase, and we are actively developing its AI-related features. You can find the current version of the Micropython source code in this GitHub repository.
Flash MicroPython Firmware on Windows¶
-
Click to open the Flash Download Tool, then choose the ESP32-S3.

-
Select the firmware and fill up the address with 0x00, then click on √.

-
Press and hold the BOOT button on the back of K10, connect the board to the computer and select the corresponding port in the software.
- First click "ERASE" to clear the flsh, and then click "START" to flash the firmware after ERASE step is successful.
- Press the RST reset button on the K10 board after the flash is completed.
Flash MicroPython Firmware on Mac/GNU Linux¶
- Visit ESP LAUNCHPAD
- Press and hold the BOOT button on the back of K10, connect the board to your Mac/PC then release BOOT button.
- Click "connect" to choose the port.

- Enter the "DIY" page and choose the .bin firmware which downloaded from Google Drive.
- Change the Flash Address into 0x00
- Click "Program" to flash firmware.

Coding¶
- Open up Thonny as the MicroPython Editor.
from unihiker_k10 import screen,camera,tf_card,
from unihiker_k10 import temp_humi,light,acce
from unihiker_k10 import rgb,button
from unihiker_k10 import mic,speaker
import time
#Init display and set the display direction(0~3)
screen.init(dir=2)#direction default to be 2
camera.init()#Init camera
#On board LED
rgb.write(num = 0, R=255,G=0,B=0)
rgb.write(num = 1, R=0,G=255,B=0)
rgb.write(num = 2, R=0,G=0,B=255)
time.sleep(1)
rgb.clear()
#Start record voice, save the audio file into the ESP32 file system then play the audio
screen.draw_text(text="begin sys recode",line=0)
screen.show_draw()
mic.recode_sys(name="sound.wav",time=5)
screen.draw_text(text="recode sys done",line=0)
screen.show_draw()
time.sleep(1)
screen.draw_text(text="begin sys play",line=0)
screen.show_draw()
speaker.play_sys_music("sound.wav")
screen.draw_text(text="end sys play",line=0)
screen.show_draw()
time.sleep(1)
#Display the camera image onto the screen
screen.show_camera(camera)
bt_a=button(button.a)#Init on board button A
bt_b=button(button.b)#Init on board button B
def button_a_pressed():
screen.draw_text(text="btn_a:pressed",line=5)
screen.show_draw()
def button_a_released():
screen.draw_text(text="btn_a:released",line=5)
screen.show_draw()
def button_b_pressed():
screen.draw_text(text="btn_b:pressed",line=6)
screen.show_draw()
def button_b_released():
screen.draw_text(text="btn_b:released",line=6)
screen.show_draw()
bt_a.event_pressed = button_a_pressed
bt_a.event_released = button_a_released
bt_b.event_pressed = button_b_pressed
bt_b.event_released = button_b_released
while True:
screen.draw_text(text="temp=" + str(temp_humi.read_temp()) + " humi=" + str(temp_humi.read_humi()),line=0)
screen.show_draw()
screen.draw_text(text="light=" + str(light.read()) ,line=1)
screen.show_draw()
screen.draw_text(text="ax=" + str(acce.read_x()),line=2)
screen.show_draw()
screen.draw_text(text="ay=" + str(acce.read_y()),line=3)
screen.show_draw()
screen.draw_text(text="az=" + str(acce.read_z()),line=4)
screen.show_draw()
time.sleep(0.1)
-
CTRL+S to save to micropython device. Choose to save to This computer is also fine, but if the program save to local computer, the program will be lost after K10 was reboot, it is more suitable for saving to the computer when debugging.

MicroPython Example¶
Cklik to the MicroPython Example.
Flash back to Arduino C firmware¶
The original firmware for K10 is ArduinoC firmware, supports development in Arduino environments such as Mind+/Arduino IDE. If you want to switch back to Arduino development after using MicroPython, we offer the following two methods for you to flash the Arduino C firmware:
Method 1
Restore the device to the factory Arduino firmware in Mind+.
Note
Mind+ is only support windows for now.
Method 2
For the MacOS/GNU Linux user the Arduino C firmware can be flash back by using the Arduino IDE.
- Download and configure Arduino IDE by following this tutorial.
- Choose the model as "EN".

- Upload an empty program, like this one:




