I tried to get this code to work on my Raspberry Pi connected to the Particle Cloud. It compiled and flash corrected (I think) but when I opened the console.particle.io/events I have yet to see it publish the Pi’s CPU temperature once.
# include "Particle.h"
int getTempC(String args)
{
Process proc = Process::run("vcgencmd measure_temp");
proc.wait(); // The output is temp=43.5'C, so read past the = and parse the number
proc.out().find("=");
float cpuTemp = proc.out().parseFloat();
Particle.publish("cpu-temp", String(cpuTemp));
return 0;
}
void setup()
{
Particle.function("getTempC", getTempC);
}
void loop()
{
// Nothing in the loop
}