BalenaOS, RPI and HAT (OLED, RGB and FAN)

more progress!

did some research here and here.
I followed the first link’s thread, asked for help and followed the advice - didn’t work.
the second link’s thread suggested success, so I tried to replicate as much as I could… and finally figured it out.
putting everything together:

dockertemplate:

FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-python:3.11-build
RUN pip3 install Pillow adafruit-circuitpython-ssd1306 RPi.GPIO smbus
WORKDIR /usr/src/app
COPY . ./
CMD ["python3","-u","src/app.py"]

app.py (the source oled, fan and rgb scripts now ‘function’ without modification)

so to summarize:

  1. adjust the balena base image
  2. install all the required modules either using requirements or RUN pip3 install
  3. have the correct script loaded into app.py

moving on, the temperature and network details on the oled are not correct.

temp data problem
the original temp method uses ‘vcgencmd
with or without it installed, it doesn’t seem to work.
this also means the fan temp script won’t work as intended.

the oled script code:

    cmd = os.popen('vcgencmd measure_temp').readline()
    CPU_TEMP = cmd.replace("temp=","Temp:").replace("'C\n","C")

returns logs:

CPU_TEMP: Can't open device file: /dev/vcio

I tried to add /dev/vcio to the dockercompose file but that didn’t change anything.

network data problem
using balena scan, I know what the target device’s local network address is (192.168.A.B). the oled, however, shows a different address. since the device is not physically connected to the network, we know the network adapter data is wrong too. the oled shows “etho0: 172.17.0.2”, but it should be “wlan:192.168.A.B”. I assume this means it’s retrieving the containers details and not the hosts? how do I go about getting the hosts details?

I have a few more ideas to try but in the mean time, as usual, any advice or thoughts?
please and thanks!