Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Cardputer ADV

M5Stack Cardputer firmware + browser PWA that turns the Cardputer into a tethered hardware peripheral. The firmware creates a WiFi access point and exposes every hardware feature through a clean JSON API (HTTP REST + WebSocket streaming + SSE). The PWA is the reference client — connect any phone, tablet or laptop and control everything through a browser.

firmware/
cardputer_webapi/ ← Arduino sketch (ESP32-S3, M5Stack Cardputer)
install-libraries.bat ← Dependency installer for contributors (arduino-cli)
pwa/ ← Browser PWA reference client

Hardware

  • M5Stack Cardputer (M5StampS3, ESP32-S3)
  • Optional: Cap LoRa 1262 Unit — adds GPS + LoRa radio
  • Optional: Any Grove-compatible sensor on the Cardputer's Grove Port A (yellow socket on the body)

Installing

Option A — Pre-built binary (easiest)

Download the latest .bin from the Releases page and flash it:

  • M5Launcher users: copy the .bin to your SD card and install from the launcher menu — done.
  • First time / no launcher: use M5Burner (GUI) or esptool:
    esptool.py --port COM3 write_flash 0x0 cardputer_webapi_v1.3.0.merged.bin
    
    Replace COM3 with your port (/dev/ttyUSB0 on Linux/Mac).

Option B — Build from source (Arduino IDE)

Standard Arduino workflow — no extra tools needed beyond the IDE itself.

  1. Install Arduino IDE 2.x

  2. Add the M5Stack board package — open File → Preferences, add this URL to Additional boards manager URLs:

    https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
    

    Then Tools → Board → Boards Manager, search M5Stack, install.

  3. Install libraries — Tools → Manage Libraries, search and install each:

    • M5Cardputer
    • ArduinoJson (install v7)
    • TinyGPSPlus
    • RadioLib
    • IRremote
    • DHTesp
    • OneWire
    • DallasTemperature
  4. Install the two libraries not in the Library Manager — download as zips and use Sketch → Include Library → Add .ZIP Library:

  5. Open firmware/cardputer_webapi/cardputer_webapi.ino, select Tools → Board → M5Stack → M5Stack-Cardputer, set Partition Scheme → No OTA, and click Upload.

Option C — arduino-cli (contributors / CI)

firmware\install-libraries.bat ← installs everything in one shot
arduino-cli compile --profile default firmware\cardputer_webapi

Partition scheme:no_ota — compatible with bmorcelli M5Launcher. Binary fits at ~1.4 MB (well within the launcher's 4.9 MB app partition).

Dependencies

LibrarySourcePurpose
M5CardputerM5Stack board packageDisplay, keyboard, IMU, speaker
ESPAsyncWebServerGitHub (me-no-dev)Async HTTP + WebSocket + SSE server
AsyncTCPGitHub (me-no-dev)Async TCP layer for ESPAsyncWebServer
ArduinoJson v7Arduino Library ManagerJSON serialisation
TinyGPSPlusArduino Library ManagerNMEA sentence parsing
RadioLibArduino Library ManagerSX1262 LoRa radio driver
IRremoteArduino Library ManagerIR signal transmission (TinyIRSender)
DHTespArduino Library ManagerGrove: DHT11 temperature + humidity
OneWireArduino Library ManagerGrove: DS18B20 1-Wire bus
DallasTemperatureArduino Library ManagerGrove: DS18B20 temperature sensor

Hardware Exposed

ModuleTransportCapability
GPS (ATGM336H)REST + WebSocketPosition, altitude, speed, satellites, fix time
LoRa (SX1262)REST + WebSocketConfigurable radio TX/RX — frequency, BW, SF, power
IR TransmitterRESTNEC / NEC Extended / Onkyo protocols
IMU (BMI270)REST + WebSocket3-axis accelerometer + 3-axis gyroscope
KeyboardWebSocketKey events with full modifier state
Display (ST7789)RESTText, filled rectangles, clear, colour control
Speaker (ES8311)RESTTone generation, volume control
GPIORESTDigital read/write, pin mode configuration
Grove Port AREST + SSEPluggable sensor interface — DHT11, DS18B20, HC-SR04, rotary encoder, digital/analog/PWM
SystemRESTChip model, memory, flash, WiFi clients, uptime

API Reference

Live clickable listing: http://192.168.4.1/info

REST Endpoints

MethodEndpointDescription
GET/api/versionFirmware name and version
GET/api/system/infoChip, memory, flash, WiFi, uptime
GET/api/gpsCurrent GPS fix
POST/api/gps/rateSet NMEA update rate
GET/api/imuCurrent IMU reading (accel + gyro)
POST/api/imu/rateSet IMU streaming interval
GET/api/lora/configCurrent LoRa radio configuration
POST/api/lora/configSet frequency, bandwidth, SF, TX power
POST/api/lora/sendTransmit a LoRa packet
POST/api/ir/sendSend IR command (NEC / NEC Extended / Onkyo)
GET/api/gpio/{pin}Read digital pin state
POST/api/gpio/{pin}Write digital pin state
POST/api/gpio/{pin}/modeSet pin mode (INPUT / OUTPUT / INPUT_PULLUP / INPUT_PULLDOWN)
POST/api/display/textDraw text at x/y with colour and size
POST/api/display/clearClear display to colour
POST/api/display/fillDraw filled rectangle
POST/api/audio/tonePlay tone at frequency/duration
POST/api/audio/volumeSet speaker volume (0–255)
POST/api/audio/stopStop audio playback
GET/api/grove/sensorsSensor catalogue with voltage safety info
GET/api/grove/configCurrent pins and active sensor
POST/api/grove/configureArm a sensor type on the Grove pins
GET/api/grove/readSingle reading from the active sensor
POST/api/grove/writeWrite output value (digital_out or pwm_out)
POST/api/grove/rotary/resetZero the rotary encoder step count

WebSocket Streams

EndpointData
ws://192.168.4.1/ws/gpsGPS position updates
ws://192.168.4.1/ws/imuIMU accelerometer + gyro at configurable rate
ws://192.168.4.1/ws/loraReceived LoRa packets
ws://192.168.4.1/ws/keyboardKey press events with modifier state

SSE Streams

EndpointData
http://192.168.4.1/api/grove/streamGrove sensor readings at configurable interval (default 500 ms)

Grove Sensor Types

Sensor IDNameVCCGPIO SafeNotes
digital_inDigital Input3.3VSignal on D pin
digital_outDigital Output3.3VD drives HIGH/LOW
analog_inAnalog Input3.3V12-bit ADC, 0–3.3V
pwm_outPWM Output3.3V8-bit duty, configurable frequency
dht11DHT11 Temp & Humidity3.3V–5VData on D
ds18b20DS18B20 Temperature3.0V–5.5V1-Wire on D; needs 4.7 kΩ pull-up
hcsr04HC-SR04 Ultrasonic5VUse HC-SR04P (3.3V) or voltage divider on Echo
rotaryRotary Encoder3.3V–5VCLK on D, DT on D2

Grove Port A on the Cardputer: D = GPIO1 (yellow wire), D2 = GPIO2 (white wire).


Architecture

firmware/cardputer_webapi/ — Arduino sketch, one source file per hardware module:

FileModule
api_gps.*GPS UART parsing + WebSocket stream
api_lora.*SX1262 LoRa TX/RX + WebSocket stream
api_ir.*IR transmitter (TinyIRSender)
api_imu.*BMI270 IMU + WebSocket stream
api_audio.*ES8311 speaker tone + volume
api_display.*ST7789 display drawing
api_gpio.*Raw GPIO read/write/mode
api_grove.*Grove Port A — pluggable sensor drivers + SSE stream
api_system.*Chip/memory/WiFi system info
api_serial.*USB serial JSON command interface (mirrors HTTP API)
api_server.*ESPAsyncWebServer routing, REST + WebSocket helpers
api_webapp.*All PWA files embedded as C string literals; serves at /
config.hWiFi AP credentials, pin assignments, version
sketch.yamlarduino-cli build profile + library list

pwa/ — vanilla JavaScript, ES6 modules, no build step:

FileTab
js/app.jsTab router + WiFi connect/disconnect
js/api.jsCardputerAPI class (fetch + WebSocket wrapper)
js/tab-system.jsSystem info
js/tab-gps.jsGPS trail map
js/tab-lora.jsLoRa TX/RX
js/tab-imu.jsIMU visualisation
js/tab-keyboard.jsKeyboard monitor
js/tab-ir.jsIR remote
js/tab-display.jsDisplay drawing
js/tab-gpio.jsGPIO control
js/tab-audio.jsTone generator
js/tab-grove.jsGrove sensor explorer
js/tab-record.jsMicrophone recorder

The PWA is embedded in the firmware via api_webapp.cpp — no LittleFS upload or separate server needed. pwa/ is the source of truth; after editing run the sketch through the build to regenerate the embedded version.


PWA Notes

Accessing the app

Open http://192.168.4.1/ while connected to the CardputerADV AP, or open pwa/index.html from a local HTTP server and enter the IP manually.

Microphone recording

Browsers block microphone access over plain HTTP. To enable it on the Cardputer AP:

  • Chrome / Android:chrome://flags/#unsafely-treat-insecure-origin-as-secure → add http://192.168.4.1
  • Firefox:about:configmedia.devices.insecure.enabled = true

The Record tab shows these instructions when it detects an insecure context.


Current State

v1.3.0 — 10 hardware modules, 11 PWA tabs, full Grove sensor support added.

  • All hardware modules implemented and tested
  • Web app embedded in firmware — flash once, no separate upload step
  • Grove Port A: sensor catalogue, SSE streaming, voltage safety warnings
  • Display shows a live status dashboard
  • Managed via bmorcelli M5Launcher

Roadmap

  • Additional Grove I2C sensor drivers (SHT31, BMP280, colour sensor, etc.)
  • Power management / sleep modes
  • Purpose-built native apps (Android via PoPA, desktop Python scripts) consuming the API
  • Possible integration into the Home PWA catalogue

Licence

AGPL-3.0-or-later -- free to use, modify, and distribute. If you run this as a network service, you must make the source available to users.

About

M5Stack Cardputer firmware + PWA client. Turns the Cardputer into a WiFi-tethered peripheral — REST + WebSocket API for GPS, LoRa, IR, IMU, keyboard, display, GPIO, and audio.

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages