Rpi4 cpu clock speed

Does anyone have an explanation for spontaneously switching the CPU clock speed back to 1000MHz?
It is a Rasperry pi 4 with sufficient cooling and running on hassio.
ha_clock_speed

Would the pi be clocking down to reduce power usage when not required? Your CPU load is pretty light?

Edit, just started monitoring mine and its rock solid so perhaps not. Do you have a decent PSU for it? Might be dropping the clockspeed if the voltage or current is too low?

1 Like

Sorry for the revival… may I ask how you got this data into Home Assistant? This is exactly what I’m looking for… specifically my RPi 4’s current CPU clock (and GPU if possible) along with the CPU temp, I want to make sure mine isn’t overheating where it is.

here the sensors I’m using

RPi CPU temp:

- platform: command_line
  name: "RPi CPU Temp"
  command: 'cat /sys/class/thermal/thermal_zone0/temp'
  unit_of_measurement: °C
  value_template: '{{ value | multiply(0.001) | round(1)}}'

RPi CPU frequency (two different implementation… still to be tested if any difference)

- platform: command_line
  name: "RPi CPU freq"
  command: 'cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq'
  unit_of_measurement: 'MHz'
  value_template: '{{ value | multiply(0.001) }}'
# https://www.home-assistant.io/integrations/cpuspeed/
- platform: cpuspeed
3 Likes

I get an error when adding this:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 315, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 506, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 323, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/cpuspeed/sensor.py", line 62, in device_state_attributes
    ATTR_BRAND: self.info["brand_raw"],
KeyError: 'brand_raw'

Thank you! I finally got this working however, I see in the official RPi notes it seems that ‘scaling_cur_freq’ is the frequency requested by the kernel and not necessarily the real frequency after potential effects like temperature throttling:

To view the Pi’s current frequency in KHz, type: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq . Divide the result by 1000 to find the value in MHz. Note that this frequency is the kernel requested frequency, and it is possible that any throttling (for example at high temperatures) may mean the CPU is actually running more slowly than reported. An instantaneous measurement of the actual ARM CPU frequency can be retrieved using the vcgencmd vcgencmd measure_clock arm . This is displayed in Hertz.

https://www.raspberrypi.org/documentation/configuration/config-txt/overclocking.md

I’m also trying to find out how to get the current GPU frequency to see what it’s doing in normal day to day usage of HA.

My frinde do dat

  • platform: systemmonitor
    resources:

    • type: memory_use_percent
    • type: processor_use
    • type: disk_use_percent
      arg: /
    • type: last_boot
    • type: network_in
      arg: eth0
    • type: network_out
      arg: eth0
  • platform: command_line
    name: CPU Temp
    command: “cat /sys/class/thermal/thermal_zone0/temp”
    unit_of_measurement: “°C”
    value_template: ‘{{ value | multiply(0.001) | round(2) }}’

  • platform: command_line
    name: CPU freq
    command: ‘cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq’
    unit_of_measurement: ‘MHz’
    value_template: ‘{{ value | multiply(0.001) }}’


this is my sensor.yaml
__

Do not write

CPU Speed - Home Assistant

  • platform: cpuspeed
    Or just
  • platform: cpuspeed

This fix the problem (i got same preblome)
sorry about my bad english