@peapodtech/peapodos
v0.4.3
Published
Main software for PeaPod.
Readme
PeaPodOS
Main software for PeaPod. Scripts are written for MacOS, and probably work on other Unix-like systems.
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).
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 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 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 400 with USB serial and power 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 (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 (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 400 First-Time Setup
- Plug in a keyboard, display, and mouse, insert the included microSD card (if not already inserted), and power on the Raspberry Pi 400.
The following are performed on the Raspberry Pi 400, with a keyboard, mouse, and monitor:
- Login. If using the graphical desktop, open a terminal.
- 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 - 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-devInstall main software package:
sudo npm i -g @peapodtech/peapodos --save
- Install PlatformIO Core
- Populate a
~/.envfile based on./.env.templatewith serial port and webserver configuration, and, if using Firebase, Firebase configuration and Google and/or GitHub auth configuration.
Connect a USB cable from the computer (i.e. Raspberry Pi 400) to the microcontroller (i.e. Adafruit ESP32 Feather V2), and verify that the serial port is available and openable by executing
peapodosand following the prompt to select "Test Serial". The serial port should be something like/dev/ttyACM0(NOT/dev/ttyS0, this is the GPIO UART). Press Ctrl-C to exit the test when finished.Perform first-time microcontroller firmware flashing by executing
peapodosand following the prompt to select "Flash Firmware". The serial port should be something like/dev/ttyACM0(NOT/dev/ttyS0, this is the GPIO UART).
Execution
Run the main program by executing
peapodosand following the prompt to select "Launch Server". You may exit at any time by pressing Ctrl-C.Follow the prompts to select publishing modes (Local Filesystem, Firebase, and/or Dashboard), and if applicable, perform Firebase Device Flow Authentication.
Select the appropriate serial port (i.e.
/dev/ttyS0for GPIO UART-ArduinoSerial1,/dev/ttyACM0for USB-ArduinoSerial) to connect to the microcontroller.If dashboard publishing was selected, enter a hostname and port when prompted (default is
0.0.0.0:3000); the webserver should start, making the dashboard accessible at the displayed hostname and port.The console will begin printing raw telemetry and debugging information from the microcontroller.
