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
98ea4574
Commit
98ea4574
authored
Nov 29, 2021
by
ryan.whiteley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recovery
parent
61cace9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
3 deletions
+57
-3
soil_moisture.py
soil_moisture.py
+57
-3
No files found.
soil_moisture.py
View file @
98ea4574
print
(
'hello world'
)
print
(
'another test'
)
print
(
'test'
)
import
thingspeak
import
time
import
paho.mqtt.publish
as
publish
from
ADCDevice
import
*
adc
=
ADCDevice
()
ts_channel_id
=
1234
ts_write_key
=
''
mqtt_soil_server
=
"192.168.0.25"
mqtt_soil_path_one
=
"soil_one"
mqtt_soil_path_two
=
"soil_two"
dry_reading
=
80
wet
reading
=
200
#setup for the ADC module
def
adc_setup
():
global
adc
if
(
adc
.
detectI2C
(
0x4b
)):
adc
=
ADS7830
()
else
:
print
(
'No I2C address found
\n
'
'use: iscdetect -y 1 to investigate I2C address'
)
exit
(
-
1
)
#main driver for measurments and MQTT
def
main_loop
(
channel
):
try
:
#get sensor reading and percentage conversions
soil_one
=
adc
.
analogRead
(
0
)
soil_two
=
adc
.
analogRead
(
1
)
#publish sensor info to MQTT server
publish
.
single
(
mqtt_soil_path_one
,
stuff
,
hostname
=
mqtt_soil_server
)
#print to the LCD display
#LCD display code
def
destroy_all
():
adc
.
close
()
if
__name__
==
'__main__'
:
#thingspeak channel settings here
try
:
adc_setup
()
except
KeyboardInterrupt
:
destroy_all
()
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