SolarOS

SolarOS 4.13.4 manual · api

SolarOS Lua API

SolarOS embeds Lua as the lua foreground application. It can run an interactive REPL or execute .lua files from storage.

The SolarOS API is preloaded as the global table solaros. A minimal require("solaros") shim is also provided:

local solaros = require("solaros")

print("SolarOS " .. solaros.version())
print(solaros.identity.format())

Lua allocations prefer PSRAM. Host-facing Lua io, os, and dynamic package loading are intentionally not opened; scripts should use SolarOS services for hardware, storage, networking, and foreground UI.

API topics

Open a topic below, or use its ID with man on the device, for example man lua.network. Service availability depends on the board and flavor.

TopicServices
Storage and filessolaros.storage
Time and schedulingsolaros.time, solaros.rtc, solaros.schedule
Networkingsolaros.wifi, solaros.mqtt, solaros.http, solaros.net, solaros.ftp, solaros.sftpsync, solaros.ssh_keys
Bluetoothsolaros.ble
GPIO and peripheralssolaros.gpio, solaros.onewire, solaros.led, solaros.adc, solaros.pwm, solaros.i2c, solaros.spi, solaros.uart, solaros.neopixel, solaros.battery, solaros.sensors, solaros.gnss, solaros.nfc
Buses and expansionsolaros.buses, solaros.expansion
Audio and controlsolaros.audio, solaros.synth, solaros.dsp, solaros.controls, solaros.parameters, solaros.midi, solaros.osc
Input and clipboardsolaros.input, solaros.hid, solaros.clipboard
Apps, jobs, and identitysolaros.identity, solaros.jobs, solaros.sessions, solaros.apps
Contacts and messagessolaros.contacts, solaros.messages
Text user interfacessolaros.tui
Graphicssolaros.gfx

Top-Level Helpers

For example, solaros.tick_interval(5) lets a foreground Lua app drain terminal, TUI, and graphics events at a best-effort 5 ms cadence. It does not schedule or preempt Lua code, and it is not a hard-real-time timer. The setting lasts for the current foreground Lua app only; headless script jobs cannot change it.

Service availability

Lua mirrors the Python solaros module structure:

The Lua runtime package requires PSRAM. Hardware and network tables are present only when the board/flavor includes the corresponding service package. For example, an ODROID-GO full build includes Lua with solaros.spi and solaros.onewire, while omitting solaros.adc and solaros.i2c because those service packages are not available on that board.

Lua strings are binary-safe, so byte-oriented APIs such as uart.read, i2c.read_reg, clipboard.get, and mqtt.read().payload return Lua strings.

Conventions

Lua tables returned as lists use normal Lua 1-based array indexes. Direct block lookup with solaros.storage.block(index) follows the underlying storage service index, matching Python's 0-based block(index).

The Lua bridge intentionally does not expose raw SSH/SCP session handles. Those need explicit object lifetime and event-loop rules before becoming scriptable.

Quick reference

Load solaros and use its service tables for storage, time, networking, hardware, jobs, sessions, input, TUI, and graphics. Foreground pointer and axis events use solaros.input sources, read, clear, and status; keyboard characters use solaros.tui.getch(). Lua arrays are 1-based unless an individual service explicitly exposes a native index. Close resources and keep long-running loops cooperative.

Join us on: