Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Readme.md for Raspberry Pi 5 i2c enabling #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions powerboard/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,68 @@ make
```bash
make clean
```
## I2C enable for RaspBerry Pi 5 with Raspi-OS (debian)
Create enable_i2c.sh script:
```bash
cd ~
nano enable_i2c.sh
```

Copy script inside enable_i2c.sh:
```bash
#!/bin/bash

# Check root execution script
if [ "$EUID" -ne 0 ]; then
echo "Please use root shell (sudo)"
exit 1
fi

# Enable i2C on /boot/config.txt
CONFIG_FILE="/boot/config.txt"

if grep -q "^dtparam=i2c_arm=on" "$CONFIG_FILE"; then
echo "I2C já está habilitado no $CONFIG_FILE."
else
echo "Enabling I2C on $CONFIG_FILE..."
echo "dtparam=i2c_arm=on" >> "$CONFIG_FILE"
fi

# Load i2c-dev module
echo "Loading i2c-dev module..."
modprobe i2c-dev

# Verify i2c module load
if lsmod | grep -q i2c_dev; then
echo "i2c-dev module successfully charged."
else
echo "i2c-dev module charge error."
exit 1
fi

# Verify /dev/i2c-1 device available
if [ -e /dev/i2c-1 ]; then
echo "/dev/i2c-1 available."
else
echo "/dev/i2c-1 unnavailable. Need to reboot system."
echo "Do you want reboot now? (s/n)"
read -r resposta
if [ "$resposta" == "s" ]; then
echo "System rebooting..."
reboot
else
echo "System needs to be rebooted to finish I2C enabling."
fi
fi
```
Press Ctrl + O to save para salvar enable_i2c.sh then Ctrl + X to get out from nano editor.

Make enable_i2c.sh runnable
```bash
chmod +x enable_i2c.sh
```
Now run enable_i2c.sh
```bash
sudo ./enable_i2c.sh
```
Continue to install modules.