I am having problems with my RS which logs data intermittently. I verified the power and it looks good. The other issue might be the temperature (I have the version in the environmental enclosure and the monitoring site is outdoors). Therefore, I wanted to log the temperature, alas the vcgencmd is not working (command not found). The /usr/bin had a link called vcgencmd, but his link points to the /opt/vc/bin/vcgencmd location, which does not exist.
The RS homepage shows the temperature, thus I fathom that there is a way to reading it, but how do I do that from the shell (so I can automate it with cron)?
hello mvgheorghe,
you can find the temperature directly in an OS file here:
/sys/class/thermal/thermal_zone0/temp
in units of 1000*C
convert to C if and as needed.
cheers,
richard
Richard, thank you.
Do you know how often is this temperature updated? In other words, can I grab this value every minute and add it to a log file to monitor the trend?
Marius
this may be of help:
Thank you. In the meanwhile I determined empirically that the temperature updates every few seconds, which was adequate enough to sample and log it once a minute. And since I am more comfortable with Lua than with Python, I created this Lua script to grab the temperature and voltages from the 5 V and 3.3 V regulators and output them to a log file and used crontab to run it every minute.
β Temperature and voltages from 5 V and 3.3 V regulators
local temp, v5, v33
β Get the temperature.
β Empirically determined that this file has just a single line, however, parsing it in its entirety and retaining the last valid value.
for line in io.lines(β/sys/class/thermal/thermal_zone0/tempβ) do
β Last valid temperature stored in βtempβ variable
temp = tonumber(line) or temp
end
β If the temperature is valid, convert it to degrees C.
if temp then
temp = string.format(β%.1fβ, temp / 1000)
else
temp = βnilβ
end
β Get the 5V regulator output voltage.
β Empirically determined that this file has just a single line, however, parsing it in its entirety and retaining the last valid value.
for line in io.lines(β/sys/devices/platform/fixedregulator_5v0/regulator/regulator.1/microvoltsβ) do
β Last valid voltage stored in βv5β variable
v5 = tonumber(line) or v5
end
β If voltage is valid, convert it to volts.
if v5 then
v5 = string.format(β%.1fβ, v5 / 1e6)
else
v5 = βnilβ
end
β Get the 3.3V regulator output voltage.
β Empirically determined that this file has just a single line, however, parsing it in its entirety and retaining the last valid value.
for line in io.lines(β/sys/devices/platform/fixedregulator_3v3/regulator/regulator.2/microvoltsβ) do
β Last valid voltage stored in βv33β variable
v33 = tonumber(line) or v33
end
β If voltage is valid, convert it to volts.
if v33 then
v33 = string.format(β%.1fβ, v33 / 1e6)
else
v33 = βnilβ
end
β Open log file for appending.
local fout = io.open(β/home/myshake/cpu_temp.logβ, βaβ)
β Append to log file.
fout:write(os.date(β%Y-%m-%d,%H:%M:%S,β, os.time()), temp, β,β, v5, β,β, v33, β\nβ)
β Close file.
fout:close()