Skip to content

Latest commit

 

History

History
120 lines (84 loc) · 2.83 KB

SETUP.md

File metadata and controls

120 lines (84 loc) · 2.83 KB

Setup

Setup the development environment and the MicroPython board


Development environment

This section describes the necessary steps on the computer to get ready to test and run the examples.

Update submodule

brainelectronics python modules submodule have to be cloned as well. A standard clone command won't clone the submodule.

git submodule update --init --recursive
cd modules
git fetch

# maybe checkout a newer version with the following command
git checkout x.y.z

# or use the latest develop branch
git checkout develop
git pull

Install required tools

Python3 must be installed on your system. Check the current Python version with the following command

python --version
python3 --version

Depending on which command Python 3.x.y (with x.y as some numbers) is returned, use that command to proceed.

python3 -m venv .venv
source .venv/bin/activate

pip install -r requirements.txt
pip install -r modules/requirements.txt

MicroPython

This section describes the necessary steps on the MicroPython device to get ready to test and run the examples.

Flash firmware

Flash the MicroPython firmware to the MicroPython board with this call

esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART erase_flash
esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART --baud 921600 write_flash -z 0x1000 esp32spiram-20220117-v1.18.bin

Install package with pip

Connect to a network

import network
station = network.WLAN(network.STA_IF)
station.connect('SSID', 'PASSWORD')
station.isconnected()

and install this lib on the MicroPython device like this

import upip
upip.install('micropython-modbus')

Without network connection

Copy the module to the MicroPython board and import them as shown below using Remote MicroPython shell

Open the remote shell with the following command. Additionally use -b 115200 in case no CP210x is used but a CH34x.

rshell -p /dev/tty.SLAB_USBtoUART --editor nano

Perform the following command to copy all files and folders to the device

mkdir /pyboard/lib
mkdir /pyboard/lib/umodbus

cp umodbus/* /pyboard/lib/umodbus