User Tools

Site Tools


operations:rpiips

IPSPi1Hb: Raspberry Pi Internet Power Switch

An Internet Power Switch (IPS) has been built for Mt Pleasant. Its main purpose is to provide remote and local control of power to a small cluster in the computer room. This can be operated from the front panel of the device or remotely via a terminal window. There are also several Remote Switches which plug into a wall socket and allow remote control of a single device via WiFi. Software on the IPS allows for control of these devices.

IPS Usage

Local control

The front panel of the IPS consists of an Enable button and one button to control each of the 7 connected devices. There is a LED in each control button that indicates if power is on to the device. To avoid accidental toggling, the Enable button must be held on when controlling power to a device and released between button presses.

To turn power on/off to a device, hold down Enable and then press the button for the device you want to control.

Software/remote control

The Raspberry Pi PC in the IPS can be accessed via VNC or on a terminal with ssh. The password is the usual one.

  • VNC to ipspi1hb and start the Switch Interface app on the desktop, or…
  • ssh pi@ipspi1hb and type SwitchInterface.py

This starts a command-line interface that allows you to control power to devices. Type 'help' for a list of possible commands and 'help <command name>' for specific help on a command.

  • To get current status of devices:
    • status
  • To turn a device on:
    • on <device number>
  • To turn a device off:
    • off <device number>
  • To turn a device off and on again. This turns the device off, waits 15 sec, then turns it on again
    • reboot <device number>
  • Disable a device. This prevents switching of a device from the panel or from software. i.e. if you really don't want the device played with.
    • disable <device number>
  • Enable a device
    • enable <device number>
  • Name a device. The status display shows a short description of the attached device which you can change:
    • name <device number> <text>. e.g name 3 My computer

Remote Switch Usage

The remote switches can also be controlled from the Switch Interface software.

Local control

Coming soon…

Software/remote control

Connect to ipspi1hb via VNC or ssh as above and start the Switch Interface. The status command gives the status of all known remote switches. Each device has a short name rather than a number, e.g. RR01, and this is the label to use when controlling it. A longer description of the device can be given with the remote_description command and this will be displayed in the status output.

The remote switch checks in with the IPS PC regularly. The interval between checks is configurable via the remote_interval command. To turn the attached device on, off, or to reboot it, use the remote_on, remote_off or remote_reboot commands respectively. The command will remain pending until the device checks in when it will be executed. If however, the device is turned on or off locally after the command is issued, it will be ignored.

Hardware and Software

Hardware consists of a Raspberry Pi PC inside the IPS, connected to two relay boards for managing power switching and a custom-made circuit board primarily for managing input from front-panel buttons and displaying switch status on the panel.

Software running on the Raspberry Pi consists of four programs:

  1. A front-end program, SwitchInterface.py, runs from a terminal window. Multiple instances can be run at once. It provides a user interface for monitoring and control of the rack-mounted IPS and all available Remote Switches.
  2. Behind this is RemoteRelayServer.py which runs a MQTT server and manages input from buttons on the front panel of the IPS. The MQTT server accepts requests from SwitchInterface.py and from the Remote Switches. The Remote Switches are designed to have their WiFi switched off for most of the time to keep radio interference to a minimum, but report in once per minute (or at another configurable interval). RemoteRelayServer.py manages requests to switch this device and sends any update commands to the Remote Switch whenever it checks in on the network.
  3. RemoteRelayServer.py Interacts with the hardware in the rack-mounted IPS. It takes commands via MQTT from RemoteSelayServer.py and actually switches the corresponding relay. It also controls the LEDs that indicate status of the switches. The circuit board also has three temperature and humidity sensors attached and this software logs their values every minute to a SQL database.
  4. IPSTHServer.py provides temperature and humidity data to MONICA on request

The Remote Switches have Arduino-compatible ESP8266 NodeMCU microcontrollers to manage a single relay switch. Each microcontroller runs software to manage the relay, WiFi connection, MQTT communication, a local button and some LEDs. When powered on it will connect to the local WiFi network if configured or start up as an access point if not, allowing a local connection for initial configuration (which is saved to non-volatile memory for next time). The software is in the Arduino directory, called RelayControl.ino.

Network

Mount the SD card.

Enable ssh: touch /Volumes/boot/ssh

IP address: 131.217.63.5 hostname: ipspihb

interface eth0 static ip_address=131.217.61.28/26 # /26 = netmask of 255.255.255.192 static routers=131.217.61.1 static domain_name_servers=131.217.0.19

/home/www/auscope/opswiki/data/pages/operations/rpiips.txt · Last modified: 2019/08/19 03:41 by Jim Lovell