2. Client: Raspberry Pi

The Raspberry Pi client control the fan speed by sending a PWM signal through the GPIO pins.

Two pins are used:

  • The PWM pin used to output the PWM signal regulating the fan speed. It should be connected to the PWM input of the fans.
  • The RPM pin used to read the actual fan speed in RPM. It should be connected to the tachometer output of the fans.

2.1. PWM backend

By default, gpiozero will use whatever supported library is installed.

To manually set which backend to use, you can use the GPIOZERO_PIN_FACTORY environment variable.

See the gpiozero.pins documentation for more information.

2.2. Examples

Start the client:

# fand clientrpi

Start and use GPIO pin 17 for PWM, and pin 18 for tacho:

# fand server -W 17 -r 18

Start with verbose output and connect to server at server-host:1234:

# fand server -v -a server-host -P 1234

2.3. Python API

fand.clientrpi.SLEEP_TIME = 60

How much time to wait between updates

2.3.1. GpioRpm

class fand.clientrpi.GpioRpm(pin: int, managed: bool = True)[source]

Class to handle RPM tachometer input from a fan

Parameters:
  • pin – GPIO pin number to use
  • managed – set to true to have the GPIO device automatically closed when fand.util.terminate() is called
Raises:

GpioError – Received a gpiozero.GPIOZeroError

close() → None[source]

Close the GPIO device

Raises:GpioError – Received a gpiozero.GPIOZeroError
rpm = None

RPM value

update() → None[source]

Update the RPM value

2.3.2. GpioPwm

class fand.clientrpi.GpioPwm(pin: int, managed: bool = True)[source]

Class to handle PWM output for a fan

Parameters:
  • pin – GPIO pin number to use
  • managed – set to true to have the GPIO device automatically closed when fand.util.terminate() is called
Raises:

GpioError – Received a gpiozero.GPIOZeroError

close() → None[source]

Close the GPIO device

Raises:GpioError – Received a gpiozero.GPIOZeroError
pwm

PWM output value, backend is gpiozero.PWMLED.value

Raises:GpioError – Received a gpiozero.GPIOZeroError

2.3.3. add_gpio_device

fand.clientrpi.add_gpio_device(device: Union[GpioRpm, GpioPwm]) → None[source]

Add a GPIO device to the set of managed GPIO devices

Parameters:device – GPIO device to add
Raises:TerminatingError – Trying to add a socket but fand.util.terminating() is True

2.3.4. main

fand.clientrpi.main() → NoReturn[source]

Module entry point

2.3.5. daemon

fand.clientrpi.daemon(gpio_pwm: fand.clientrpi.GpioPwm, gpio_rpm: fand.clientrpi.GpioRpm, shelf_name: str = 'build-11968335-project-622900-fand', address: str = 'build-11968335-project-622900-fand', port: int = 9999) → None[source]

Main function of this module

Parameters:
  • gpio_pwm – GPIO device to use for PWM output
  • gpio_rpm – GPIO device to use for RPM input
  • shelf_name – Name of this shelf, used to communicate with the server
  • address – Server address or hostname
  • port – Port number to connect to