Nerves Linux System on a PI - best way to read the cpu-temperature

Hi,

i have a nerves image for an PI and want to modify it so the PI sends the cpu-temperature to an REST-API.
Currently I’m in the planning phase how this could work.

  • According to that pi-gpu-and-arm-cpu-temperature it is possible to read out the cpu-temperature with “cat /sys/class/thermal/thermal_zone0/temp”. Is this also true for the nerves linux image?
  • My current plan is to read out the file above with Elixir I/O.File every 10 seconds

Will this work? Has anyone a better idea or even better has anyone even developed something? Please let me know.

I don’t know for sure, because I’ve never tried it, but I’ve found Elixir has a hard time reading some /sys/class* files currently. This will be fixed when Nerves supports otp 21.

For now you can just try reading that file normally and see what happens!

thanks for your answer. Do you know when nerves will support otp 21?

We have support for it in nerves_system_br, we just have to test out all the nerves_system_XYZ repos. @fhunleth is on vacation at the moment, but i suspect they will be out shortly after he returns.

also i just found this:

iex(49)> cmd("vcgencmd measure_temp")
temp=47.2'C

Which will work on any Raspberry pi device.