SlideShare a Scribd company logo
Command your IoT Projects
from the Terminal
Terminal Setup
Apple
Mac Studio
M1 Ultra
Apple
iPad Pro M1
Magic Keyboard
Portable Monitor
Keyboard Mouse
SSH Client
(terminal)
VNC Client
(remote desktop)
UVC Client
(video capture)
USB-A
USB-C
Ethernet
Micro-USB
HDMI
Mini-USB
USB-B
SSH
(network)
VNC
(network)
HDMI
(wired)
OTG
(gadget)
Wi-Fi
CONNECT
(service)
Raspberry
Pi 5
RP2040
BMP280
I²C
/tty/ACM0
BOOTSEL
Connect
(service)
What exactly is a Terminal?
print a line, scroll up
type a line, scroll up
RS-232
Raspberry
Pi 5
SERIAL
USB
BMP280
JST SH
Serial I²C
Raspberry
Pi 5
HDMI
USB JST SH
Serial I²C
Raspberry
Pi 5
USB JST SH
Serial I²C
HDMI
Portable/Desktop
Monitor
Keyboard Mouse
Video Capture Card
HDMI
HDMI
RS-232
DEC VT320
ESP32-S3
SAMD21
RP2040
BH1750
LSM
303AGR
But wait what about Terminal Emulators?
macOS Terminal kitty iTerm 2
ghostty Prompt 3 Terminus
Apple Mac
Studio Ultra M1
Raspberry
Pi 5
VNC
CAT5 USB
RP2350
JST SH
Serial I²C
Apple
MacBook Pro
M1
Raspberry
Pi 5
SSH
USB
RP2040
JST SH
Serial I²C
Wi-Fi
Apple
iPad Pro M1
Magic Keyboard
Raspberry
Pi 5
USB
nRF52840
GROVE
Serial I²C
OTG
(gadget)
USB-C
VEM
L7700
VCNL4040
SHT41
Then what exactly is the shell?
POSIX
BASH
SH
FISH
KSH
CSH
PWSH
REPL
Ken Thompson
Raspberry Pi
Raspberry Pi Imager
rpilocator.com
Raspberry Pi Config
SSH*
RPi Connect*
VNC
I2C
Expand Filesystem
Boot Order*
Wireless LAN*
Hostname
Raspberry Pi Connect
sudo apt update
sudo apt full-upgrade
sudo apt install rpi-connect
sudo apt install rpi-connect rpi-connect-lite
sudo reboot
systemctl --user start rpi-connect
rpi-connect signin
NOTE:
fi
nish the rest of the setup via any browser on some other computer, laptop, phone or tablet…
Complete sign in by visiting
https://connect.raspberrypi.com/verify/XXXX-XXXX
Raspberry Pi USB Gadget
Raspberry Pi Forums - Topic 376578
https://forums.raspberrypi.com/
viewtopic.php?t=376578
• Edit ‘con
fi
g.txt’ and ‘cmdline.txt’ per instructions in the topic’s post…
• Download/edit/run script in the topic’s post…
• Reboot, check with ifconfig…
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.133.86 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::15dd:9047:cee6:391b prefixlen 64 scopeid 0x20<link>
ether ea:46:11:1b:0b:c1 txqueuelen 1000 (Ethernet)
RX packets 284 bytes 46679 (45.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 326 bytes 285229 (278.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
phattmatt
Raspberry Pi USB Gadget
phattmatt
OTG
sudo ip link set eth0 down
sudo ip link set wlan0 down
arp -a | grep :
arp -a | grep bridge
ssh ggeoffre@192.168.2.10
Raspberry Pi HDMI Output
USB to HDMI
Video Capture
MacBook Raspberry Pi
QuickTime > New Movie Recording > USB Video
OBS > Video Capture Device Source
Raspberry Pi RS-232 Output
WYSE PI
USB to Serial
adapter
9-pin to 25-pin
adapter
9-pin Null Modem
adapter
ls /dev/*USB* | grep tty
sudo systemctl enable serial-getty@ttyUSB0.serviceminicom
https://www.youtube.com/watch?v=xQTr9ZOJkC0
Modern Linux on a Wyse Terminal
Visual Studio Code - Remote SSH
https://code.visualstudio.com/docs/remote/ssh-tutorial
Install
Visual Studio Code Remote
SSH / Editing Con
fi
guration Files / Explorer
Connect
from the Command Palette
select Remote-SSH: Connect to Host...
Work
Remotely Edit Files
understands ‘remote’ versioning
Visual Studio Code - Remote Development Over SSH
Fonts and Colors
True Type Font Terminal Font
grep -n FONTFACE /etc/default/console-setup
echo $TERM; sudo showconsolefont -Vvi
sudo dpkg-reconfigure console-setup
ls /usr/share/consolefonts/*.psf.gz
setfont /usr/share/consolefonts/*.psf.gz
# CONFIGURATION FILE FOR SETUPCON
ACTIVE_CONSOLES="/dev/tty[1-6]"
CHARMAP="UTF-8"
CODESET="guess"
FONTFACE="Terminus"
FONTSIZE="16x32"
Fonts and Colors
https://gitlab.com/protesilaos/tempus-themes
https://iterm2colorschemes.com/
WCAG - accessibility standard for color contrast
• AA minimum contrast ratio of 4.50:1
• AAA minimum contrast ratio of 7.00:1
Tempus Autumn (WCAG AA) Tempus Tempest (WCAG AA) Tempus Warp (WCAG AA)
Fonts and Colors
if [ "$TERM" = "linux" ]; then
echo -en "e]P0001514" #black
echo -en "e]P1ff3737" #darkred
echo -en "e]P2169c16" #darkgreen
echo -en "e]P39f8500" #brown
echo -en "e]P45781ef" #darkblue
echo -en "e]P5da4ebf" #darkmagenta
echo -en "e]P6009880" #darkcyan
echo -en "e]P7968282" #lightgrey
echo -en "e]P8261c2c" #darkgrey
echo -en "e]P9F0681A" #red
echo -en "e]PA3aa73a" #green
echo -en "e]PBba8a00" #yellow
echo -en "e]PC8887f0" #blue
echo -en "e]PDd85cf2" #magenta
echo -en "e]PE1da1af" #cyan
echo -en "e]PFa29fa0" #white
clear #for background artifacting
fi
~/.bashrc color_test.sh
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m'
'1;31m' ' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m'
' 35m' '1;35m' ' 36m' '1;36m' ' 37m' ' 1;37m';
do
FG=${FGs// /};
echo -en " $FGs 033[$FG $T ";
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do
echo -en "$EINS 033[$FG033[$BG Text 033[0m";
done;
echo;
done
What is an IoT Project?
Microcontroller Electronic Circuits
PROGRAM A
TO CONTROL
chip pins protocols
boards platforms
connectors
boards pins chips
MicroPython Python
Platforms
Arduino C/C++
CircuitPython Python
Pico SDK C/C++
ESP-IDF C/C++
MULTI
SINGLE
pyboard
arduino-cli
cmake/make
idf.py
Runtimes
INTERPRETED
COMPILED
pyboard
arduino-cli
cmake/make
idf.py
Python
C/C++
Python
C/C++
C/C++
MicroPython
Arduino
CircuitPython
Pico SDK
ESP-IDF
Unexpected Maker ProS3 ESP32-S3
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
Raspberry Pi Pico W RP2040
•Pico-SDK
•Arduino
•MicroPython
•CircuitPython
Arduino Nano Every ATMega4809
•Arduino
RP2350
Pimoroni Tiny2350
•Pico-SDK
•Arduino
•CircuitPython
nRF52840
seeed XAIO nRF52840
•Arduino
•MicroPython
•CircuitPython
Adafruit M0 Express ATSAMD21
•Arduino
•MicroPython
•CircuitPython
STM32
SparkFun Thing Plus
•Arduino
•CircuitPython
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
ESP3
2­
-S
3­
-DevKitC-1 ESP32-S3
BMP280
BOSH
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
MPU6050
TDK
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
ADXL345
ANALOG
DEVICES
•Arduino
•CircuitPython
ADT7410
•Arduino
•MicroPython
•CircuitPython
TSL2591
AMS
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
VL53L4CX
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
•Arduino
•PIMORONI
BH1750
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
BOSH
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
ANALOG
DEVICES
LIS3MDL
•Pico-SDK
•ESP-IDF
•Arduino
•MicroPython
•CircuitPython
TDK
VCNL4040
•Arduino
•CircuitPython
Command Workflow
• Platform tools install/update
• Boards/Cores set/install
• Project create (optional)
• Libraries import/download/install/add
• Source Code edit/make/compile
• App deploy/copy/upload
• Output monitor
Pi Directory Structure
/home/$USER/iot
./bin
./arduino
./circuitpython
./esp
./micropython
./pico
./python
$IOT
/home/$USER/iot
./work
./arduino
./circuitpython
./esp-idf
./micropython
./pico
$WORK
Python Directory Structure
/media/$USER/CIRCUITPY
./code.py
./lib
CIRCUIT
./boot.py
./lib
MICRO
/dev/ttyACM0*
NOTE: must use PyBoard.py
NOTE: cannot use PyBoard.py
/dev/ttyACM0 /dev/ttyACM0
PY_BOARD=$IOT/circuitpython/tools/pyboard.py
PY_BOARD=$IOT/micropython/tools/pyboard.py
Arduino - Installation
Google search "arduino cli installation"
https://arduino.github.io/arduino-cli/
1.0/installation/
cd $IOT; mkdir $IOT/arduino; cd ./arduino
curl -fsSL https://raw.githubusercontent.com/
arduino/arduino-cli/master/install.sh | sh
NOTE: This script will install the latest version of Arduino CLI to $PWD/bin
Arduino - Check Status
arduino-cli version
git ls-remote --tags https://github.com/
arduino/arduino-cli | tail -1
arduino-cli config dump
arduino-cli core list
arduino-cli lib list
arduino-cli outdated
Arduino - Update
arduino-cli core update-index
arduino-cli core upgrade
arduino-cli lib update-index
arduino-cli lib upgrade
arduino-cli update
arduino-cli upgrade
cd $IOT/arduino
curl -fsSL https://raw.githubusercontent.com/
arduino/arduino-cli/master/install.sh | sh
NOTE: This script will install the latest version of Arduino CLI to $PWD/bin:
Arduino - Board Support
arduino-cli config add
board_manager.additional_urls https://
adafruit.github.io/arduino-board-index/
package_adafruit_index.json
arduino-cli core update-index
arduino-cli board search adafruit | grep samd
arduino-cli core install adafruit:samd
arduino-cli board listall samd
arduino-cli board details -b
adafruit:samd:adafruit_sht4xtrinkey_m0
Arduino - Create Project
cd $WORK/Arduino
arduino-cli sketch new trinkey_neopixel_blink
Arduino - Edit Code
nano $WORK/Arduino/trinkey_neopixel_blink.ino
Arduino - Compile/Upload
arduino-cli compile -vu -b
adafruit:samd:adafruit_sht4xtrinkey_m0 $WORK/
Arduino/trinkey_neopixel_blink -p /dev/ttyACM0
Arduino - Monitor
arduino-cli monitor -p /dev/ttyACM0
minicom -D /dev/ttyACM0
Arduino - Libraries
arduino-cli lib list
arduino-cli lib search {$SEARCH}
arduino-cli lib download “{$NAME}”
arduino-cli lib install “{$NAME}”
arduino-cli lib update-index
arduino-cli lib upgrade
BMP280
Arduino - Demo
cd $IOT/work/arduino
ls /dev/serial/*;
find /sys/bus/usb/devices/usb*/ -name dev | grep tty
arduino-cli board listall rp2040 | grep "Raspberry Pi"
cat ./blink/blink.ino
arduino-cli compile -vu -b rp2040:rp2040:rpipico2
$IOT/work/arduino/blink -p /dev/ttyACM0
arduino-cli monitor -p /dev/ttyACM0
minicom -w -D /dev/ttyACM0
Pico C/C++ SDK - Installation
Google search "pico c/c++ sdk"
https://www.raspberrypi.com/
documentation/microcontrollers/c_sdk.html
sudo apt install cmake gcc-arm-none-eabi libnewlib-
arm-none-eabi build-essential g++ libstdc++-arm-none-
eabi-newlib
cd $IOT; wget https://raw.githubusercontent.com/
raspberrypi/pico-setup/master/pico_setup.sh;
chmod +x pico_setup.sh; ./pico_setup.sh
NOTE: This script will install the latest version of Pick C/C++ SDK to $IOT/pico
TOOL
CHAIN
Pico C/C++ SDK - Check Status
for PICO_REPO in $(ls $IOT/pico/);
do
cd $IOT/pico/$PICO_REPO;
git fetch ; git status;
done
ls $IOT/pico
pico-sdk openocd debugprobe picotool
pico-extras pico-examples pico-playground
NOTE: Repeat for each repository…
which picotool; picotool version;
git ls-remote --tags $(cd $IOT/pico/picotool;
git config --get remote.origin.url) | tail -1
Pico C/C++ SDK - Update
PICO-REPO=$(ls -d $IOT/pico); echo $PICO-REPO
pico-sdk openocd debugprobe picotool
pico-extras pico-examples pico-playground
NOTE: Repeat for each repository…
cd $IOT/pico/$PICO-REPO
git fetch ; git status
git submodule update --recursive --remote
git restore . --recurse-submodules
git clean -df -f
git pull
git submodule update
git fetch ; git status
Pico C/C++ SDK - Board Support
udevadm info -q all -n /dev/ttyACM0
NOTE: Board must be in BOOTSEL mode
NOTE: Board must be in USB Drive mode
ls $IOT/pico/pico-sdk/src/boards/include/boards/
sudo $IOT/pico/picotool/build/picotool info -a
Pico C/C++ SDK - Create Project
cd $IOT/work/pico;
mkdir HelloWorld; cd HelloWorld
touch HelloWorld.c
touch CMakeLists.txt
Pico C/C++ SDK - Edit Code
nano HelloWorld.c
nano CMakeLists.txt
Pico C/C++ SDK - Compile/Upload
rm -rf ./build; mkdir build; cd build
export PICO_SDK_PATH=$IOT/pico/pico-sdk
cmake -DPICO_BOARD=adafruit_feather_rp2350 ..
Pico C/C++ SDK - Monitor
minicom -D /dev/ttyACM0
⟳
make -j4 ; ls *.uf2 ; ls /media/$USER
cp *.uf2 /media/$USER/RP2350/
Pico C/C++ SDK - Libraries
ls $IOT/pico/pico-examples/i2c
https://forums.raspberrypi.com/viewtopic.php?t=305620
STICKY: Community library list for Pi Pico SDK C/C++
Topic ID: 305620
Pico C/C++ SDK - Demo
cd $IOT/work/pico/blink
ls $IOT/pico/pico-sdk/src/boards/include/boards
picotool info -a -F
cat blink.c
cat CMakeLists.txt
rm -rf ./build && mkdir build && cd build && pwd
cmake -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350 ..
make -j4
picotool load blink.uf2 -f
picotool reboot -a
minicom -w -D /dev/ttyACM0
ESP-IDF - Installation
Google search "esp-idf"
https://idf.espressif.com/
sudo apt install git wget flex bison gpref python3
python3-venv cmake ninja-build ccache libffi-dev
mkdir $IOT/esp && cd $_; git clone --recursive
https://github.com/espressif/esp-idf.git
cd $IOT/esp/esp-idf; ./install.sh
python -m pip install --upgrade esptool --break-
system-packages
TOOL
CHAIN
ESP-IDF - Check Status
cd $IOT/esp-idf
. ./export.sh
python -m esptool version
git ls-remote --tags https://github.com/
espressif/esptool | tail -1
idf.py —version
git ls-remote --tags https://github.com/
espressif/esp-idf | tail -1
NOTE: Run Every Time
To Set Up Environment
ESP-IDF - Update
cd $IOT/esp-idf; ./install.sh
python -m pip install --upgrade esptool --break-
system-packages
cd $IOT/esp/$ESP-REPO
git fetch ; git status
git submodule update --recursive --remote
git restore . --recurse-submodules
git clean -df -f
git pull
git submodule update
git fetch ; git status
ESP-IDF - Board Support
python -m esptool -p /dev/ttyACM0 chip_id
idf.py —list-targets
idf.py set-target esp32s3
idf.py menuconfig
ESP-IDF - Create Project
cd $IOT/work/esp-idf/
. $IOT/esp-idf/export.sh; idf.py --version
idf.py create-project blink-led
ESP-IDF - Edit Code
nano ./main/blink-led.c
ESP-IDF - Compile/Upload
idf.py --list-targets
idf.py set-target esp32s3
idf.py menuconfig
idf.py build
idf.py /dev/ttyUSB0 flash
ESP-IDF - Monitor
idf.py monitor
NOTE: Ctrl-] will exit the monitor
ESP-IDF - Libraries
cd $IOT/esp; git clone --recursive https://
github.com/UncleRus/esp-idf-lib.git
ls $IOT/esp/esp-idf-lib/components
Uncle Russ
ESP-IDF - Demo
cd $IOT/work/esp-idf/blink-led
ls /dev/serial/* && find /sys/bus/usb/devices/
usb*/ -name dev | grep tty
idf.py --list-targets
python -m esptool -p /dev/ttyACM0 chip_id
cat ./main/blink-led.c
cat ./main/CMakeLists.txt
idf.py set-target esp32s3
idf.py build
idf.py -p /dev/ttyACM0 flash monitor
CircuitPython - Installation
Google search “circuitpython"
https://circuitpython.org/
sudo apt install build-essential libffi-dev git
pkg-config cmake gcc-arm-none-eabi
libnewlib-arm-none-eabi build-essential
cd $IOT; git clone https://github.com/adafruit/
circuitpython.git
python -m pip install --upgrade circup --break-system-
packages
TOOL
CHAIN
CircuitPython - Check Status
find /sys/bus/usb/devices/usb*/ -name dev | grep tty
lsblk; ls -laR /media/*; mount | grep media
IOT_USB_SERIAL=ttyACM0
sudo ~/iot/pico/picotool/build/picotool info -aF
python -m esptool -p /dev/$IOT_USB_SERIAL chip_id
udevadm info -q all -n /dev/$IOT_USB_SERIAL
minicom -w -D /dev/$IOT_USB_SERIAL
>>> import board
>>> dir(board)
picotool reboot
python3 $PY_BOARD -c 'print("Hello World")'
python3 $PY_BOARD -c 'import board; print(dir(board))'
CircuitPython - Check Status
CircuitPython
Pico-SDK
Press and HOLD
Pull Pin 30 to GND
Then RELEASE
CircuitPython - Check Status
Press and HOLD
Pull Pin 30 to GND
Then RELEASE
GND
3V3
CircuitPython - Update
cd $IOT/circuitpython
git fetch ; git status
git submodule update --recursive --remote
git restore . --recurse-submodules
git clean -df -f
git pull
git submodule update
git fetch ; git status
python -m pip install --upgrade circup --break-system-
packages
CircuitPython - Board Support
https://circuitpython.org/downloads
wget -q -O - https://circuitpython.org/board/
raspberry_pi_pico2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' |
grep org.bin | grep en_US | sort -u | tail -1 | tr -d '"'
ls -d $IOT/circuitpython/ports/*/boards/*/
wget $(wget -q -O - https://circuitpython.org/board/
raspberry_pi_pico2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep
org.bin | grep en_US | sort -u | tail -1 | tr -d '"') -P $IOT/bin
CircuitPython - Demo (board setup)
picotool load $IOT/bin/adafruit-circuitpython-raspberry_pi_pico2-
en_US-9.2.2.uf2 -F
picotool reboot -a
wget -q -O - https://circuitpython.org/board/raspberry_pi_pico2/ |
grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep raspberry_pi_pico2 |
grep en_US
wget https://downloads.circuitpython.org/bin/raspberry_pi_pico2/
en_US/adafruit-circuitpython-raspberry_pi_pico2-en_US-9.2.2.uf2 -P
$IOT/bin
picotool erase -f
ls /dev/serial/*;
find /sys/bus/usb/devices/usb*/ -name dev | grep tty
ls -d $IOT/circuitpython/ports/*/boards/*/ | grep -i pico
CircuitPython - Edit Code
cd $IOT/work/circuitpython/pico
nano hello_world.py
CircuitPython - Run Code
python3 $PY_BOARD hello_world.py
CircuitPython - Upload Code
cp hello_world.py /media/$USER/CIRCUITPY/code.py
CircuitPython - Monitor
minicom -w -D /dev/ttyACM0
CircuitPython - Demo (run code)
PY_BOARD=$IOT/circuitpython/tools/pyboard.py
python3 $PY_BOARD -c 'print("Hello World")'
minicom -w -D /dev/ttyACM0
>>> print("Hello World”)
cd $IOT/work/circuitpython/pico
cat map_pins.py
python3 $PY_BOARD map_pins.py
cat scan_i2c.py
python3 $PY_BOARD scan_i2c.py
CircuitPython - Libraries
cd $IOT/work/circuitpython/pico
cp /media/$USER/CIRCUITPY/boot_out.txt .
ls $IOT/work/circuitpython/pico/lib
circup show
circup --path . list
circup --path . update --all
circup --path . freeze
circup show
circup install adafruit_bme280
CircuitPython - Demo (libraries)
SERIAL
ls /dev/serial/*;
find /sys/bus/usb/devices/usb*/ -name dev | grep tty
STORAGE
lsblk | grep -E "sd[a-zA-Z][0-9]";
ls -laR /media/*
MOUNT
sudo mkdir /media/$USER/CIRCUITPY && sudo mount -o
uid=$USER /dev/$IOT_USB_STORAGE /media/$USER/CIRCUITPY
circup list && circup show
circup install adafruit_bme280
UN-MOUNT
sudo sync && sudo umount /dev/$IOT_USB_STORAGE && sudo
rm -r /media/$USER/CIRCUITPY
MicroPython - Installation
Google search “micropython"
https://micropython.org/
sudo apt install build-essential libffi-dev git
pkg-config cmake gcc-arm-none-eabi
libnewlib-arm-none-eabi build-essential
cd $IOT; git clone https://github.com/micropython/
micropython.git --branch master
python -m pip install --upgrade mpremote --break-
system-packages
TOOL
CHAIN
MicroPython - Check Status
find /sys/bus/usb/devices/usb*/ -name dev | grep tty
lsblk; ls -laR /media/*; mount | grep media
IOT_USB_SERIAL=ttyACM0
sudo ~/iot/pico/picotool/build/picotool info -aF
python -m esptool -p /dev/$IOT_USB_SERIAL chip_id
udevadm info -q all -n /dev/$IOT_USB_SERIAL
minicom -w -D /dev/$IOT_USB_SERIAL
>>> import machine
>>> dir(machine.Pin)
picotool reboot
python3 $PY_BOARD -c 'print("Hello World")'
python3 $PY_BOARD -c 'import machine; print(dir(machine.Pin))’
MicroPython - Update
python -m pip install --upgrade mpremote --break-system-
packages
cd $IOT/micropython
git fetch ; git status
git submodule update --recursive --remote
git restore . --recurse-submodules
git clean -df -f
git pull
git submodule update
git fetch ; git status
MicroPython - Board Support
https://micropython.org/download/
wget -q -O - https://micropython.org/download/RPI_PICO2/ |
grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep firmware | grep
-Ev "preview" | sort -u | head -2 | tail -1 | tr -d '"'
ls -d $IOT/micropython/ports/*/boards/*/
wget https://micropython.org/$(wget -q -O - https://
micropython.org/download/RPI_PICO2/ | grep -io '['"'"'"]
[^"'"'"']*['"'"'"]' | grep firmware | grep -Ev "preview" | sort -u
| head -2 | tail -1 | tr -d '"') -P $IOT/bin
MicroPython - Demo (board setup)
wget -q -O - https://micropython.org/download/RPI_PICO2/ |
grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep firmware | grep -Ev
"preview" | sort -u | tail -1 | tr -d ‘"'
wget https://micropython.org/resources/firmware/
RPI_PICO2-20241129-v1.24.1.uf2 -P $IOT/bin
picotool load $IOT/bin/RPI_PICO2-20241129-v1.24.1.uf2 -F
picotool reboot -a
picotool erase -f
ls /dev/serial/*;
find /sys/bus/usb/devices/usb*/ -name dev | grep tty
ls -d $IOT/micropython/ports/*/boards/*/ | grep -i rpi
MicroPython - Edit Code
cd $IOT/work/micropython/pico
nano hello_world.py
MicroPython - Run Code
python3 $PY_BOARD hello_world.py
MicroPython - Upload Code
cp hello_world.py /media/$USER/MICROPY/code.py
MicroPython - Monitor
minicom -w -D /dev/ttyACM0
MicroPython - Demo (run code)
PY_BOARD=$IOT/micropython/tools/pyboard.py
python3 $PY_BOARD -c 'print("Hello World")'
minicom -w -D /dev/ttyACM0
>>> print("Hello World”)
cd $IOT/work/micropython/pico
cat map_pins.py
python3 $PY_BOARD map_pins.py
cat scan_i2c.py
python3 $PY_BOARD scan_i2c.py

More Related Content

PPTX
Up and running with Raspberry Pi
PPTX
IoT for data science Module 5 - Raspberry Pi.pptx
PDF
Introduction to the rapid prototyping with python and linux for embedded systems
PPTX
Got Python I/O: IoT Develoment in Python via GPIO
PDF
IoT: Internet of Things with Python
PPTX
Starting Raspberry Pi
PDF
Introduction to Raspberry Pi
PPTX
IOT notes ....,.........
Up and running with Raspberry Pi
IoT for data science Module 5 - Raspberry Pi.pptx
Introduction to the rapid prototyping with python and linux for embedded systems
Got Python I/O: IoT Develoment in Python via GPIO
IoT: Internet of Things with Python
Starting Raspberry Pi
Introduction to Raspberry Pi
IOT notes ....,.........

Similar to Command Your IoT Projects from the Terminal (20)

PDF
5 IOT MODULE 5 RaspberryPi Programming using Python.pdf
PDF
Iot Bootcamp - abridged - part 1
PDF
Raspberry Pi IoT In C 2nd Edition Harry Fairhead
PDF
Introduction to Arduino Programming: Features of Arduino
PDF
Raspberry Pi - Lecture 6 Working on Raspberry Pi
PDF
Luca Cipriani - Control your Embedded Linux remotely by using MQTT and a web ...
PDF
IoT Physical Devices and End Points.pdf
PDF
Exploring Raspberry Pi
PDF
DeviceHub - First steps using Intel Edison
PPTX
Exploring the Internet of Things Using Ruby
PPTX
M.Tech Internet of Things Unit - III.pptx
PDF
Raspberry Pi
PDF
Hardware hacking
PPTX
Contiki Operating system tutorial
ODP
Raspberry Pi introduction
PPTX
Unit 3 Complete.pptx
PPTX
RaspberryPi & Python Workshop Day - 01.pptx
PDF
Raspberry pi Board Hardware & Software Setup
PPTX
Parallel Rendering of Webpages
PDF
Linux+sensor+device-tree+shell=IoT !
5 IOT MODULE 5 RaspberryPi Programming using Python.pdf
Iot Bootcamp - abridged - part 1
Raspberry Pi IoT In C 2nd Edition Harry Fairhead
Introduction to Arduino Programming: Features of Arduino
Raspberry Pi - Lecture 6 Working on Raspberry Pi
Luca Cipriani - Control your Embedded Linux remotely by using MQTT and a web ...
IoT Physical Devices and End Points.pdf
Exploring Raspberry Pi
DeviceHub - First steps using Intel Edison
Exploring the Internet of Things Using Ruby
M.Tech Internet of Things Unit - III.pptx
Raspberry Pi
Hardware hacking
Contiki Operating system tutorial
Raspberry Pi introduction
Unit 3 Complete.pptx
RaspberryPi & Python Workshop Day - 01.pptx
Raspberry pi Board Hardware & Software Setup
Parallel Rendering of Webpages
Linux+sensor+device-tree+shell=IoT !
Ad

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Spectroscopy.pptx food analysis technology
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Machine learning based COVID-19 study performance prediction
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Spectroscopy.pptx food analysis technology
sap open course for s4hana steps from ECC to s4
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
Chapter 3 Spatial Domain Image Processing.pdf
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Machine learning based COVID-19 study performance prediction
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MIND Revenue Release Quarter 2 2025 Press Release
Ad

Command Your IoT Projects from the Terminal

  • 1. Command your IoT Projects from the Terminal
  • 2. Terminal Setup Apple Mac Studio M1 Ultra Apple iPad Pro M1 Magic Keyboard Portable Monitor Keyboard Mouse SSH Client (terminal) VNC Client (remote desktop) UVC Client (video capture) USB-A USB-C Ethernet Micro-USB HDMI Mini-USB USB-B SSH (network) VNC (network) HDMI (wired) OTG (gadget) Wi-Fi CONNECT (service) Raspberry Pi 5 RP2040 BMP280 I²C /tty/ACM0 BOOTSEL Connect (service)
  • 3. What exactly is a Terminal? print a line, scroll up type a line, scroll up RS-232
  • 4. Raspberry Pi 5 SERIAL USB BMP280 JST SH Serial I²C Raspberry Pi 5 HDMI USB JST SH Serial I²C Raspberry Pi 5 USB JST SH Serial I²C HDMI Portable/Desktop Monitor Keyboard Mouse Video Capture Card HDMI HDMI RS-232 DEC VT320 ESP32-S3 SAMD21 RP2040 BH1750 LSM 303AGR
  • 5. But wait what about Terminal Emulators? macOS Terminal kitty iTerm 2 ghostty Prompt 3 Terminus
  • 6. Apple Mac Studio Ultra M1 Raspberry Pi 5 VNC CAT5 USB RP2350 JST SH Serial I²C Apple MacBook Pro M1 Raspberry Pi 5 SSH USB RP2040 JST SH Serial I²C Wi-Fi Apple iPad Pro M1 Magic Keyboard Raspberry Pi 5 USB nRF52840 GROVE Serial I²C OTG (gadget) USB-C VEM L7700 VCNL4040 SHT41
  • 7. Then what exactly is the shell? POSIX BASH SH FISH KSH CSH PWSH REPL Ken Thompson
  • 10. Raspberry Pi Config SSH* RPi Connect* VNC I2C Expand Filesystem Boot Order* Wireless LAN* Hostname
  • 11. Raspberry Pi Connect sudo apt update sudo apt full-upgrade sudo apt install rpi-connect sudo apt install rpi-connect rpi-connect-lite sudo reboot systemctl --user start rpi-connect rpi-connect signin NOTE: fi nish the rest of the setup via any browser on some other computer, laptop, phone or tablet… Complete sign in by visiting https://connect.raspberrypi.com/verify/XXXX-XXXX
  • 12. Raspberry Pi USB Gadget Raspberry Pi Forums - Topic 376578 https://forums.raspberrypi.com/ viewtopic.php?t=376578 • Edit ‘con fi g.txt’ and ‘cmdline.txt’ per instructions in the topic’s post… • Download/edit/run script in the topic’s post… • Reboot, check with ifconfig… usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 169.254.133.86 netmask 255.255.0.0 broadcast 169.254.255.255 inet6 fe80::15dd:9047:cee6:391b prefixlen 64 scopeid 0x20<link> ether ea:46:11:1b:0b:c1 txqueuelen 1000 (Ethernet) RX packets 284 bytes 46679 (45.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 326 bytes 285229 (278.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 phattmatt
  • 13. Raspberry Pi USB Gadget phattmatt OTG sudo ip link set eth0 down sudo ip link set wlan0 down arp -a | grep : arp -a | grep bridge ssh ggeoffre@192.168.2.10
  • 14. Raspberry Pi HDMI Output USB to HDMI Video Capture MacBook Raspberry Pi QuickTime > New Movie Recording > USB Video OBS > Video Capture Device Source
  • 15. Raspberry Pi RS-232 Output WYSE PI USB to Serial adapter 9-pin to 25-pin adapter 9-pin Null Modem adapter ls /dev/*USB* | grep tty sudo systemctl enable serial-getty@ttyUSB0.serviceminicom https://www.youtube.com/watch?v=xQTr9ZOJkC0 Modern Linux on a Wyse Terminal
  • 16. Visual Studio Code - Remote SSH https://code.visualstudio.com/docs/remote/ssh-tutorial Install Visual Studio Code Remote SSH / Editing Con fi guration Files / Explorer Connect from the Command Palette select Remote-SSH: Connect to Host... Work Remotely Edit Files understands ‘remote’ versioning Visual Studio Code - Remote Development Over SSH
  • 17. Fonts and Colors True Type Font Terminal Font grep -n FONTFACE /etc/default/console-setup echo $TERM; sudo showconsolefont -Vvi sudo dpkg-reconfigure console-setup ls /usr/share/consolefonts/*.psf.gz setfont /usr/share/consolefonts/*.psf.gz # CONFIGURATION FILE FOR SETUPCON ACTIVE_CONSOLES="/dev/tty[1-6]" CHARMAP="UTF-8" CODESET="guess" FONTFACE="Terminus" FONTSIZE="16x32"
  • 18. Fonts and Colors https://gitlab.com/protesilaos/tempus-themes https://iterm2colorschemes.com/ WCAG - accessibility standard for color contrast • AA minimum contrast ratio of 4.50:1 • AAA minimum contrast ratio of 7.00:1 Tempus Autumn (WCAG AA) Tempus Tempest (WCAG AA) Tempus Warp (WCAG AA)
  • 19. Fonts and Colors if [ "$TERM" = "linux" ]; then echo -en "e]P0001514" #black echo -en "e]P1ff3737" #darkred echo -en "e]P2169c16" #darkgreen echo -en "e]P39f8500" #brown echo -en "e]P45781ef" #darkblue echo -en "e]P5da4ebf" #darkmagenta echo -en "e]P6009880" #darkcyan echo -en "e]P7968282" #lightgrey echo -en "e]P8261c2c" #darkgrey echo -en "e]P9F0681A" #red echo -en "e]PA3aa73a" #green echo -en "e]PBba8a00" #yellow echo -en "e]PC8887f0" #blue echo -en "e]PDd85cf2" #magenta echo -en "e]PE1da1af" #cyan echo -en "e]PFa29fa0" #white clear #for background artifacting fi ~/.bashrc color_test.sh for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' ' 36m' '1;36m' ' 37m' ' 1;37m'; do FG=${FGs// /}; echo -en " $FGs 033[$FG $T "; for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do echo -en "$EINS 033[$FG033[$BG Text 033[0m"; done; echo; done
  • 20. What is an IoT Project? Microcontroller Electronic Circuits PROGRAM A TO CONTROL chip pins protocols boards platforms connectors boards pins chips
  • 21. MicroPython Python Platforms Arduino C/C++ CircuitPython Python Pico SDK C/C++ ESP-IDF C/C++ MULTI SINGLE pyboard arduino-cli cmake/make idf.py
  • 23. Unexpected Maker ProS3 ESP32-S3 •ESP-IDF •Arduino •MicroPython •CircuitPython Raspberry Pi Pico W RP2040 •Pico-SDK •Arduino •MicroPython •CircuitPython Arduino Nano Every ATMega4809 •Arduino RP2350 Pimoroni Tiny2350 •Pico-SDK •Arduino •CircuitPython nRF52840 seeed XAIO nRF52840 •Arduino •MicroPython •CircuitPython Adafruit M0 Express ATSAMD21 •Arduino •MicroPython •CircuitPython STM32 SparkFun Thing Plus •Arduino •CircuitPython •ESP-IDF •Arduino •MicroPython •CircuitPython ESP3 2­ -S 3­ -DevKitC-1 ESP32-S3
  • 25. Command Workflow • Platform tools install/update • Boards/Cores set/install • Project create (optional) • Libraries import/download/install/add • Source Code edit/make/compile • App deploy/copy/upload • Output monitor
  • 27. Python Directory Structure /media/$USER/CIRCUITPY ./code.py ./lib CIRCUIT ./boot.py ./lib MICRO /dev/ttyACM0* NOTE: must use PyBoard.py NOTE: cannot use PyBoard.py /dev/ttyACM0 /dev/ttyACM0 PY_BOARD=$IOT/circuitpython/tools/pyboard.py PY_BOARD=$IOT/micropython/tools/pyboard.py
  • 28. Arduino - Installation Google search "arduino cli installation" https://arduino.github.io/arduino-cli/ 1.0/installation/ cd $IOT; mkdir $IOT/arduino; cd ./arduino curl -fsSL https://raw.githubusercontent.com/ arduino/arduino-cli/master/install.sh | sh NOTE: This script will install the latest version of Arduino CLI to $PWD/bin
  • 29. Arduino - Check Status arduino-cli version git ls-remote --tags https://github.com/ arduino/arduino-cli | tail -1 arduino-cli config dump arduino-cli core list arduino-cli lib list arduino-cli outdated
  • 30. Arduino - Update arduino-cli core update-index arduino-cli core upgrade arduino-cli lib update-index arduino-cli lib upgrade arduino-cli update arduino-cli upgrade cd $IOT/arduino curl -fsSL https://raw.githubusercontent.com/ arduino/arduino-cli/master/install.sh | sh NOTE: This script will install the latest version of Arduino CLI to $PWD/bin:
  • 31. Arduino - Board Support arduino-cli config add board_manager.additional_urls https:// adafruit.github.io/arduino-board-index/ package_adafruit_index.json arduino-cli core update-index arduino-cli board search adafruit | grep samd arduino-cli core install adafruit:samd arduino-cli board listall samd arduino-cli board details -b adafruit:samd:adafruit_sht4xtrinkey_m0
  • 32. Arduino - Create Project cd $WORK/Arduino arduino-cli sketch new trinkey_neopixel_blink Arduino - Edit Code nano $WORK/Arduino/trinkey_neopixel_blink.ino
  • 33. Arduino - Compile/Upload arduino-cli compile -vu -b adafruit:samd:adafruit_sht4xtrinkey_m0 $WORK/ Arduino/trinkey_neopixel_blink -p /dev/ttyACM0 Arduino - Monitor arduino-cli monitor -p /dev/ttyACM0 minicom -D /dev/ttyACM0
  • 34. Arduino - Libraries arduino-cli lib list arduino-cli lib search {$SEARCH} arduino-cli lib download “{$NAME}” arduino-cli lib install “{$NAME}” arduino-cli lib update-index arduino-cli lib upgrade BMP280
  • 35. Arduino - Demo cd $IOT/work/arduino ls /dev/serial/*; find /sys/bus/usb/devices/usb*/ -name dev | grep tty arduino-cli board listall rp2040 | grep "Raspberry Pi" cat ./blink/blink.ino arduino-cli compile -vu -b rp2040:rp2040:rpipico2 $IOT/work/arduino/blink -p /dev/ttyACM0 arduino-cli monitor -p /dev/ttyACM0 minicom -w -D /dev/ttyACM0
  • 36. Pico C/C++ SDK - Installation Google search "pico c/c++ sdk" https://www.raspberrypi.com/ documentation/microcontrollers/c_sdk.html sudo apt install cmake gcc-arm-none-eabi libnewlib- arm-none-eabi build-essential g++ libstdc++-arm-none- eabi-newlib cd $IOT; wget https://raw.githubusercontent.com/ raspberrypi/pico-setup/master/pico_setup.sh; chmod +x pico_setup.sh; ./pico_setup.sh NOTE: This script will install the latest version of Pick C/C++ SDK to $IOT/pico TOOL CHAIN
  • 37. Pico C/C++ SDK - Check Status for PICO_REPO in $(ls $IOT/pico/); do cd $IOT/pico/$PICO_REPO; git fetch ; git status; done ls $IOT/pico pico-sdk openocd debugprobe picotool pico-extras pico-examples pico-playground NOTE: Repeat for each repository… which picotool; picotool version; git ls-remote --tags $(cd $IOT/pico/picotool; git config --get remote.origin.url) | tail -1
  • 38. Pico C/C++ SDK - Update PICO-REPO=$(ls -d $IOT/pico); echo $PICO-REPO pico-sdk openocd debugprobe picotool pico-extras pico-examples pico-playground NOTE: Repeat for each repository… cd $IOT/pico/$PICO-REPO git fetch ; git status git submodule update --recursive --remote git restore . --recurse-submodules git clean -df -f git pull git submodule update git fetch ; git status
  • 39. Pico C/C++ SDK - Board Support udevadm info -q all -n /dev/ttyACM0 NOTE: Board must be in BOOTSEL mode NOTE: Board must be in USB Drive mode ls $IOT/pico/pico-sdk/src/boards/include/boards/ sudo $IOT/pico/picotool/build/picotool info -a
  • 40. Pico C/C++ SDK - Create Project cd $IOT/work/pico; mkdir HelloWorld; cd HelloWorld touch HelloWorld.c touch CMakeLists.txt Pico C/C++ SDK - Edit Code nano HelloWorld.c nano CMakeLists.txt
  • 41. Pico C/C++ SDK - Compile/Upload rm -rf ./build; mkdir build; cd build export PICO_SDK_PATH=$IOT/pico/pico-sdk cmake -DPICO_BOARD=adafruit_feather_rp2350 .. Pico C/C++ SDK - Monitor minicom -D /dev/ttyACM0 ⟳ make -j4 ; ls *.uf2 ; ls /media/$USER cp *.uf2 /media/$USER/RP2350/
  • 42. Pico C/C++ SDK - Libraries ls $IOT/pico/pico-examples/i2c https://forums.raspberrypi.com/viewtopic.php?t=305620 STICKY: Community library list for Pi Pico SDK C/C++ Topic ID: 305620
  • 43. Pico C/C++ SDK - Demo cd $IOT/work/pico/blink ls $IOT/pico/pico-sdk/src/boards/include/boards picotool info -a -F cat blink.c cat CMakeLists.txt rm -rf ./build && mkdir build && cd build && pwd cmake -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350 .. make -j4 picotool load blink.uf2 -f picotool reboot -a minicom -w -D /dev/ttyACM0
  • 44. ESP-IDF - Installation Google search "esp-idf" https://idf.espressif.com/ sudo apt install git wget flex bison gpref python3 python3-venv cmake ninja-build ccache libffi-dev mkdir $IOT/esp && cd $_; git clone --recursive https://github.com/espressif/esp-idf.git cd $IOT/esp/esp-idf; ./install.sh python -m pip install --upgrade esptool --break- system-packages TOOL CHAIN
  • 45. ESP-IDF - Check Status cd $IOT/esp-idf . ./export.sh python -m esptool version git ls-remote --tags https://github.com/ espressif/esptool | tail -1 idf.py —version git ls-remote --tags https://github.com/ espressif/esp-idf | tail -1 NOTE: Run Every Time To Set Up Environment
  • 46. ESP-IDF - Update cd $IOT/esp-idf; ./install.sh python -m pip install --upgrade esptool --break- system-packages cd $IOT/esp/$ESP-REPO git fetch ; git status git submodule update --recursive --remote git restore . --recurse-submodules git clean -df -f git pull git submodule update git fetch ; git status
  • 47. ESP-IDF - Board Support python -m esptool -p /dev/ttyACM0 chip_id idf.py —list-targets idf.py set-target esp32s3 idf.py menuconfig
  • 48. ESP-IDF - Create Project cd $IOT/work/esp-idf/ . $IOT/esp-idf/export.sh; idf.py --version idf.py create-project blink-led ESP-IDF - Edit Code nano ./main/blink-led.c
  • 49. ESP-IDF - Compile/Upload idf.py --list-targets idf.py set-target esp32s3 idf.py menuconfig idf.py build idf.py /dev/ttyUSB0 flash ESP-IDF - Monitor idf.py monitor NOTE: Ctrl-] will exit the monitor
  • 50. ESP-IDF - Libraries cd $IOT/esp; git clone --recursive https:// github.com/UncleRus/esp-idf-lib.git ls $IOT/esp/esp-idf-lib/components Uncle Russ
  • 51. ESP-IDF - Demo cd $IOT/work/esp-idf/blink-led ls /dev/serial/* && find /sys/bus/usb/devices/ usb*/ -name dev | grep tty idf.py --list-targets python -m esptool -p /dev/ttyACM0 chip_id cat ./main/blink-led.c cat ./main/CMakeLists.txt idf.py set-target esp32s3 idf.py build idf.py -p /dev/ttyACM0 flash monitor
  • 52. CircuitPython - Installation Google search “circuitpython" https://circuitpython.org/ sudo apt install build-essential libffi-dev git pkg-config cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential cd $IOT; git clone https://github.com/adafruit/ circuitpython.git python -m pip install --upgrade circup --break-system- packages TOOL CHAIN
  • 53. CircuitPython - Check Status find /sys/bus/usb/devices/usb*/ -name dev | grep tty lsblk; ls -laR /media/*; mount | grep media IOT_USB_SERIAL=ttyACM0 sudo ~/iot/pico/picotool/build/picotool info -aF python -m esptool -p /dev/$IOT_USB_SERIAL chip_id udevadm info -q all -n /dev/$IOT_USB_SERIAL minicom -w -D /dev/$IOT_USB_SERIAL >>> import board >>> dir(board) picotool reboot python3 $PY_BOARD -c 'print("Hello World")' python3 $PY_BOARD -c 'import board; print(dir(board))'
  • 54. CircuitPython - Check Status CircuitPython Pico-SDK Press and HOLD Pull Pin 30 to GND Then RELEASE
  • 55. CircuitPython - Check Status Press and HOLD Pull Pin 30 to GND Then RELEASE GND 3V3
  • 56. CircuitPython - Update cd $IOT/circuitpython git fetch ; git status git submodule update --recursive --remote git restore . --recurse-submodules git clean -df -f git pull git submodule update git fetch ; git status python -m pip install --upgrade circup --break-system- packages
  • 57. CircuitPython - Board Support https://circuitpython.org/downloads wget -q -O - https://circuitpython.org/board/ raspberry_pi_pico2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep org.bin | grep en_US | sort -u | tail -1 | tr -d '"' ls -d $IOT/circuitpython/ports/*/boards/*/ wget $(wget -q -O - https://circuitpython.org/board/ raspberry_pi_pico2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep org.bin | grep en_US | sort -u | tail -1 | tr -d '"') -P $IOT/bin
  • 58. CircuitPython - Demo (board setup) picotool load $IOT/bin/adafruit-circuitpython-raspberry_pi_pico2- en_US-9.2.2.uf2 -F picotool reboot -a wget -q -O - https://circuitpython.org/board/raspberry_pi_pico2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep raspberry_pi_pico2 | grep en_US wget https://downloads.circuitpython.org/bin/raspberry_pi_pico2/ en_US/adafruit-circuitpython-raspberry_pi_pico2-en_US-9.2.2.uf2 -P $IOT/bin picotool erase -f ls /dev/serial/*; find /sys/bus/usb/devices/usb*/ -name dev | grep tty ls -d $IOT/circuitpython/ports/*/boards/*/ | grep -i pico
  • 59. CircuitPython - Edit Code cd $IOT/work/circuitpython/pico nano hello_world.py CircuitPython - Run Code python3 $PY_BOARD hello_world.py CircuitPython - Upload Code cp hello_world.py /media/$USER/CIRCUITPY/code.py CircuitPython - Monitor minicom -w -D /dev/ttyACM0
  • 60. CircuitPython - Demo (run code) PY_BOARD=$IOT/circuitpython/tools/pyboard.py python3 $PY_BOARD -c 'print("Hello World")' minicom -w -D /dev/ttyACM0 >>> print("Hello World”) cd $IOT/work/circuitpython/pico cat map_pins.py python3 $PY_BOARD map_pins.py cat scan_i2c.py python3 $PY_BOARD scan_i2c.py
  • 61. CircuitPython - Libraries cd $IOT/work/circuitpython/pico cp /media/$USER/CIRCUITPY/boot_out.txt . ls $IOT/work/circuitpython/pico/lib circup show circup --path . list circup --path . update --all circup --path . freeze circup show circup install adafruit_bme280
  • 62. CircuitPython - Demo (libraries) SERIAL ls /dev/serial/*; find /sys/bus/usb/devices/usb*/ -name dev | grep tty STORAGE lsblk | grep -E "sd[a-zA-Z][0-9]"; ls -laR /media/* MOUNT sudo mkdir /media/$USER/CIRCUITPY && sudo mount -o uid=$USER /dev/$IOT_USB_STORAGE /media/$USER/CIRCUITPY circup list && circup show circup install adafruit_bme280 UN-MOUNT sudo sync && sudo umount /dev/$IOT_USB_STORAGE && sudo rm -r /media/$USER/CIRCUITPY
  • 63. MicroPython - Installation Google search “micropython" https://micropython.org/ sudo apt install build-essential libffi-dev git pkg-config cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential cd $IOT; git clone https://github.com/micropython/ micropython.git --branch master python -m pip install --upgrade mpremote --break- system-packages TOOL CHAIN
  • 64. MicroPython - Check Status find /sys/bus/usb/devices/usb*/ -name dev | grep tty lsblk; ls -laR /media/*; mount | grep media IOT_USB_SERIAL=ttyACM0 sudo ~/iot/pico/picotool/build/picotool info -aF python -m esptool -p /dev/$IOT_USB_SERIAL chip_id udevadm info -q all -n /dev/$IOT_USB_SERIAL minicom -w -D /dev/$IOT_USB_SERIAL >>> import machine >>> dir(machine.Pin) picotool reboot python3 $PY_BOARD -c 'print("Hello World")' python3 $PY_BOARD -c 'import machine; print(dir(machine.Pin))’
  • 65. MicroPython - Update python -m pip install --upgrade mpremote --break-system- packages cd $IOT/micropython git fetch ; git status git submodule update --recursive --remote git restore . --recurse-submodules git clean -df -f git pull git submodule update git fetch ; git status
  • 66. MicroPython - Board Support https://micropython.org/download/ wget -q -O - https://micropython.org/download/RPI_PICO2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep firmware | grep -Ev "preview" | sort -u | head -2 | tail -1 | tr -d '"' ls -d $IOT/micropython/ports/*/boards/*/ wget https://micropython.org/$(wget -q -O - https:// micropython.org/download/RPI_PICO2/ | grep -io '['"'"'"] [^"'"'"']*['"'"'"]' | grep firmware | grep -Ev "preview" | sort -u | head -2 | tail -1 | tr -d '"') -P $IOT/bin
  • 67. MicroPython - Demo (board setup) wget -q -O - https://micropython.org/download/RPI_PICO2/ | grep -io '['"'"'"][^"'"'"']*['"'"'"]' | grep firmware | grep -Ev "preview" | sort -u | tail -1 | tr -d ‘"' wget https://micropython.org/resources/firmware/ RPI_PICO2-20241129-v1.24.1.uf2 -P $IOT/bin picotool load $IOT/bin/RPI_PICO2-20241129-v1.24.1.uf2 -F picotool reboot -a picotool erase -f ls /dev/serial/*; find /sys/bus/usb/devices/usb*/ -name dev | grep tty ls -d $IOT/micropython/ports/*/boards/*/ | grep -i rpi
  • 68. MicroPython - Edit Code cd $IOT/work/micropython/pico nano hello_world.py MicroPython - Run Code python3 $PY_BOARD hello_world.py MicroPython - Upload Code cp hello_world.py /media/$USER/MICROPY/code.py MicroPython - Monitor minicom -w -D /dev/ttyACM0
  • 69. MicroPython - Demo (run code) PY_BOARD=$IOT/micropython/tools/pyboard.py python3 $PY_BOARD -c 'print("Hello World")' minicom -w -D /dev/ttyACM0 >>> print("Hello World”) cd $IOT/work/micropython/pico cat map_pins.py python3 $PY_BOARD map_pins.py cat scan_i2c.py python3 $PY_BOARD scan_i2c.py