Skip to content

Commit 5c1549d

Browse files
committed
solutions/reference-designs/eval-cn0591-rpiz/sample_application: Add documentation that showcases running the Temperature Controller software application
- Add Temperature Controller Application page with Prerequisites, Hardware and Software setup subsections - Describe the purpose of the application and provide steps necessary to setup and run locally using the required hardware components - Add images of the physical setup and the terminal results of running the commands as a visual support and verification source for users - Link the sample application page to the official page of EVAL-CN0591-RPIZ Signed-off-by: Evelyn Plesca <evelyn-iulia.plesca@analog.com>
1 parent fffbe83 commit 5c1549d

8 files changed

+349
-0
lines changed

docs/solutions/reference-designs/ad-rpi-t1lpse-sl/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ Hardware Registration
489489
videos, and more when you :adi:`register <AD-RPI-T1LPSE-SL?&v=RevC>` your
490490
hardware.
491491

492+
Sample Application
493+
------------------
494+
495+
.. toctree::
496+
:maxdepth: 2
497+
:glob:
498+
499+
*/index
500+
492501
Help and Support
493502
-------------------
494503

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 322 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,322 @@
1+
Temperature Controller Application
2+
==================================
3+
4+
This sample application demonstrates a basic Temperature Controller using the
5+
:adi:`AD-AD-RPI-T1LPSE-SL-RPIZ` board, two :adi:`AD-SWIOT1L-SL` boards, a
6+
Raspberry Pi, a fan actuator and a temperature sensor. The system reads
7+
temperature data and adjusts fan speed (via SWIOT1L output) based on
8+
configurable thresholds and hysteresis.
9+
10+
Prerequisites
11+
-------------
12+
13+
- Python 3.8 or newer (3.8–3.11 tested with pyadi-iio). Ensure that a
14+
compatible version is installed on your system before continuing. Older
15+
versions (<3.8) may not work reliably with pyadi-iio.
16+
17+
- Git command-line tools installed.
18+
19+
- Raspberry Pi with :adi:`Kuiper 2` image installed. Follow the instructions in
20+
the :external+adi-kuiper-gen:doc:`index` documentation to prepare the
21+
Raspberry Pi.
22+
23+
- Ensure that the first two **Software Setup** steps described in
24+
:ref:`software-setup` (*Downloading and Flashing the Micro-SD Card* and
25+
*Configuring the Micro-SD Card*) are performed **with the Kuiper 2 image**,
26+
not with previous Kuiper releases. These steps must be redone after flashing
27+
Kuiper 2 to ensure proper compatibility before continuing.
28+
29+
30+
Hardware Setup
31+
--------------
32+
33+
.. figure:: temperature_controller_system.png
34+
:align: center
35+
:width: 500
36+
37+
Temperature Controller System
38+
39+
**Equipment Needed**
40+
41+
- 1x :adi:`AD-AD-RPI-T1LPSE-SL-RPIZ` Board
42+
- 2x :adi:`AD-SWIOT1L-SL` Boards
43+
- 1x Raspberry Pi 4 Model B running Kuiper 2
44+
- 1x :adi:`TMP01` Temperature Sensor
45+
- 1x MC002103 DC Axial Fan
46+
- 1x Raspberry Pi USB Type-C Power Supply (5V, 3A)
47+
48+
**Setup Procedure**
49+
50+
1. Connect the :adi:`AD-AD-RPI-T1LPSE-SL-RPIZ` board to the Raspberry Pi via the
51+
40-pin header
52+
53+
2. Connect the two :adi:`AD-SWIOT1L-SL` boards to the
54+
:adi:`AD-AD-RPI-T1LPSE-SL-RPIZ` board via the T1L connectors
55+
56+
3. Connect the first :adi:`AD-SWIOT1L-SL` board to the :adi:`TMP01` temperature
57+
sensor
58+
59+
The first SWIOT1L-SL board is used to both power the TMP01 sensor and
60+
measure its analog output voltage (VPTAT), which encodes the temperature.
61+
62+
- **Channel 3 (CH3)** is configured as a **Voltage Output** and provides
63+
the sensor supply voltage. Connect:
64+
65+
- ``CH3 SWIO`` → ``TMP01 V+``
66+
- ``CH3 GND`` → ``TMP01 GND``
67+
68+
- **Channel 4 (CH4)** is configured as a **Voltage Input** to measure the
69+
TMP01 analog output. Connect:
70+
71+
- ``CH4 SWIO`` → ``TMP01 VOUT``
72+
- ``CH4 GND`` → ``TMP01 GND``
73+
74+
.. note::
75+
76+
CH3 provides a regulated 5 V supply to power the TMP01, while CH4 is
77+
configured as a high-impedance voltage input with a 0–5 V range to measure
78+
the TMP01 VOUT signal. Both channels must share the same ground reference
79+
with the sensor.
80+
81+
4. Connect the second :adi:`AD-SWIOT1L-SL` board to the fan actuator
82+
83+
The second SWIOT1L-SL board drives the fan according to the control loop.
84+
85+
- The fan is powered directly from channel 0, configured as a
86+
**Voltage Output**:
87+
88+
- ``CH0 SWIO`` → ``Fan +``
89+
- ``CH0 GND`` → ``Fan −``
90+
91+
- Connect the tachometer output to channel 1 to monitor fan speed (optional):
92+
93+
- ``CH1 SWIO`` → ``Fan Tach Out``
94+
95+
5. Power the Raspberry Pi with a 5V, 3A USB Type-C power supply.
96+
97+
98+
Software Setup
99+
--------------
100+
101+
Repository Cloning
102+
~~~~~~~~~~~~~~~~~~
103+
104+
1. Clone the repository and checkout the *swiot* branch:
105+
106+
.. shell::
107+
:user: analog
108+
:group: analog
109+
:show-user:
110+
111+
$ git clone https://github.com/analogdevicesinc/pyadi-iio.git
112+
$ cd pyadi-iio
113+
$ git checkout swiot
114+
115+
2. Install Python dependencies:
116+
117+
.. shell::
118+
:user: analog
119+
:group: analog
120+
:show-user:
121+
122+
$ python3 -m venv ./venv
123+
$ source venv/bin/activate
124+
$ pip install -e .
125+
126+
127+
Firmware Flashing
128+
~~~~~~~~~~~~~~~~~
129+
130+
Each :adi:`AD-SWIOT1L-SL` must be updated with the provided firmware image.
131+
132+
1. Follow the official update instructions here:
133+
`Updating the AD-SWIOT1L-SL firmware <https://analogdevicesinc.github.io/documentation/solutions/reference-designs/ad-swiot1l-sl/software-guide/index.html#updating-the-ad-swiot1l-sl-firmware>`_.
134+
135+
2. Repeat the process for **both boards**.
136+
137+
3. Use the firmware images provided below. These images configure the boards with
138+
static IP addresses:
139+
140+
- The first board will have the ``192.168.97.40`` IP address
141+
- The second board will have the ``192.168.97.41`` IP address
142+
143+
.. ADMONITION:: Download
144+
145+
:download:`Firmware for temperature controller application <swiot1l_firmware.zip>`
146+
147+
Four different firmware images are provided. We recommend using the ones
148+
mentioned above. You may use the other two images if you wish to change the
149+
IP addresses of the boards or to extend the application.
150+
151+
152+
Applying Overlays
153+
~~~~~~~~~~~~~~~~~
154+
155+
Overlays are required to enable the proper device tree configurations for the :adi:`AD-RPI-T1LPSE-SL-RPIZ` HAT.
156+
157+
Open a terminal and write this command:
158+
159+
.. shell::
160+
:user: analog
161+
:group: analog
162+
:show-user:
163+
164+
$ sudo tee -a /boot/firmware/config.txt <<'EOF'
165+
dtoverlay=rpi-t1lpse-apl
166+
dtoverlay=rpi-t1lpse-class12
167+
EOF
168+
169+
170+
Network Setup
171+
~~~~~~~~~~~~~
172+
173+
The Raspberry Pi has two Ethernet interfaces connected to the two
174+
:adi:`AD-SWIOT1L-SL` boards. We will create two persistent NetworkManager
175+
connections with autoconnect enabled for each interface in order to communicate
176+
with the boards:
177+
178+
- ``eth1`` will use ``192.168.97.30/32`` and route to the SWIOT1L board at ``192.168.97.41``
179+
- ``eth2`` will use ``192.168.97.31/32`` and route to the SWIOT1L board at ``192.168.97.40``
180+
181+
Open the terminal and run the following commands.
182+
183+
1. Add the wired connection interfaces:
184+
185+
.. shell::
186+
:user: analog
187+
:group: analog
188+
:show-user:
189+
190+
$ sudo nmcli connection add \
191+
type ethernet \
192+
ifname eth1 \
193+
con-name "Wired connection 2" \
194+
ipv4.method manual \
195+
ipv4.addresses 192.168.97.30/32 \
196+
ipv4.routes "192.168.97.41/32" \
197+
ipv6.method disabled \
198+
connection.autoconnect yes
199+
200+
$ sudo nmcli connection add \
201+
type ethernet \
202+
ifname eth2 \
203+
con-name "Wired connection 3" \
204+
ipv4.method manual \
205+
ipv4.addresses 192.168.97.31/32 \
206+
ipv4.routes "192.168.97.40/32" \
207+
ipv6.method disabled \
208+
connection.autoconnect yes
209+
210+
2. Activate the new connections:
211+
212+
.. shell::
213+
:user: analog
214+
:group: analog
215+
:show-user:
216+
217+
$ sudo nmcli connection up "Wired connection 2"
218+
$ sudo nmcli connection up "Wired connection 3"
219+
220+
3. Reboot the Raspberry Pi to ensure autoconnect is applied:
221+
222+
.. shell::
223+
:user: analog
224+
:group: analog
225+
:show-user:
226+
227+
$ sudo reboot
228+
229+
4. Verify that the new connections are active:
230+
231+
.. shell::
232+
:user: analog
233+
:group: analog
234+
:show-user:
235+
236+
$ nmcli connection show
237+
238+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-nmcli-conn-show.png
239+
:align: center
240+
:width: 500
241+
242+
Example of active NetworkManager connections
243+
244+
5. Verify routing and connectivity to the boards:
245+
246+
.. shell::
247+
:user: analog
248+
:group: analog
249+
:show-user:
250+
251+
$ ip route
252+
$ ping 192.168.97.40
253+
$ ping 192.168.97.41
254+
255+
256+
Application Execution
257+
~~~~~~~~~~~~~~~~~~~~~
258+
259+
When executed, the demo continuously reads the temperature from the :adi:`TMP01`
260+
sensor and compares it against the configured thresholds. The fan is
261+
automatically turned **ON** once the temperature rises above ``TEMP_ON``
262+
(default 27 °C) and turned **OFF** once the temperature falls below
263+
``TEMP_OFF`` (default 26 °C). This hysteresis prevents rapid switching when the
264+
temperature hovers around the threshold.
265+
266+
During runtime, the application prints sensor readings and fan state in the
267+
console, and displays two plots:
268+
269+
- **Temperature vs Time** — TMP01 and ADT75 temperature measurements with ON/OFF
270+
thresholds.
271+
- **Fan State vs Time** — graphical representation of when the fan is active.
272+
273+
The application accepts optional command-line arguments to override the default
274+
IP addresses of the temperature sensor board and the fan control board. If no
275+
arguments are provided, the application falls back to the default IP addresses
276+
defined in the script.
277+
278+
Run the Temperature Controller example using the default configuration:
279+
280+
.. shell::
281+
:user: analog
282+
:group: analog
283+
:show-user:
284+
285+
$ cd examples/rpi_t1lpse
286+
$ python3 temperature_controller.py
287+
288+
To explicitly specify the board IP addresses:
289+
290+
.. shell::
291+
:user: analog
292+
:group: analog
293+
:show-user:
294+
295+
$ python3 temperature_controller.py \
296+
--temp-ip 192.168.97.41 \
297+
--fan-ip 192.168.97.40
298+
299+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-console-output.png
300+
:align: center
301+
:width: 500
302+
303+
Example Console Output of the Temperature Controller Application
304+
305+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-plot-output.png
306+
:align: center
307+
:width: 500
308+
309+
Example Plot Result of the Temperature Controller Application
310+
311+
312+
Use Cases
313+
^^^^^^^^^
314+
315+
This demo illustrates how the :adi:`AD-AD-RPI-T1LPSE-SL-RPIZ` platform together
316+
with :adi:`AD-SWIOT1L-SL` boards can be applied in:
317+
318+
- **Thermal management** - automatically controlling fans in enclosures or test
319+
setups
320+
- **Process monitoring** - maintaining temperature ranges in small-scale
321+
industrial or lab equipment
322+
- **Educational examples** - demonstrating closed-loop control
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5ba879cf0154aa9b43ee0f4be96c2bed2e4ebc40341efaba4745a98dc1432bae
3+
size 839110
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)