Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 9122

Graphics, sound and multimedia • Re: Grok, Europi-X, and nothing works...

$
0
0
continues...

I resplit the main code in two parts, one only for the encoder (and midi) and the other for the Adafruit SD1306 128x32 Oled

after several corrections, Grok updates himself and tries to correct the code.
Example. gpio readall doesnt work on rasp 5. I have to insert some other Ai answer (like Claude) to explain Grok that raspi-gpio is instead used in rasp 5, and pinctrl is used instead of gpio readall instruction...

If I close Grok, I have to feed back to him all these individual "fixes" again, otherwise he WILL restart repeating the same errors.
Completely confusing Rasp 5 only instructions sets and mixing everything together...
...

So....

After correcting the last issues i run pinctrl get 17,22,23 and got the status of those three pins connected to the encoder.
but they are not active. And obviously running the encoder-py script returns errors like
SOC cannot determine address of external peripherals... because those pins are inactive..

Grok suggests running a virtualvenv (althought with again wrong Pi 5 specific spelling. venv only suggests) to
debug the pins and the code before committing the

apt install python3 encoder.py

which fails..


The last "notable" instructions are in /boot/firmware/config.txt

dtoverlay=i2c-gpio,bus=4,i2c_gpio_sda=5,i2c_gpio_scl=6

and create a gpio_staus.sh script

nano /home/pi/gpio_status.sh
# Paste the script

#!/bin/bash

echo "GPIO Status (Raspberry Pi 5)"
echo "BCM | Physical Pin | Mode | Value | Pull"
echo "----|--------------|--------|-------|------"

for bcm in {0..27}
do
# Get pinctrl status for the GPIO
status=$(pinctrl get $bcm 2>/dev/null)
if [ -z "$status" ]; then
mode="UNKNOWN"
value="?"
pull="?"
else
# Extract mode (function), level, and pull
mode=$(echo "$status" | awk '{print $3}' | grep -o '[A-Z0-9]*')
value=$(echo "$status" | awk '{print $1}' | grep -o '[0-1]')
pull=$(echo "$status" | grep -o 'pu\|pd\|pn' || echo "?")
[ -z "$mode" ] && mode="UNKNOWN"
[ -z "$value" ] && value="?"
[ -z "$pull" ] && pull="?"
fi

# Map BCM to physical pin for relevant GPIOs
pin=""
case $bcm in
5) pin=29 ;;
6) pin=31 ;;
17) pin=11 ;;
22) pin=15 ;;
23) pin=16 ;;
*) pin="-" ;;
esac

printf "%-3s | %-12s | %-6s | %-5s | %-5s\n" "$bcm" "$pin" "$mode" "$value" "$pull"
done

-------- save and exit


chmod +x /home/pi/gpio_status.sh
./gpio_status.sh

---------

the breadboard is set up with all connections monitored with an external hardware scope...

i used physical pull up and decoupling caps instead of internal pull up for two of the three encoder pins if you wonder.
Only the Enc Switch pin is connected directly to the Pi gpio, with internal pull up. As if it would make any difference...
I tried modifying the enc code to all internal pull up also, but still pinctrl gives mode inactivity on all 17,22,23 pins...

This is the third day consecutive with Grok windows always open, I hope there are no blackouts...

Statistics: Posted by Zool64Pi — Sun May 25, 2025 10:18 am



Viewing all articles
Browse latest Browse all 9122

Trending Articles