Viam modular component for Numato USB relays on Android devices
This module implements the Viam generic component API in an mcvella:generic:numato-relay-usb-android model. With this component, you can control Numato USB devices in your Viam Android projects.
Viam server must be running on an Android device that has OTG capabilities, with a Numato USB serial relay device connected.
Note that currently, the expectation is that this is the only USB serial device connected; it will assume the first serial device is a Numato relay.
To use this module, follow these instructions to add a module from the Viam Registry and select the mcvella:generic:numato-relay-usb-android
model from the mcvella:generic:numato-relay-usb-android
module.
Note
Before configuring your numato relay component, you must create a machine.
Navigate to the Config tab of your robot’s page in the Viam app.
Click on the Components subtab and click Create.
Select the generic
type, then select the mcvella:generic:numato-relay-usb-android
model.
Enter a name for your component and click Create.
On the new component panel, copy and paste the following attribute template into your pubsub’s Attributes box:
{
}
Note
For more information, see Configure a Robot.
The following attributes are available for mcvella:generic:numato-relay-usb-android
:
Name | Type | Inclusion | Description |
---|---|---|---|
A typical configuration might look like:
{
}
DoCommand() can be used to turn a relay on, turn a relay off, or read a relay's status.
Example:
# turn relay 0 on
await relay.do_command({'on': 0})
# read the status of relay 1
status = await relay.do_command({'read': 1})
# turn relay 1 on
await relay.do_command({'off': 1})
If the key on is passed to DoCommand(), the a integer value representing the index of a relay (starting with 0 for the first relay) is passed as the value. This will turn the specified relay on.
If the key off is passed to DoCommand(), the a integer value representing the index of a relay (starting with 0 for the first relay) is passed as the value. This will turn the specified relay off.
If the key read is passed to DoCommand(), the a integer value representing the index of a relay (starting with 0 for the first relay) is passed as the value. This will read and return the status for the specified relay, either "on" or "off".
Currently, when a Numato device is plugged-in, you must allow device access via the Android screen within 5 seconds of first DoCommand() call. This could be improved by adding fixed intent for the device in the module.