@peapodtech/peapodos
v0.3.8
Published
Main software for PeaPod.
Readme
PeaPodOS
Main software for PeaPod.
Table of Contents
Design
A two-part system, consisting of a high-level software application and a low-level microcontroller firmware, designed for remote monitoring and configuration of control systems.
The software is written in TypeScript and runs on any compatible computer system with an internet connection, persistent storage, and a UART serial interface (i.e. Raspberry Pi Zero 2 W).
The firmware is written in Arduino C++ and runs on any compatible microcontroller system with UART serial and I2C interfaces (i.e. Adafruit ESP32 Feather V2). See ./microcontroller/README.md for more information.
Ensure UART voltage levels are compatible (i.e. 3.3V for both Raspberry Pi Zero 2 W and Adafruit ESP32 Feather V2).
Architecture
environment
Priority:
- User input
- Command-line arguments
- Environment variables
- Defaults
index
run tests, flash firmware, launch server
server
start menu
- publishing mode selection (Local Filesytem, Firebase, Dashboard)
- Firebase Device Flow Authentication
- Provider Selection (Google, GitHub)
- Device Code & URL
- Microcontroller Serial Port Selection
- Dashboard Webserver Hostname & Port Selection
serial communication
- bidirectional
- JSON-formatted
- newline-delimited
- encoding: device commands, system configuration
- decoding: telemetry/debugging
WebSockets API w/ Callbacks
- camera capture and image streaming
- serial passthrough
- intervals
- linker
- firmware flashing
- scheduler
Control Systems (TODO)
dashboard webserver
- Debugging Console
- Telemetry Charts
- Calendar + DataGrid
- Interval & Event Scheduler
- Microcontroller Instructions
- Tasks
Usage
Development
There are three entrypoints:
- Docker compose development environment for native simulator development
- NPM package for development and publishing
- Exported software bundle for development deployment
Native Simulator Development
git clone https://github.com/PeaPodTechnologies/PeaPod.gitcd softwarechmod +x ./scripts/attach.shdocker compose up- In a separate terminal,
./scripts/attach.shto attach to the container and run the software.
Packing for NPM
git clone https://github.com/PeaPodTechnologies/PeaPod.gitcd softwarechmod +x ./scripts/pack.sh./scripts/pack.shto build the software and create a.tgzpackage in./dist/peapodos.tgzfor publishing to NPM.
Exporting Software Bundle
- Execute
scripts/export.shWITH NO ARGUMENTS to compile TypeScript to JavaScript and bundle the webserver, creating an./out.tar.gzarchive containing the compiled software. - Optional: Execute
scripts/upload.sh <hostname>to upload the./out.tar.gzarchive to the Raspberry Pi Zero 2 W home directory, where<hostname>is the hostname of the Raspberry Pi (e.g.peapod.local). - Unzip the
~/out.tar.gzarchive withtar -xzf ~/out.tar.gz -C ~.
QEMU Raspberry Pi Simulator
- Install dependencies:
brew install qemu - Build the Raspberry Pi OS Lite (64-bit) QEMU-compatible image:
./qemu-image.sh - Build the Docker image for the QEMU simulator:
./qemu-build.sh - Run the QEMU simulator container with
./qemu-run.sh deploy/<date>-peapod-lite-qemu.imgto install boot the Raspberry Pi OS Lite (64-bit) image in a virtual machine.
Production
This targets Raspberry Pi Zero 2 W with GPIO UART serial connection to an Adafruit ESP32 Feather V2 microcontroller.
Build Raspberry Pi Image
The following are performed on a computer with an internet connection, Docker, and Homebrew installed:
- Format a microSD card (>=32GB) with a single FAT partition.
- Download the Raspberry Pi Imager (Download).
- Build the Raspberry Pi OS Lite (64-bit) image:
build.sh. This creates a Docker build container that produces a.zipfile atdeploy/*.zip. This requires Homebrew and installsgnu-sed. - Flash the SD card with the Raspberry Pi OS Lite (64-bit) image using Raspberry Pi Imager, and select
deploy/*.zipas the custom image.
Note: A custom PeaPodOS image will be released in the future.
Raspberry Pi First-Time Setup
- Plug in a keyboard and display, insert the microSD card, and power on the Raspberry Pi Zero 2 W.
The following are performed on the Raspberry Pi Zero 2 W, with a keyboard and monitor:
- Login.
- Execute
sudo raspi-configand perform these steps to setup the Pi:- System Options > Wireless Lan - Setup WiFi and connect to the Internet (if not set from within imager)
- System Options > Hostname - Set a unique hostname, e.g.
peapod(if not set from within imager) - System Options > Boot/Auto Login - Select
Console Autologin(B2) - Interface Options > SSH -
EnableSSH Server (if not set from within imager) - Interface Options > Serial Port -
Disableserial login shell, butEnablethe serial port hardware - Performance Options > GPU Memory - 256 MB (to support the camera module, if used)
- Localisation Options > Locale (i.e.
en_US.UTF-8) - Localisation Options > Timezone (i.e.
US>Eastern) - Localisation Options > Keyboard (i.e.
Generic 105-key>English (US)>Default>No compose key) - Optional: Advanced Options > Expand Filesystem
- Reboot to save:
sudo reboot -f
You can now SSH into the Raspberry Pi to perform the rest of the setup, or continue with the keyboard and monitor.
Installation
Update package listings, upgrade existing packages:
sudo apt update && sudo apt full-upgrade -yInstall Node.JS, the Node package manager, and Python dependencies:
sudo apt install -y nodejs npm python3-venv python3-dev
- Install PlatformIO Core
Populate a
~/.envfile based on./.env.templatewith Firebase configuration, Google and/or GitHub auth configuration, serial port configuration, and webserver configuration (if applicable).Unpack the
~/out.tar.gzarchive to the home directory:tar -xzf ~/out.tar.gz -C ~Connect a USB cable from the computer (i.e. Raspberry Pi Zero 2 W) to the microcontroller (i.e. Adafruit ESP32 Feather V2), and verify that the serial port is available and openable by executing
node ~/serialtest.mjsand following the prompts. The serial port should be something like/dev/ttyACM0(NOT/dev/ttyS0, this is the GPIO UART).Perform first-time microcontroller firmware flashing by executing
node ~/flash.mjsand following the prompts. The serial port should be something like/dev/ttyACM0(NOT/dev/ttyS0, this is the GPIO UART).
Execution
Run the main program by executing
node ~/server.mjs.Follow the prompts to select a publishing mode (Local Filesystem, Firebase, and/or Dashboard), and if applicable, perform Firebase Device Flow Authentication.
The webserver should start, making the dashboard accessible at the displayed hostname and port.
Select the appropriate serial port (i.e.
/dev/ttyS0for GPIO UART-ArduinoSerial1,/dev/ttyACM0for USB-ArduinoSerial) to connect to the microcontroller.The console will begin printing raw telemetry and debugging information from the microcontroller.
