Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
bokunimowakaru
RaspberryPi
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
RaspberryPi
/
gpio
/
raspi_temp.c
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 1.56 KB
master
Breadcrumbs
RaspberryPi
/
gpio
/
raspi_temp.c
Copy path
Top
File metadata and controls
Code
Blame
39 lines (36 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h> // 標準入出力を使用
#include <stdlib.h> // 型変換(atoi)を使用
#include<string.h>
int TEMPERATURE_OFFSET = 25.0; // 補正値(RaspPi温度上昇)
int main(int argc,char **argv){
FILE *pp; // コマンド出力用の変数pp
char cmd[]= // コマンドをcmdに代入
"cat /sys/devices/virtual/thermal/thermal_zone0/temp";
float in; // 数値変数inを定義
char s[8]; // 文字列変数sを定義
if( argc == 2 ){
in = atoi(argv[1]);
if(strcmp(argv[1],"pi3")==0) in=25.0;
if(strcmp(argv[1],"pi2")==0) in=21.0;
if(strcmp(argv[1],"pi1")==0) in=26.0;
if(strcmp(argv[1],"zerow")==0) in=11.0;
if(strcmp(argv[1],"zero")==0) in=7.0;
if(in)TEMPERATURE_OFFSET=in;
else if(strcmp(argv[1],"0")==0){
TEMPERATURE_OFFSET=0.0;
}else{
fprintf(stderr,"usage: %s [offset]\n",argv[0]);
return -1;
}
}
pp = popen(cmd, "r"); // GPIO用ファイルを開く
if( pp == NULL ){ // 失敗時
printf("ERROR\n"); // エラー表示
return -1; // 異常終了
}
fgets(s, 8, pp); // コマンドの戻り値を取得
in = (float)atoi(s); // 数値に変換してinに代入
printf("%3.1f\n",in/1000.-TEMPERATURE_OFFSET);
pclose(pp); // コマンド出力を閉じる
return 0; // 関数mainの正常終了(0)
}
You can’t perform that action at this time.