Skip to content

Commit 336325c

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 336325c

8 files changed

+341
-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: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
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+
4. After flashing, verify that each board responds to ping:
152+
153+
.. shell::
154+
:user: analog
155+
:group: analog
156+
:show-user:
157+
158+
$ ping 192.168.97.40
159+
$ ping 192.168.97.41
160+
161+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-ping.png
162+
:align: center
163+
:width: 500
164+
165+
Ping Results
166+
167+
168+
Network Setup
169+
~~~~~~~~~~~~~
170+
171+
The Raspberry Pi has two Ethernet interfaces connected to the two
172+
:adi:`AD-SWIOT1L-SL` boards. We will create two persistent NetworkManager
173+
connections with autoconnect enabled for each interface in order to communicate
174+
with the boards:
175+
176+
- ``eth1`` will use ``192.168.97.30/32`` and route to the SWIOT1L board at ``192.168.97.41``
177+
- ``eth2`` will use ``192.168.97.31/32`` and route to the SWIOT1L board at ``192.168.97.40``
178+
179+
Open the terminal and run the following commands.
180+
181+
1. (Optional) Remove existing connections with the same names:
182+
183+
.. shell::
184+
:user: analog
185+
:group: analog
186+
:show-user:
187+
188+
$ sudo nmcli connection delete "Wired connection 2" 2>/dev/null || true
189+
$ sudo nmcli connection delete "Wired connection 3" 2>/dev/null || true
190+
191+
2. Add the wired connection interfaces:
192+
193+
.. shell::
194+
:user: analog
195+
:group: analog
196+
:show-user:
197+
198+
$ sudo nmcli connection add \
199+
type ethernet \
200+
ifname eth1 \
201+
con-name "Wired connection 2" \
202+
ipv4.method manual \
203+
ipv4.addresses 192.168.97.30/32 \
204+
ipv4.routes "192.168.97.41/32" \
205+
ipv6.method disabled \
206+
connection.autoconnect yes
207+
208+
$ sudo nmcli connection add \
209+
type ethernet \
210+
ifname eth2 \
211+
con-name "Wired connection 3" \
212+
ipv4.method manual \
213+
ipv4.addresses 192.168.97.31/32 \
214+
ipv4.routes "192.168.97.40/32" \
215+
ipv6.method disabled \
216+
connection.autoconnect yes
217+
218+
3. Activate the new connections:
219+
220+
.. shell::
221+
:user: analog
222+
:group: analog
223+
:show-user:
224+
225+
$ sudo nmcli connection up "Wired connection 2"
226+
$ sudo nmcli connection up "Wired connection 3"
227+
228+
4. (Optional) Reboot the Raspberry Pi to ensure autoconnect is applied:
229+
230+
.. shell::
231+
:user: analog
232+
:group: analog
233+
:show-user:
234+
235+
$ sudo reboot
236+
237+
5. Verify that the new connections are active:
238+
239+
.. shell::
240+
:user: analog
241+
:group: analog
242+
:show-user:
243+
244+
$ nmcli connection show
245+
246+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-nmcli-conn-show.png
247+
:align: center
248+
:width: 500
249+
250+
Example of active NetworkManager connections
251+
252+
6. Verify routing and connectivity to the boards:
253+
254+
.. shell::
255+
:user: analog
256+
:group: analog
257+
:show-user:
258+
259+
$ ip route
260+
$ ping 192.168.97.40
261+
$ ping 192.168.97.41
262+
263+
264+
Application Execution
265+
~~~~~~~~~~~~~~~~~~~~~
266+
267+
When executed, the demo continuously reads the temperature from the :adi:`TMP01`
268+
sensor and compares it against the configured thresholds. The fan is
269+
automatically turned **ON** once the temperature rises above ``TEMP_ON``
270+
(default 27 °C) and turned **OFF** once the temperature falls below
271+
``TEMP_OFF`` (default 26 °C). This hysteresis prevents rapid switching when the
272+
temperature hovers around the threshold.
273+
274+
During runtime, the application prints sensor readings and fan state in the
275+
console, and displays two plots:
276+
277+
- **Temperature vs Time** — TMP01 and ADT75 temperature measurements with ON/OFF
278+
thresholds.
279+
- **Fan State vs Time** — graphical representation of when the fan is active.
280+
281+
Run the Temperature Controller example:
282+
283+
.. shell::
284+
:user: analog
285+
:group: analog
286+
:show-user:
287+
288+
$ cd examples/rpi_t1lpse
289+
$ python3 temperature_controller.py
290+
291+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-console-output.png
292+
:align: center
293+
:width: 500
294+
295+
Example Console Output of the Temperature Controller Application
296+
297+
.. figure:: ad-rpi-t1lpse-rpiz-sample-application-plot-output.png
298+
:align: center
299+
:width: 500
300+
301+
Example Plot Result of the Temperature Controller Application
302+
303+
304+
Use Cases
305+
^^^^^^^^^
306+
307+
This demo illustrates how the :adi:`AD-AD-RPI-T1LPSE-SL-RPIZ` platform together
308+
with :adi:`AD-SWIOT1L-SL` boards can be applied in:
309+
310+
- **Thermal management** - automatically controlling fans in enclosures or test
311+
setups
312+
- **Process monitoring** - maintaining temperature ranges in small-scale
313+
industrial or lab equipment
314+
- **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)