1

member

Easy Basics: Project 083y Sipeed Maixduino board - Using MaixPy REPL interface and Micropython Editor

of Acoptex.com in Sipeed Maixduino

Basics: Project 083y

Project name: Sipeed Maixduino board - Using MaixPy REPL interface and Micropython Editor(pye)

Tags: Sipeed Maixduino Kit for RISC-V AI and IoT, seeedstudio, Artificial intelligence, AI, IOT, Internet of things, MaixPy, MicroPython, upload micropython script to sipeed maixduino board, how to format Micro SD more than 4GB card to FAT format, REPL interface, MaixPy REPL interface, Micropython Editor(pye)

Attachments: none

In this project, you need these parts :

1. Sipeed Maixduino Kit for RISC-V AI + IoT 1 pc or Sipeed Maixduino for RISC-V AI + IoT 1 pc

2. USB Type C cable 1 pc

3. Micro SD card and SD card adapter, size 4GB (FAT formatted) 1 pc

General

We will learn how to use MaixPy REPL interface, upload the micropython script to the Sipeed Maixduino board. 

About Seeed Studio

Seeed is the IoT hardware enabler providing services over 10 years that empower makers to realize their projects and products. Seeed offers a wide array of hardware platforms and sensor modules ready to be integrated with existing IoT platforms and one-stop PCB manufacturing and Prototype PCB Assembly. Seeed Studio provides a wide selection of electronic parts including ArduinoRaspberry Pi and many different development board platforms. Especially the Grove System help engineers and makers to avoid jumper wires problems. Seeed Studio has developed more than 280 Grove modules covering a wide range of applications that can fulfill a variety of needs. 

Understanding the MaixPy

MaixPy ported MicroPython to K210 (a 64-bit dual-core RISC-V CPU with hardware FPU and convolution accelerator). A project that supports MCU routine operations and integrates machine vision and microphone arrays to quickly develop intelligent applications in the AIOT field that are extremely cost effective and practical.

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.

K210 created for AIOT(AI+IOT) use, It's powerful performance and low cost are very competitive.

MicroPython makes programming on K210 hardware easier, the code is open source and can be found here.

Maixpy is a scripting language that is completely usable without the need for an IDE. This IDE is for make it easier to view images, pick colors, send files, etc on a computer. The Maixpy IDE is derived from the OpenMV IDE. Because the K210 does not support USB, it uses serial communication instead, so using Maixpy IDE will reduce the frame rate, or if you encounter other problems, please try to use the serial terminal instead.

MaixPy devices have an internal file system which can access both internal and external memories. During boot, the device will mount any external memory cards formatted with either SPIFFS or FAT file systems, and add them to the internal file system as the /flash or /sd directories respectively. SPIFFS cards are by default assigned to 3MB SPIFFS (starting at flash address 0xD00000). When detected at boot, SPIFFS devices automatically appear as the /flash directory within the device's internal file system. Currently the SPIFFS implementation in MaixPy does not support the creation of directories. FAT formatted SD (TF) cards are supported, but FAT32 or exFAT formatted cards are not currently supported. When detected at boot, FAT formatted cards will be automatically mounted and appear as the /sd directory in the device's internal file system. It should be noted that the root directory is only used to mount the SD card or SPIFFS flash card. All other file operations happen in the /flash or /sd directories, as determined by the format of the memory card discovered at boot time.

If a memory card formatted with either a SPIFFS or FAT file system is detected at boot, MaixPy will look for a boot.py file in the root directory of that memory card. If /boot.py is found, the system will immediately execute it. If the /boot.py file is not found, the device will automatically create one on the memory card that offers a basic REPL command line interface. Edit the contents of the /boot.py file on the memory card to determine what the device does when it is reset or rebooted. FAT memory cards will have a mount point of /sd, while SPIFFS cards will appear as /flash.

Understanding the Sipeed Maixduino board

You can read more about it here.

Signals and connections of the Sipeed Maixduino board


Maxduino pinout.



Espressif ESP32-WROOM-32 pinout.



Sipeed M1 pinout. See detailed description about pins here.

ADC - Analog to Digital Converter or Analog pins.This devepment board has 5.

GND - Ground pin.

RST - Reset pin.

Vin - External power supply pin 6V

I2C - It has dedicated pins available for two-wire I2C communication. One pin is used for data transfer (SDA) and another pin is used for clock synchronization (SCL). 

Pin 0, Pin 1 - hardware serial communication pins.

5V, 3V3 - power supply pins.

ESP32-WROOM-32 - ESP32-WROOM-32 module soldered to the development board. Optionally ESP32-WROOM-32D, ESP32-WROOM-32U or ESP32-SOLO-1 module may be soldered instead of the ESP32-WROOM-32.

Reset button - to reset the development board

BOOT button - to upload the firmware/sketch

USB type C port - USB interface. It functions as the power supply for the board and the communication interface between PC and the ESP module.

Wiring

Pay attention to the installation direction of the camera and screen, otherwise it may not work or damage the device. The camera is facing the back:

The screen is facing the front:


Step by step istruction

We are using the Sipeed Maixduino board and have Windows 7 64 bit OS installed on our PC.

1. Preparations

Please check in our Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy

2. Uploading the MaixPy to Sipeed Maixduino board

Please check in our Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy

3. Checking the MaixPy firmware on Sipeed Maixduino board

Please check in our Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy

4. How to install the FT2232 drivers

Please check in our Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy

5. How to format Micro SD card with more than 4GB side to FAT format

Please check in our Basics: Project 083f Sipeed Maixduino board - Using MycroPython

6. Using MaixPy REPL interface

MaixPy's REPL interface is simple and convenient for the small tasks but it soon becomes annoying to re-enter your code each time you want to run it. The solution is to save your code to a file, and then execute the file. We will show you both ways in this project.

  1. We assume that you have PuTTY installed in your PC/laptop and MaixPy firmware uploaded to your Sipeed Maixduino board.
  2. Open PuTTY app and open connection with Sipeed Maixduino board. 
  3. Press the Sipeed Maixduino board on-board Reset button to reboot it. You will see the welcome screen. 
  4. If you type help() you will see the REPL Control commands: CTRL-A - on a blank line, enter raw REPL mode; CTRL-B - on a blank line, enter normal REPL mode; CTRL-C  - interrupt a running program; CTRL-D - on a blank line, do a soft reset of the board; CTRL-E - on a blank line, enter paste mode.
  5. In MaixPy's REPL interface and in code the following os commands can be used to navigate directories and manage files: 
  6. You can find the complete list of os commands here.
  7. If you enter code directly in the terminal at the Maix prompt it will be executed immediately upon pressing the Enter button on your keyboard. Such interactive command line interfaces are often referred to as REPL(Read Eval Print Loop). MaixPy's REPL interface operates similar to most other command line interfaces except that the supported syntax is MicroPython.
  8. MaixPy includes a built-in open source editor Micropython Editor(pye). Keyboard shortcuts and other instructions can be found here
  9. At the MaixPy prompt type pye("hello.py") command to create a file and enter the edit mode.
  10. Type the following code: print("hello world!!!)

  11. When you finish editing, press Ctrl + S buttons on your keyboard and then press Enter button on your keyboard to save.
  12. Press Ctrl + Q buttons on your keyboard to exit the editor.
  13. The pye editor has certain requirements of the connected terminal. For intuitive operation the BackSpace key should be configured to send Ctrl + ?, otherwise the BackSpace key will function as Ctrl + H (ie: character replacement).
  14. If you are Windows user use PuTTY which supports Backspace key configuration. Typing Shift-Backspace will cause PuTTY to send whichever code isn't configured as the default.
  15. t MaixPy's REPL interface simply enter: import hello then press Enter
    The hello.py file will run and should output hello maixpy
    But be careful, the import command can only be used once. If you want to execute the code more than once
    If you want to run the script hello.py simply type: import hello command in the MaixPy prompt and then press Enter button on your keyboard. The hello.py file will run and should output hello world!!!
  16. Be careful, the import command can only be used once. If you want to execute the code more than once use exec()  in a simple program to execute your file: with open("hello.py") as f: exec(f.read())

Summary

We have learnt how to use MaixPy REPL interface, upload the micropython script to the Sipeed Maixduino board. 

More projects with Sipeed Maixduino board

Project 083f Sipeed Maixduino board - Using MycroPython

Project 083e Sipeed Maixduino board - Uploading MaixPy

Project 083x Sipeed Maixduino board - Uploading script with uPyLoader

Project 083w Sipeed Maixduino board - Using PlatformIO IDE

Project 083d Sipeed Maixduino Kit for RISC-V AI and IoT

Libraries

  • No libraries required for this project

Script

  • None


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

Published at 07-08-2019
Viewed: 5278 times