Skip to main content

Client-server package to remotely control a Raspberrypi Pi Pico W.

Project description

https://img.shields.io/pypi/v/piconetcontrol.svg https://img.shields.io/github/license/matthiaszeller/piconetcontrol.svg

Client-server package to remotely control a Raspberrypi Pico W.

About

This package provides a client-server architecture to remotely control a Raspberry Pi Pico W. The server runs on the Pico W and the client on a computer. For testing/debugging purpose, the server can also run on e.g. a Raspberrypi 4, with limited functionality.

The goal is to handle logic on the client side, while the server is responsible for direct hardware interaction. This enables using more powerful hardware for orchestration with greater functionalities, as the server is executed with MicroPython on the Pico W.

Server Blinking Patterns

The Pico W board is equipped with an LED that can be used to indicate the status of the server.

Status

Pattern

Connecting to WiFi

3 blinks of 100ms, 200ms apart, then 1s pause

Server Listening (Idling)

Infinite blinks of 1.5s on, 1.5s off

Ongoing Connection

Continuous 20ms blinks, 100ms apart

If the board isn’t blinking:

  • Server might not be running

  • Board might be in light or deep sleep mode * If in light sleep, the server wakes up upon receiving a command

Client-Server Communication Protocol

The server and the Raspberry Pi Pico W (client) communicate over a TCP/IP connection. Message exchange occurs via JSON-encoded dictionaries.

Commands

GPIO Control

Setup pin

Instructs client to configure a GPIO pin as input or output, optionally set its value.

Command structure:

{
    "action": "setup_pin",
    "pin": "<pin_number>",
    "mode": "<'input'|'output'>",
    "value": "<0|1> [optional]"
}

Success Response: Client echoes back the command.

Set pin value

Instructs client to set a specified GPIO pin to specified value (high or low) during some specified time.

Command structure:

{
    "action": "write_pin",
    "pin": "<pin_number>",
    "value": "<0|1>",
    "timeout": "<duration_in_seconds>"
}

Success Response: Client echoes back the command (does not wait for timeout).

Read pin value

Requests the current value (high or low) of a specified GPIO pin.

Command structure:

{
    "action": "read_pin",
    "pin": "<pin_number>"
}

Success Response: Client echoes back the command and adds the value field (high/low).

Board Management

Reset board

Instructs client to reset the board, using the machine.reset() method.

Command structure:

{
    "action": "reset"
}

Success Response: Client echoes back the command.

Sleep for low power

Instructs client to enter a low-power state mode for a specified duration.

Command structure:

{
    "action": "sleep",
    "deep": "<0|1>",
    "time_ms": "<duration_in_ms>"
}

Success Response: Client echoes back the command.

Get resource info

Requests information about the client’s resources (e.g., memory, CPU).

Command structure:

{
    "action": "get_resource_info"
}

Success Response: Client echoes back the command and adds the info field.

Get server version

Requests the version of the server software.

Command structure:

{
    "action": "get_version"
}

Success Response: Client echoes back the command and adds the version field.

List actions

Requests a list of available actions supported by the client.

Command structure:

{
    "action": "list_actions"
}

Success Response: Client echoes back the command and adds the actions field.

Update server software

Instructs the client to update the server software.

Command structure:

{
    "action": "update"
}

The client will update the server software and restart the server. In case of failure after restart, the server will revert to the previous version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piconetcontrol-0.2.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piconetcontrol-0.2.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file piconetcontrol-0.2.1.tar.gz.

File metadata

  • Download URL: piconetcontrol-0.2.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for piconetcontrol-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d938f4e443b61293a682d943c61d493bb698dce207615a1238159fa440557b8d
MD5 a95467ab43b62ab6cf71f6470b9f9a42
BLAKE2b-256 b7a6164d3d15812e93304e37845e4b650f3b49077f1ed51538da8742298e788d

See more details on using hashes here.

File details

Details for the file piconetcontrol-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: piconetcontrol-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for piconetcontrol-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b951cf7fb1b2b056d0926564402c01bd6b705bbe77681e1ff9a96d1c3c3a9c5
MD5 7c0b1ba4960dd3d7ed3bdc1e0dfd0220
BLAKE2b-256 b642861081d9ad8b974af5fa529815b0973f1735f3a6a2373ab7558fe59921ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page