SolarOS

SolarOS 4.13.4 manual · api

Lua gpio and peripherals API

API overview · Python gpio and peripherals

solaros.battery

solaros.sensors

for _, sensor in ipairs(solaros.sensors.list()) do
    print(sensor.name, sensor.driver)
end

print(solaros.sensors.temperature())
print(solaros.sensors.humidity())

solaros.gnss

local fix = solaros.gnss.fix()
if fix.valid then
    print(fix.latitude_deg_e7, fix.longitude_deg_e7)
end

solaros.haptic

solaros.haptic.play(15)

solaros.charger

OTG/boost mode and battery-chemistry policy are not exposed.

local status = solaros.charger.status()
print(status.state)

solaros.nfc

solaros.imu

local sample = solaros.imu.sample()
if sample.acceleration_m_s2 then
    print(sample.acceleration_m_s2.x,
          sample.acceleration_m_s2.y,
          sample.acceleration_m_s2.z)
end

solaros.gpio

solaros.onewire

solaros.led

solaros.adc

solaros.pwm

solaros.neopixel

solaros.i2c

solaros.spi

solaros.uart

Direct-pin OneWire

solaros.onewire.scan(pin) returns tables containing a 16-digit hexadecimal address and numeric family code. solaros.onewire.xfer(pin, read_len[, data]) resets the bus, writes the binary-safe data string, and returns read_len bytes. Reads and writes are each limited to 64 bytes.

Default UART

solaros.uart is the default uart0 compatibility table; use solaros.buses.uart_* for another named UART and solaros.buses.attach() or detach() for lifecycle control. solaros.uart.status() includes the bus name, attached, rx_buffered, and rx_buffered_valid. When another owner is actively using the UART, rx_buffered_valid is false because the live RX count is not sampled.

Quick reference

Use solaros.gpio, solaros.onewire, solaros.led, solaros.adc, solaros.pwm, solaros.i2c, solaros.spi, solaros.uart, solaros.neopixel, solaros.battery, solaros.charger, solaros.sensors, solaros.gnss, solaros.haptic, solaros.imu, and solaros.nfc for gpio and peripherals. See man lua for runtime conventions and service availability.

Join us on: