Temperature Controller Application

This sample application demonstrates a basic Temperature Controller using the AD-RPI-T1LPSE-SL board, two AD-SWIOT1L-SL boards, a Raspberry Pi, a fan actuator and a temperature sensor. The system reads temperature data and adjusts fan speed (via SWIOT1L output) based on configurable thresholds and hysteresis.

Prerequisites

  • Python 3.8 or newer (3.8–3.11 tested with pyadi-iio). Ensure that a compatible version is installed on your system before continuing. Older versions (<3.8) may not work reliably with pyadi-iio.

  • Git command-line tools installed.

  • Raspberry Pi with Kuiper 2 image installed. Follow the instructions in the ADI Kuiper Linux documentation to prepare the Raspberry Pi.

  • Ensure that the first two Software Setup steps described in Software Setup (Downloading and Flashing the Micro-SD Card and Configuring the Micro-SD Card) are performed with the Kuiper 2 image, not with previous Kuiper releases. These steps must be redone after flashing Kuiper 2 to ensure proper compatibility before continuing.

Hardware Setup

https://media.githubusercontent.com/media/plescaevelyn/adi-documentation/t1lpse-temp-controller/docs/solutions/reference-designs/ad-rpi-t1lpse-sl/sample_application/temperature_controller_system.png

Figure 1 Temperature Controller System

Equipment Needed

  • 1x AD-RPI-T1LPSE-SL Board

  • 2x AD-SWIOT1L-SL Boards

  • 1x Raspberry Pi 4 Model B running Kuiper 2

  • 1x TMP01 Temperature Sensor

  • 1x MC002103 DC Axial Fan

  • 1x Raspberry Pi USB Type-C Power Supply (5V, 3A)

  • 1x Power Resistor (6.2Ω, 10W was used by us)

  • 1x Power Supply for the Power Resistor (5V, 1A was used by us)

Setup Procedure

  1. Connect the AD-RPI-T1LPSE-SL board to the Raspberry Pi via the 40-pin header

  2. Connect the two AD-SWIOT1L-SL boards to the AD-RPI-T1LPSE-SL board via the T1L connectors

  3. Connect the TMP01 temperature sensor to the first AD-SWIOT1L-SL board

    The first SWIOT1L-SL board is used to both power the TMP01 sensor and measure its analog output voltage (VPTAT), which encodes the temperature.

    • Channel 3 (CH3) is configured as a Voltage Output and provides the sensor supply voltage. Connect:

      • CH3 SWIOTMP01 V+

      • CH3 GNDTMP01 GND

    • Channel 4 (CH4) is configured as a Voltage Input to measure the TMP01 analog output. Connect:

      • CH4 SWIOTMP01 VOUT

      • CH4 GNDTMP01 GND

    Note

    CH3 provides a regulated 5 V supply to power the TMP01, while CH4 is configured as a high-impedance voltage input with a 0–5 V range to measure the TMP01 VOUT signal. Both channels must share the same ground reference with the sensor.

  4. Power on the power resistor. Attach the power resistor to the TMP01 sensor to simulate temperature changes via rubber bands or similar means to dissipate heat. The power resistor acts as a heat source simulating a GPU under load (similar to running a graphics-intensive application like SuperTuxKart).

  5. Connect the fan actuator to the second AD-SWIOT1L-SL board

    The second SWIOT1L-SL board drives the fan according to the control loop.

    • The fan is powered directly from channel 0, configured as a Voltage Output:

      • CH0 SWIOFan +

      • CH0 GNDFan

    • Connect the tachometer output to channel 1 to monitor fan speed (optional):

      • CH1 SWIOFan Tach Out

  6. Power the Raspberry Pi with a 5V, 3A USB Type-C power supply.

Software Setup

Repository Cloning

  1. Clone the repository and checkout the swiot branch:

    analog@analog:~$
    
    git clone https://github.com/analogdevicesinc/pyadi-iio.git
    
    analog@analog:~$
    
    cd pyadi-iio
    
    analog@analog:~/pyadi-iio$
    
    git checkout swiot
    
  2. Install Python dependencies:

    analog@analog:~$
    
    python3 -m venv ./venv
    
    analog@analog:~$
    
    source venv/bin/activate
    
    analog@analog:~$
    
    pip install -e .
    
    analog@analog:~$
    
    pip install matplotlib
    

Firmware Flashing

Each AD-SWIOT1L-SL must be updated with the provided firmware image.

  1. Follow the official update instructions here: Updating the AD-SWIOT1L-SL firmware.

  2. Repeat the process for both boards.

  3. Use the firmware images provided below. These images configure the boards with static IP addresses:

    • The first board will have the 192.168.97.40 IP address

    • The second board will have the 192.168.97.41 IP address

    Four different firmware images are provided. We recommend using the ones mentioned above. You may use the other two images if you wish to change the IP addresses of the boards or to extend the application.

Applying Overlays

Overlays are required to enable the proper device tree configurations for the AD-RPI-T1LPSE-SL HAT.

Open a terminal and write this command:

analog@analog:~$
sudo tee -a /boot/config.txt <<'EOF'
  dtoverlay=rpi-t1lpse-apl
  dtoverlay=rpi-t1lpse-class12
  EOF

Network Setup

The Raspberry Pi has two Ethernet interfaces connected to the two AD-SWIOT1L-SL boards. We will create two persistent NetworkManager connections with autoconnect enabled for each interface in order to communicate with the boards:

  • eth1 will use 192.168.97.30/32 and route to the SWIOT1L board at 192.168.97.41

  • eth2 will use 192.168.97.31/32 and route to the SWIOT1L board at 192.168.97.40

Open the terminal and run the following commands.

  1. Add the wired connection interfaces:

    analog@analog:~$
    
    sudo nmcli connection add \
       type ethernet \
       ifname eth1 \
       con-name "Wired connection 2" \
       ipv4.method manual \
       ipv4.addresses 192.168.97.30/32 \
       ipv4.routes "192.168.97.41/32" \
       ipv6.method disabled \
       connection.autoconnect yes
    
    
    
    analog@analog:~$
    
    sudo nmcli connection add \
       type ethernet \
       ifname eth2 \
       con-name "Wired connection 3" \
       ipv4.method manual \
       ipv4.addresses 192.168.97.31/32 \
       ipv4.routes "192.168.97.40/32" \
       ipv6.method disabled \
       connection.autoconnect yes
    
  2. Activate the new connections:

    analog@analog:~$
    
    sudo nmcli connection up "Wired connection 2"
    
    analog@analog:~$
    
    sudo nmcli connection up "Wired connection 3"
    
  3. Reboot the Raspberry Pi to ensure autoconnect is applied:

    analog@analog:~$
    
    sudo reboot
    
  4. Verify that the new connections are active:

    analog@analog:~$
    
    nmcli connection show
    
    https://media.githubusercontent.com/media/plescaevelyn/adi-documentation/t1lpse-temp-controller/docs/solutions/reference-designs/ad-rpi-t1lpse-sl/sample_application/ad-rpi-t1lpse-sl-sample-application-nmcli-conn-show.png

    Figure 2 Example of active NetworkManager connections

  5. Verify routing and connectivity to the boards:

    analog@analog:~$
    
    ip route
    
    analog@analog:~$
    
    ping 192.168.97.40
    
    analog@analog:~$
    
    ping 192.168.97.41
    

Application Execution

When executed, the demo continuously reads temperature from the external TMP01 and applies a simple thermostat hysteresis:

  • Fan turns ON when temperature is ≥ TEMP_ON

  • Fan turns OFF when temperature is ≤ TEMP_OFF

  • Between thresholds, the fan keeps its previous state

The thresholds are configured via command-line arguments (see below). The application validates that TEMP_OFF < TEMP_ON; otherwise it exits with an error.

The on-board ADT75 is included as a secondary reference measurement to provide a quick sanity check that the SWIOT1L-SL is operational and to indicate local ambient/board temperature.

During runtime, the application prints sensor readings and fan state in the console, and displays two plots:

  • Temperature vs Time — external TMP01 temperature and the on-board ADT75 temperature from the SWIOT1L-SL “temperature sensor board”, with ON/OFF thresholds.

  • Fan State vs Time — graphical representation of when the fan is active.

Command-line arguments

The demo accepts optional command-line arguments to select the IP addresses for each SWIOT1L-SL board and to configure the thermostat thresholds:

  • --temp-ip: IP address of the SWIOT1L-SL board that powers/reads the TMP01 and provides the ADT75 reference trace (default: 192.168.97.41)

  • --fan-ip: IP address of the SWIOT1L-SL board that drives the fan (default: 192.168.97.40)

  • --temp-on: temperature in °C at/above which the fan turns ON

  • --temp-off: temperature in °C at/below which the fan turns OFF

Note

--temp-off must be strictly less than --temp-on (hysteresis condition).

Running the Application

Run the Temperature Controller example with example thresholds:

analog@analog:~$
cd examples/rpi_t1lpse
analog@analog:~/examples/rpi_t1lpse$
python3 temperature_controller.py --temp-on 50 --temp-off 40

Specify board IP addresses and thresholds:

analog@analog:~$
python3 temperature_controller.py \
   --temp-ip 192.168.97.41 \
   --fan-ip 192.168.97.40 \
   --temp-on 50 \
   --temp-off 40
https://media.githubusercontent.com/media/plescaevelyn/adi-documentation/t1lpse-temp-controller/docs/solutions/reference-designs/ad-rpi-t1lpse-sl/sample_application/ad-rpi-t1lpse-sl-sample-application-console-output.png

Figure 3 Example Console Output of the Temperature Controller Application

https://media.githubusercontent.com/media/plescaevelyn/adi-documentation/t1lpse-temp-controller/docs/solutions/reference-designs/ad-rpi-t1lpse-sl/sample_application/ad-rpi-t1lpse-sl-sample-application-plot-output.png

Figure 4 Example Plot Result of the Temperature Controller Application

System characterization

After running the application, the resulting temperature and fan state plots can be used to characterize the thermal behavior of the system.

Based on this characterization, appropriate thermostat thresholds may be chosen and applied either as defaults or via command-line arguments.

Wide thresholds (for example, fan ON at 100 °C and OFF at 0 °C) may be used during initial bring-up or validation, while tighter thresholds can be selected for normal operation.

https://media.githubusercontent.com/media/plescaevelyn/adi-documentation/t1lpse-temp-controller/docs/solutions/reference-designs/ad-rpi-t1lpse-sl/sample_application/ad-rpi-t1lpse-sl-sample-application-step-response.png

Figure 5 Temperature response and fan state during system characterization

Use Cases

This demo illustrates how the AD-RPI-T1LPSE-SL platform together with AD-SWIOT1L-SL boards can be applied in:

  • Thermal management - automatically controlling fans in enclosures or test setups

  • Process monitoring - maintaining temperature ranges in small-scale industrial or lab equipment

  • Educational examples - demonstrating closed-loop control