インテル ガリレオを使ってみる – CPUの温度を取得する –

スポンサーリンク

サンプル見たらありました
https://communities.intel.com/docs/DOC-22272の「Samples of how to run Linux Commands via IDE」をダウンロードし展開するとあります

その中のLinux_QuarkTemperature/Linux_QuarkTemperature.ino がCPUの温度を取得するArduinoスケッチ(インテル ガリレオで電子工作をするときのプログラム)のようです

中身は

/*
This example shows how to read the temperature of the Quark SoC

Example code by Erik Nyquist 2013;
erik.nyquist@intel.com

I do not hold any rights over these 
code examples, and you may do with 
them what you wish
*/

char temp_raw[6];
int temp;

void setup() {
  
  Serial.begin(115200);

}

void loop() {
  
  temp = getQuarkTemp();
  Serial.print("The temperature of the Quark SoC is ");
  Serial.print(temp);
  Serial.println(" degrees celcius.");
  
  delay(1000);
  
}

int getQuarkTemp(){
 
  FILE *fp;
 
  fp = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); 
  fgets(temp_raw, 5, fp);
  fclose(fp);
  
  int temp = atoi(temp_raw);
  temp /= 100;
  return temp;  
  
}

上のプログラムを実行すると、インテル ガリレオで気温が計測できるかと思います(^O^)

インテル ガリレオは安サバで有名なNTT-X Storeでも販売中です