Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DS18B20
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CH Monitor
DS18B20
Commits
f554fe3c
Commit
f554fe3c
authored
7 years ago
by
Zandor Smith
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit.
parent
f5103e00
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
updateSensor.php
+37
-0
37 additions, 0 deletions
updateSensor.php
with
37 additions
and
0 deletions
updateSensor.php
0 → 100644
+
37
−
0
View file @
f554fe3c
<?php
$sensorId
=
0
;
// Fill in your sensor id.
$apiKey
=
""
;
// Fill in the installation API key.
function
getTemperature
()
{
$handle
=
fopen
(
"/sys/bus/w1/devices/w1_bus_master1/w1_master_slaves"
,
"r"
);
if
(
$handle
)
{
while
((
$sensors
=
fgets
(
$handle
))
!==
false
)
{
$sensor
=
"/sys/bus/w1/devices/"
.
trim
(
$sensors
)
.
"/w1_slave"
;
$sensorhandle
=
fopen
(
$sensor
,
"r"
);
if
(
$sensorhandle
)
{
$thermometerReading
=
fread
(
$sensorhandle
,
filesize
(
$sensor
));
fclose
(
$sensorhandle
);
// We want the value after the t= on the 2nd line
preg_match
(
"/t=(.+)/"
,
preg_split
(
"/
\n
/"
,
$thermometerReading
)[
1
],
$matches
);
$celsius
=
round
(
$matches
[
1
]
/
1000
);
fclose
(
$handle
);
return
$celsius
;
}
else
{
return
null
;
}
}
fclose
(
$handle
);
}
else
{
return
null
;
}
return
null
;
}
while
(
true
)
{
$temperature
=
getTemperature
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment