Files
led-fan/test/README.md
T

2.1 KiB
Raw Blame History

Device tests

These scripts run on the board with MicroPython, not on the host. Use mpremote from the repo root (pipenv sync first).

Replace PORT with your serial device, e.g. /dev/ttyACM0 or /dev/ttyUSB0. List ports with ls /dev/ttyACM* /dev/ttyUSB* or pipenv run mpremote connect list.

Stop the main app first

If src/main.py is already on the board it starts on boot and will fight the tests (WiFi, I2C, LEDs). Interrupt it, then run the test:

pipenv run mpremote connect PORT

In the REPL press Ctrl-C until you get >>>. Leave that session, or use a second command as below.

Copy libraries (needed for Microdot / LSM6DS3)

mpremote run only uploads the one test file. Anything it imports must already live on the board.

pipenv run mpremote connect PORT fs cp -r lib :

Same as pipenv run ./dev.py PORT lib.

Run a test

From the repo root:

pipenv run mpremote connect PORT run test/leds.py
pipenv run mpremote connect PORT run test/lsm6ds3_test.py
pipenv run mpremote connect PORT run test/ap_microdot.py

run copies the file to the device, executes it, and streams stdout. Ctrl-C stops it.

Access-point + Microdot (ap_microdot.py)

Starts a soft-AP (led-test, open by default) and a small HTTP app.

  1. Upload lib (so microdot imports).
  2. pipenv run mpremote connect PORT run test/ap_microdot.py
  3. Join the led-test WiFi network from a phone or laptop.
  4. Open http://192.168.4.1/ (plain text hello) or http://192.168.4.1/ping (JSON).

SSID/password are at the top of ap_microdot.py. Default AP address on ESP32 is 192.168.4.1.

Other useful mpremote commands

pipenv run mpremote connect PORT                         # REPL
pipenv run mpremote connect PORT fs ls :                 # list board files
pipenv run mpremote connect PORT fs cp test/leds.py :    # copy a file onto the board
pipenv run mpremote connect PORT exec "import leds"      # run a file already on the board

If the port is already in use (another mpremote, serial monitor, or dev.py follow), disconnect that first.