led
WS2812 RGB LED control — color presets, raw RGB, current state.
Full reference →
The nXPico M firmware exposes three high-level MicroPython modules. Import them directly — no installation required.
led
WS2812 RGB LED control — color presets, raw RGB, current state.
Full reference →
modem
nRF9151 LTE-M/NB-IoT modem — AT commands, MQTT, radio control, certificate storage.
Full reference →
powman
RP2350A Power Manager — timed deep-sleep and GPIO wake-up.
Full reference →
x509gen
RSA/EC key generation and X.509 certificate creation — on-device, no external tooling.
Full reference →
led — RGB LEDfrom led import Ledrgb = Led()| Function | Signature | Description |
|---|---|---|
| Constructor | Led() | Init LED on GPIO23, sets off. |
set_color | set_color(value: list) | Set color as [r, g, b] (0–255 each). |
get_value | get_value() → list | Returns current color as [r, g, b]. |
red | red() | Set red. |
green | green() | Set green. |
blue | blue() | Set blue. |
white | white() | Set white. |
yellow | yellow() | Set yellow. |
cyan | cyan() | Set cyan. |
magenta | magenta() | Set magenta. |
orange | orange() | Set orange. |
off | off() | Turn off. |
rgb.red()rgb.set_color([0, 100, 200])print(rgb.get_value()) # [0, 100, 200]rgb.off()modem — nRF9151 LTE-M/NB-IoTfrom modem import Modemm = Modem() # singleton — same instance on every call| Function | Signature | Description |
|---|---|---|
| Constructor | Modem() | Init modem, flush RX buffer. |
CFUN | CFUN(mode: int) → bool | Set radio mode: 0 off, 1 full, 4 flight. |
m.CFUN(1) # enable full RFm.CFUN(4) # flight mode| Function | Signature | Description |
|---|---|---|
send_cmd | send_cmd(command, expected="OK", timeout_ms=1000, is_bool=True) | Send AT command, wait for response. |
send | send(data: bytes) | Send raw bytes to UART1. |
read | read(num_bytes: int) → bytes | Read raw bytes from UART1. |
wait_response | wait_response(expected="OK", timeout_ms=1000) → str | Poll until expected string or timeout. |
ok = m.send_cmd("AT") # True / Falsever = m.send_cmd("AT+CGMR", is_bool=False) # raw response string| Function | Signature | Description |
|---|---|---|
mqtt_cfg | mqtt_cfg(client_id, keep_alive=60, clean_session=0) → bool | Configure client ID and session. |
get_mqtt_cfg | get_mqtt_cfg() → str | Read current MQTT configuration. |
mqtt_conn | mqtt_conn(op, username, password, url, port, sec_tag=None) → bool | Connect (op=1) or disconnect (op=0). |
is_mqtt_conn | is_mqtt_conn() → bool | Check connection status. |
mqtt_publish | mqtt_publish(topic, msg, qos=0, retain=0) → bool | Publish a message. |
mqtt_subscribe | mqtt_subscribe(topic, qos=0) → bool | Subscribe to a topic. |
m.CFUN(1)m.mqtt_cfg("my-device")m.mqtt_conn(1, "user", "pass", "broker.example.com", 1883)m.mqtt_publish("sensors/temp", "23.5")m.mqtt_subscribe("commands/#")Credentials (certificates, keys, PSKs) are stored in the modem’s internal secure storage and referenced by a sec_tag.
| Function | Signature | Description |
|---|---|---|
write_certificate | write_certificate(sec_tag, cert_type, content, psw=None, sha256=None) → bool | Write a credential to secure storage. |
list_certificate | list_certificate(sec_tag, cert_type=None) → str | List credentials for a given sec_tag. |
read_certificate | read_certificate(sec_tag, cert_type) → str | Read the content of a stored credential. |
delete_certificate | delete_certificate(sec_tag, cert_type) → bool | Delete a credential from secure storage. |
m.CFUN(4) # flight mode while writing credentialsm.write_certificate(1, 0, ROOT_CA) # Root CAm.write_certificate(1, 1, CLIENT_CERT) # Client certificatem.write_certificate(1, 2, CLIENT_KEY) # Client private keym.CFUN(1)m.mqtt_conn(1, "", "", "broker.example.com", 8883, sec_tag=1)See the full reference for credential type values and parameter details.
powman — Deep-sleepimport powman, time| Function | Signature | Description |
|---|---|---|
powmanInit | powmanInit(absTimeMs: int) | Seed the 64-bit POWMAN timer. Call once before powmanOffForMs. |
powmanOffForMs | powmanOffForMs(sleepingMs: int) | Enter dormant mode for N milliseconds, then reboot. |
powmanOffUntilGPIO | powmanOffUntilGPIO(gpio: int) | Enter dormant mode, wake when GPIO goes HIGH, then reboot. |
# Timed sleeppowman.powmanInit(time.ticks_ms())powman.powmanOffForMs(30_000) # sleep 30 s, then reboot
# GPIO wake-uppowman.powmanOffUntilGPIO(10) # sleep until GPIO10 goes HIGHx509gen — Certificate generationimport x509gen| Function | Signature | Description |
|---|---|---|
generate_rsa_keypair | generate_rsa_keypair(bits=2048) → (str, str) | Generate RSA key pair. May take 10–30 s on RP2350. |
generate_ec_keypair | generate_ec_keypair(curve_name="secp256r1") → (str, str) | Generate EC key pair. Curves: secp256r1, secp384r1, secp521r1. |
generate_self_signed_cert | generate_self_signed_cert(private_key_pem, subject, ...) → str | Generate a self-signed X.509 certificate. |
generate_csr | generate_csr(private_key_pem, subject, md_alg="sha256") → str | Generate a Certificate Signing Request. |
import machine, x509gen
uid = machine.unique_id()serial = ''.join('{:02X}'.format(b) for b in uid)
priv, _pub = x509gen.generate_rsa_keypair(2048)cert = x509gen.generate_self_signed_cert( priv, subject=f"CN=rp2350-{serial},O=neXo,C=IT", not_before="20250101000000", not_after="20350101000000",)See the full reference for key usage constants, CSR generation, and the complete provisioning example.