Remote Power Management
The Cube hast its own the manage the power of the connected Pis. It's possible to control the Power with the Button on the right side of the Cube or over a network through its COAP
based REST
API. All files for the Remote Power Management
are located in this repository.
#
Interact with itA simple testing client for Linux is included in the repository. It uses Docker and the libcoap library as backend.
Switch specific relay on:
./client.sh -m put -e '{"power":true}' coap://<IP>/api/relays/<1-7>
Switch all relays on:
./client.sh -m post -e '{"power":true}' coap://<IP>/api/relays
Get all relays:
./client.sh -m get coap://<IP>/api/relays
#
Open EndpointsOpen Endpoints require no authentication
- Change power of all relays at once:
PUT /api/relays
- Turn specific relay on:
PUT /api/relays/<id>
- Change power of the pis in the stack (1-6):
PUT /api/relays/stack
- Get power state of all relays:
GET /api/relays
- Get power of the pis in the stack (1-6):
GET /api/relays/stack
- Get power state of specific worker node:
GET /api/relays/<id>
Relay numbering
The Pis in the Cube are numbered from bot to top. The bottom Pi is connected to the relay with id 1 and the top Pi with the display iis connected to relay 7.
The device responds in JSON Format and can parse JSON payloads. Due to the restrictions of the device it's not possible to parse bigger incoming payloads. Because of this it is only possible at the time to change the powerstate of all relays at one endpoint at once.
To turn the node(s) on send '{"power":true}'
as payload.
To turn the node(s) off send '{"power":false}'
as payload.
#
ButtonThe Relays can be controlled with a button on the right side of the cube.
#
Short Button PressThe relays are activated one-by-one starting with relay seven (the head node). If the previous relay is already active the next relay gets activated.
#
Long Button PressPress the button for at least 1.5 seconds. When releasing the button all relays get turned off.
#
Very Long Button PressPress the button for at least 5 seconds. When releasing the button the controller will reset.
#
Update Controller FirmwareRequirements: Linux, Docker, Mini-USB-Cable, Screwdriver
Updating the Firmware can only be achieved through a USB connection due to the constraints of the device. To reach the USB port of the arduino it's probably necessary to dissemble the front or the top of the Cube.
Dissemble front or top and connect USB cable
Clone git repository
git clone https://code.fbi.h-da.de/pi-lab/remote-power-management.git
- Flash Arduino
<Serial Port>: Device in /dev
(default: /dev/ttyUSB0
)
<id>: Id of the Cube (1-9
with leading zero e.g. MAC=0x01
for Cube 1)
You can find the ID on the right side of the cube
make upload DEVICE=<Serial Port> MAC=0x<id>
Example
make upload DEVICE=/dev/ttyUSB0 MAC=0x01