recently start use Raspberry Pi PICO W with MicroPython via the THONNY IDE from RPI1, PC, Linux Laptop. The REPL is integrated in THONNY, but you can reach it also via a serial program like using picocom /dev/ttyACM0 -b115200
i run:
MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico W with RP2040
theREPL prompt is
>>>
if code running use [ctrl][c] to stop for restart use: [ctrl][d]
module.[tab] give a list of module entries ( like select time.localtime )
but shows ‘function’
and then need to add ()
help()
help(“modules”)
import sys
sys.implementation
(name=’micropython’, version=(1, 23, 0, ”), _machine=’Raspberry Pi Pico W with RP2040′, _mpy=4870)
sys.platform
‘rp2’
machine.freq()
125000000
import time
print(time.localtime()) or just time.localtime()
(2024, 9, 3, 9, 36, 27, 1, 247)
( how it knows this time ?RTC even after power reset? )
from machine import RTC
rtc = RTC()
rtc.datetime()
(2024, 9, 3, 1, 10, 0, 37, 0)
import ntptime
ntptime.host
‘pool.ntp.org’
dir()
[‘machine’, ‘thonny_result’, ‘__name‘, ‘__thonny_names’, ‘rp2’, ‘__thonny_helper’, ‘__thonny_name’]
filesystem:
import os
os.uname()
(sysname=’rp2′, nodename=’rp2′, release=’1.23.0′, version=’v1.23.0 on 2024-06-02 (GNU 13.2.0 MinSizeRel)’, machine=’Raspberry Pi Pico W with RP2040′)
os.listdir()
[‘lib’, ‘main.py’, ‘mqtt.py’, ‘multi_job.py’, ‘pio.py’, ‘secrets.py’, ‘wifi.py’, ‘wtime.py’]
%cd lib
os.listdir()
[‘micropython_umqtt.simple-1.3.4.dist-info’, ‘umqtt’]
%cd ..
______________________________________________
and let’s say there is any independent code file ‘test.py’
but after boot
main.py is running,
you can stop it with [ctrl][c]
get the >>> prompt
and type:
import test
______________________________________________
next level would be
https://docs.micropython.org/en/latest/reference/pyboard.py.html
so you could edit the files like ‘app.py on cmd / terminal with vim / nano
and execute them with
pyboard.py –device /dev/ttyACM0 app.py
and the prints come back..
the file is not copied to micropython file space
use for copy:
pyboard.py –device /dev/ttyACM0 -f cp main.py :
Leave a comment