Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
Internet of Things Artefact
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
daniel.parker
Internet of Things Artefact
Commits
82598276
Commit
82598276
authored
Jan 05, 2021
by
daniel.parker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
205 additions
and
0 deletions
+205
-0
Temperature_Humidity_Light_Hydration.ino
..._Light_Hydration/Temperature_Humidity_Light_Hydration.ino
+203
-0
arduino_secrets.h
Temperature_Humidity_Light_Hydration/arduino_secrets.h
+2
-0
No files found.
Temperature_Humidity_Light_Hydration/Temperature_Humidity_Light_Hydration.ino
0 → 100644
View file @
82598276
#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>
#include "ThingSpeak.h"
#include <dht.h>
#define dht_pin A0
#define light_Pin A1
#define hydration_Pin A2
const
unsigned
long
channel_id
=
1276626
;
const
char
write_api_key
[]
=
"S0HMG0KSGUDVLH4T"
;
dht
DHT
;
WiFiUDP
UDP
;
WiFiClient
client
;
#include "arduino_secrets.h"
char
ssid
[]
=
SECRET_SSID
;
char
pass
[]
=
SECRET_PASS
;
int
status
=
WL_IDLE_STATUS
;
String
hostName
=
"www.google.com"
;
int
pingResult
;
void
setup
()
{
Serial
.
begin
(
9600
);
while
(
!
Serial
)
{
}
if
(
WiFi
.
status
()
==
WL_NO_MODULE
)
{
Serial
.
println
(
"Communication with WiFi module failed!"
);
while
(
true
);
}
while
(
status
!=
WL_CONNECTED
)
{
Serial
.
print
(
"Attempting to connect to WPA SSID: "
);
Serial
.
println
(
ssid
);
status
=
WiFi
.
begin
(
ssid
,
pass
);
delay
(
5000
);
}
Serial
.
println
(
"You're connected to the network"
);
printCurrentNet
();
printWiFiData
();
delay
(
500
);
Serial
.
println
(
"
\n
"
);
Serial
.
println
(
"Daniel Parker
\n
"
);
Serial
.
println
(
"Plant monitoring system
\n\n
"
);
delay
(
1000
);
ThingSpeak
.
begin
(
client
);
}
void
loop
()
{
Serial
.
print
(
"Pinging "
);
Serial
.
print
(
hostName
);
Serial
.
print
(
": "
);
pingResult
=
WiFi
.
ping
(
hostName
);
if
(
pingResult
>=
0
)
{
Serial
.
print
(
"SUCCESS! RTT = "
);
Serial
.
print
(
pingResult
);
Serial
.
println
(
" ms"
);
}
else
{
Serial
.
print
(
"FAILED! Error code: "
);
Serial
.
println
(
pingResult
);
}
DHT
.
read11
(
dht_pin
);
String
lightVal
;
lightVal
=
analogRead
(
light_Pin
);
String
hydrationVal
;
hydrationVal
=
analogRead
(
hydration_Pin
);
Serial
.
print
(
"Humidity = "
);
Serial
.
print
(
DHT
.
humidity
);
Serial
.
print
(
" % "
);
ThingSpeak
.
setField
(
3
,
String
(
DHT
.
humidity
));
Serial
.
print
(
"Temperature = "
);
Serial
.
print
(
DHT
.
temperature
);
Serial
.
print
(
" C "
);
ThingSpeak
.
setField
(
2
,
String
(
DHT
.
temperature
));
Serial
.
print
(
"Ambient Light = "
);
Serial
.
print
(
lightVal
);
ThingSpeak
.
setField
(
1
,
String
(
lightVal
));
Serial
.
print
(
" "
);
Serial
.
print
(
"Soil Hydration Level = "
);
Serial
.
println
(
hydrationVal
);
ThingSpeak
.
setField
(
4
,
String
(
hydrationVal
));
ThingSpeak
.
writeFields
(
channel_id
,
write_api_key
);
delay
(
300000
);
//delay(60000); //(TEST VALUE)
//delay(15000); //(SECOND TEST VALUE)
}
void
printWiFiData
()
{
IPAddress
ip
=
WiFi
.
localIP
();
Serial
.
print
(
"IP address : "
);
Serial
.
println
(
ip
);
Serial
.
print
(
"Subnet mask: "
);
Serial
.
println
((
IPAddress
)
WiFi
.
subnetMask
());
Serial
.
print
(
"Gateway IP : "
);
Serial
.
println
((
IPAddress
)
WiFi
.
gatewayIP
());
byte
mac
[
6
];
WiFi
.
macAddress
(
mac
);
Serial
.
print
(
"MAC address: "
);
printMacAddress
(
mac
);
}
void
printCurrentNet
()
{
Serial
.
print
(
"SSID: "
);
Serial
.
println
(
WiFi
.
SSID
());
byte
bssid
[
6
];
WiFi
.
BSSID
(
bssid
);
Serial
.
print
(
"BSSID: "
);
printMacAddress
(
bssid
);
long
rssi
=
WiFi
.
RSSI
();
Serial
.
print
(
"signal strength (RSSI): "
);
Serial
.
println
(
rssi
);
byte
encryption
=
WiFi
.
encryptionType
();
Serial
.
print
(
"Encryption Type: "
);
Serial
.
println
(
encryption
,
HEX
);
Serial
.
println
();
}
void
printMacAddress
(
byte
mac
[])
{
for
(
int
i
=
5
;
i
>=
0
;
i
--
)
{
if
(
mac
[
i
]
<
16
)
{
Serial
.
print
(
"0"
);
}
Serial
.
print
(
mac
[
i
],
HEX
);
if
(
i
>
0
)
{
Serial
.
print
(
":"
);
}
}
Serial
.
println
();
}
Temperature_Humidity_Light_Hydration/arduino_secrets.h
0 → 100644
View file @
82598276
#define SECRET_SSID "VM2561973_EXT"
#define SECRET_PASS "ssGmvsvg3jjp"
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