Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoT soil moisture project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ryan.whiteley
IoT soil moisture project
Commits
c457d435
Commit
c457d435
authored
Nov 29, 2021
by
ryan.whiteley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all thinkspeak feeds working again for both soil sensors, average and cpu temp
parent
5e6b743f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
soil_moisture.py
soil_moisture.py
+14
-3
No files found.
soil_moisture.py
View file @
c457d435
...
...
@@ -27,9 +27,15 @@ def adc_setup():
'use: iscdetect -y 1 to investigate I2C address'
)
exit
(
-
1
)
def
cpu_temp_finder
():
temp
=
open
(
'/sys/class/thermal/thermal_zone0/temp'
)
cpu_temp
=
temp
.
read
()
temp
.
close
()
return
'{:.1f}'
.
format
(
float
(
cpu_temp
)
/
1000
)
+
' c'
#main driver for measurments and MQTT
def
main_loop
(
channel
):
#insert channel variable when setting up thingspeak
#LCD initialisation goes here
try
:
#get sensor reading and percentage conversions
...
...
@@ -39,20 +45,25 @@ def main_loop(channel):#insert channel variable when setting up thingspeak
soil_two_percent
=
((
soil_two
-
two_dry_reading
)
*
100
)
/
(
two_wet_reading
-
two_dry_reading
)
soil_avg
=
(
soil_one_percent
+
soil_two_percent
)
/
2
temp
=
open
(
'/sys/class/thermal/thermal_zone0/temp'
)
cpu_temp
=
temp
.
read
()
temp
.
close
()
cpu_ts
=
'{:.1f}'
.
format
(
float
(
cpu_temp
)
/
1000
)
print
(
soil_one
)
print
(
soil_two
)
print
(
'soil one:
%
d
%%
'
%
soil_one_percent
)
print
(
'soil two:
%
d
%%
'
%
soil_two_percent
)
print
(
'soil average:
%
d
%%
'
%
soil_avg
)
print
(
'CPU temp @: '
,
cpu_ts
)
#publish sensor info to MQTT server
#publish.single(mqtt_soil_path_one, stuff, hostname= mqtt_soil_server)
#send to thingspeak
test
=
5
response
=
channel
.
update
({
'field1'
:
soil_one_percent
,
'field2'
:
soil_two_percent
,
'field3'
:
soil_avg
,
'field4'
:
test
})
response
=
channel
.
update
({
'field1'
:
soil_one_percent
,
'field2'
:
soil_two_percent
,
'field3'
:
soil_avg
,
'field4'
:
cpu_ts
})
#print to the LCD display
except
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment