Use case: Configure a device with the GUI
Goal
Add an ADXL345 accelerometer to a Raspberry Pi 4 with the GUI: set up the project, add the part and its interrupt, validate, build and deploy the overlay, and read the acceleration back over the network.
What you need
Item |
Details |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Board / carrier |
Raspberry Pi 4 Model B, running ADI Kuiper |
||||||||||||
Evaluation board / part |
MikroElektronika Accel Click (ADXL345), set for I2C at address
|
||||||||||||
Wiring |
Five jumper wires from the Click to the Pi’s 40-pin header:
|
||||||||||||
Cables and power |
The Pi’s USB-C power supply; an Ethernet cable from the Pi to the host.
Here the host shares its connection over that cable, and the Pi gets
|
||||||||||||
Host |
Linux machine with Analog Attach installed (see Installation),
a web browser, |
||||||||||||
Software versions |
Analog Attach 0.2.0; the ADI Linux tree ( |
Steps
Step 1: Wire the Click
With the Pi off, connect the Click as in the table above. On the Pi 4,
GPIO 2 and 3 are the I2C bus labelled i2c1 and i2c_arm in its
devicetree.
Step 2: Start the GUI and set up the project
mkdir -p ~/work/rpi4-adxl345 && cd ~/work/rpi4-adxl345
analog-attach gui
The browser opens on the Project setup (see The project setup):
Step |
Value |
|---|---|
Ecosystem |
Linux |
Linux tree |
|
Base devicetree |
|
Overlay |
|
Then click Create Overlay. The workspace opens.
Figure 1 The base devicetree step, with bcm2711-rpi-4-b.dts among the suggestions
Step 3: Add the ADXL345
Click + Add Device and type
adxl345. Clickadi,adxl345.Bus: i2c_arm · i2c1 (
/soc/i2c@7e804000).Address:
1d.Keep Turn i2c1 on ticked: the bus is disabled in the Pi 4’s base devicetree, and the overlay enables it.
Leave Name and Label empty, and click + Add Device under the preview. The console shows the
analog-attach addit ran.
See Adding devices for every field of the panel.
Figure 2 Add Device with adi,adxl345 picked, on the bus i2c1 at the address 1d
Step 4: Set the interrupt
The new node opens in the node card. Its required interrupt-parent and
interrupts are missing, and validation says so.
interrupt-parent: pickgpio.interrupts:27in the first cell andIRQ_TYPE_EDGE_RISINGin the second.
Each change is written to the overlay as you make it (see Properties).
Figure 3 The ADXL345’s node card with interrupt-parent and interrupts set
Step 5: Validate
The GUI validates after every change. The header now says Valid, and the
Validation tab of the right column has no errors. Had the bus been left
off, a warning there would say that Linux won’t probe the device (see
Validate, build and deploy).
Step 6: Build and deploy
Click Build Overlay. The console ends with
Built overlay.dtbo.Open the settings (the gear), the Project tab, and set
BOARD_IPto the Pi’s address,10.42.0.196; the default isanalog.local.BOARD_USERstaysanalog. See Set the target.Click Deploy, and type the password of
analogwhen asked. The console shows the script copyingoverlay.dtboto the Pi, addingdtoverlay=overlaytoconfig.txtand rebooting the Pi.
Result
When the Pi is back, the ADXL345 is an IIO device:
iio_info -u ip:10.42.0.196 | grep -A3 adxl345
lists adxl345 with its channels accel_x, accel_y and accel_z.
Read the raw values on the Pi:
$ ssh analog@10.42.0.196
$ cd /sys/bus/iio/devices/iio:device0 # the device whose name is adxl345
$ cat name in_accel_x_raw in_accel_y_raw in_accel_z_raw
adxl345
2
1
253
With the board lying flat, X and Y are close to 0 and Z reads about 253: 1 g, gravity, at about 3.9 mg per count.
The workfile the GUI wrote:
/dts-v1/;
/plugin/;
/ {
fragment@0 {
target = <&i2c_arm>;
__overlay__ {
status = "okay";
adxl345: accelerometer@1d {
compatible = "adi,adxl345";
reg = <0x1d>;
interrupt-parent = <&gpio>;
interrupts = <27 1>;
};
};
};
};
With Name and Label left empty, the node is named
accelerometer@1d and labelled adxl345. IRQ_TYPE_EDGE_RISING is
written as its value, 1.
Troubleshooting
No adxl345 in iio_info. On the Pi,
sudo i2cdetect -y 1should showUUat1d. A number at53means the Click’s address jumper is the other way: setregto0x53in the node card, then build and deploy again. Nothing at all: check the wiring.Deploy can’t reach the Pi.
analog.localneeds mDNS; setBOARD_IPto the Pi’s IP address. See Troubleshooting.
Next steps
Use case: Configure a device with the CLI only: the same from the command line.
Use case: GUI with an AI agent: the GUI with its Assistant, on another board.
GUI Guide: the GUI in detail.