This protocol enables communication between an Arduino device and a host system over serial communication. It allows the remote control of actuators and monitoring of sensors. Each command follows the format alp://<command>/<pin>/<value>, with an optional ?id=<id> that can be added to the message for tracking individual commands.
- Note: The
id=<id>parameter is optional in all commands. If included in the command, it will be included in the response. If noidis provided in the command, there will be no response.
Upon initialization, the Arduino sends an informational message containing key/value pairs. Currently, it includes the firmware version:
alp://info/fw=1.2
Additional key/value pairs may be added in the future. This message is sent once when the Arduino starts up and establishes a serial connection.
Note: The info message at startup was introduced with firmware version 1.2. In previous versions, only senseless reply message was sent to signal that the Arduino is ready.
- Command:
alp://kprs/<message>?id=<id>(Optional:?id=<id>) - Description: Sent when a key is pressed.
- Parameters:
message: The key press message (e.g., "a", "b", etc.).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://ppin/<pin>/<intensity>?id=<id>(Optional:?id=<id>) - Description: Set the intensity (PWM value) for a power pin.
- Parameters:
pin: Pin number (integer).intensity: PWM intensity value (0-255).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://ppsw/<pin>/<power>?id=<id>(Optional:?id=<id>) - Description: Set the power state of a pin (ON/OFF).
- Parameters:
pin: Pin number (integer).power: Power state (1 for ON, 0 for OFF).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://tone/<pin>/<frequency>/<duration>?id=<id>(Optional:?id=<id>) - Description: Generate a tone on a specified pin.
- Parameters:
pin: Pin number (integer).frequency: Frequency of the tone (Hz).duration: Duration of the tone in milliseconds. If -1, the tone will continue indefinitely.id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://notn/<pin>?id=<id>(Optional:?id=<id>) - Description: Stop the tone on a specified pin.
- Parameters:
pin: Pin number (integer).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://srld/<pin>?id=<id>(Optional:?id=<id>) - Description: Start listening to a digital pin for state changes.
- Parameters:
pin: Pin number (integer).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://spld/<pin>?id=<id>(Optional:?id=<id>) - Description: Stop listening to a digital pin.
- Parameters:
pin: Pin number (integer).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://srla/<pin>?id=<id>(Optional:?id=<id>) - Description: Start listening to an analog pin for state changes.
- Parameters:
pin: Pin number (integer).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://spla/<pin>?id=<id>(Optional:?id=<id>) - Description: Stop listening to an analog pin.
- Parameters:
pin: Pin number (integer).id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://cust/<customId>/<value>?id=<id>(Optional:?id=<id>) - Description: Send a custom message to the Arduino.
- Parameters:
customId: Custom identifier for the message.value: The custom message value.id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://cust/pingid=<id>(Optional:?id=<id>) - Description: Pings the Arduino. Can be used to verify if the Arduino reponds (via id)
- Parameters:
id: (Optional) Unique message identifier. If provided, it will be included in the response.
- Command:
alp://rply/<status>?id=<id> - Description: The Arduino sends a response back indicating the success or failure of the operation. The response includes the same
idfrom the original command (if it was provided). If noidwas provided in the the original command there will be no reply. - Parameters:
status: "ok" or "ko" indicating whether the command was successful or not.id: The unique message identifier that was included in the original command.
- Command:
alp://<type>/<pin>/<value> - Description: Sent when a pin's value is read (either digital or analog).
- Parameters:
type: The type of pin ("dred" for digital or "ared" for analog).pin: The pin number that is being monitored.value: The value of the pin (either 0/1 for digital or an analog value).
- Host to Arduino: The host system sends a command to the Arduino.
- Arduino Execution: The Arduino processes the command and interacts with the hardware as necessary.
- Arduino to Host: If the original command contained an
idthe Arduino sends a response with the requests'idsame. If noidwas provided in the command, the Arduino will not send a response for that command.
-
Command:
alp://srld/7?id=123- Description: Start listening to digital pin 7, with an
idof "123".
- Description: Start listening to digital pin 7, with an
-
Arduino Response:
alp://rply/ok?id=123- Description: Acknowledge the start of pin 7 listening, with the same
id("123") to match the original request.
- Description: Acknowledge the start of pin 7 listening, with the same
-
Command:
alp://srld/7- Description: Start listening to digital pin 7, without an
id.
- Description: Start listening to digital pin 7, without an
-
Arduino Response: (No response)
- Description: Since the command did not include an
id, no response is sent from the Arduino.
- Description: Since the command did not include an
idis optional in all commands.- If
idis provided in the command, the Arduino includes the sameidin the response. - If no
idis included in the command, the Arduino does not send a response for that command.