Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Remote Plant Watering System
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
zak.evans
Remote Plant Watering System
Commits
78f97898
Commit
78f97898
authored
Jan 15, 2024
by
zak.evans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete main.c
parent
521c6729
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
109 deletions
+0
-109
main.c
main.c
+0
-109
No files found.
main.c
deleted
100644 → 0
View file @
521c6729
#include <SPI.h>
#include <WiFiNINA.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
char
ssid
[]
=
"Stans_Wifi_Guest"
;
char
pass
[]
=
""
;
int
keyIndex
=
0
;
int
status
=
WL_IDLE_STATUS
;
WiFiServer
server
(
80
);
const
char
*
thingSpeakApiKey
=
"MRIHLKXFMUDD5V0K"
;
const
char
*
thingSpeakAddress
=
"api.thingspeak.com"
;
const
int
thingSpeakPort
=
80
;
LiquidCrystal_I2C
lcd
(
0x27
,
16
,
2
);
void
setup
()
{
Serial
.
begin
(
9600
);
//This was the first setup for the system which powers on and connects...
//...the LCD to display "Irrigation ssytem is on".
lcd
.
init
();
lcd
.
backlight
();
lcd
.
clear
();
pinMode
(
2
,
OUTPUT
);
digitalWrite
(
2
,
HIGH
);
delay
(
1000
);
lcd
.
setCursor
(
0
,
0
);
lcd
.
print
(
"IRRIGATION"
);
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
"SYSTEM IS ON "
);
lcd
.
print
(
""
);
delay
(
3000
);
lcd
.
clear
();
// WiFi setup
while
(
status
!=
WL_CONNECTED
)
{
Serial
.
print
(
"Attempting to connect to Network named: "
);
Serial
.
println
(
ssid
);
status
=
WiFi
.
begin
(
ssid
,
pass
);
delay
(
10000
);
}
server
.
begin
();
Serial
.
print
(
"SSID: "
);
Serial
.
println
(
WiFi
.
SSID
());
IPAddress
ip
=
WiFi
.
localIP
();
Serial
.
print
(
"IP Address: "
);
Serial
.
println
(
ip
);
}
void
loop
()
{
//Loop to make the water pump turn on once the soil moisture is low from...void
//...reading Analog Pin (A0) on the Arduino.
int
value
=
analogRead
(
A0
);
Serial
.
println
(
value
);
if
(
value
>
950
)
{
digitalWrite
(
2
,
LOW
);
lcd
.
setCursor
(
0
,
0
);
lcd
.
print
(
"Water Pump is ON "
);
}
else
{
digitalWrite
(
2
,
HIGH
);
lcd
.
setCursor
(
0
,
0
);
lcd
.
print
(
"Water Pump is OFF"
);
}
//Programs the soil mositure sensor to be at a Low, Mid or High state at a certain value.
if
(
value
<
300
)
{
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
"Moisture : HIGH"
);
}
else
if
(
value
>
300
&&
value
<
950
)
{
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
"Moisture : MID "
);
}
else
if
(
value
>
950
)
{
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
"Moisture : LOW "
);
}
uploadToThingSpeak
(
value
);
}
void
uploadToThingSpeak
(
int
moistureValue
)
{
WiFiClient
client
;
if
(
client
.
connect
(
thingSpeakAddress
,
thingSpeakPort
))
{
String
url
=
"/update?api_key="
;
url
+=
thingSpeakApiKey
;
url
+=
"&field1="
;
url
+=
String
(
moistureValue
);
client
.
print
(
String
(
"GET "
)
+
url
+
" HTTP/1.1
\r\n
"
+
"Host: "
+
thingSpeakAddress
+
"
\r\n
"
+
"Connection: close
\r\n\r\n
"
);
Serial
.
println
(
"Data sent to ThingSpeak!"
);
}
else
{
Serial
.
println
(
"Failed to connect to ThingSpeak"
);
}
client
.
stop
();
}
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