Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IOT Project - 3CB105
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
joel.guest
IOT Project - 3CB105
Commits
3bbde2f9
Commit
3bbde2f9
authored
Nov 30, 2020
by
joel.guest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
185 additions
and
0 deletions
+185
-0
Arduino_Project_Code_Final.ino
Arduino_Project_Code_Final/Arduino_Project_Code_Final.ino
+106
-0
Live-Google-Maps-Location.html
Live-Google-Maps-Location.html
+79
-0
No files found.
Arduino_Project_Code_Final/Arduino_Project_Code_Final.ino
0 → 100644
View file @
3bbde2f9
//Import Libraries
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <WiFiNINA.h>
#include <ThingSpeak.h>
//Initialise variables
int
buttonPin
=
2
;
int
ledpin
=
13
;
boolean
flag
=
true
;
boolean
Movement
=
LOW
;
int
led
=
12
;
int
sensor
=
8
;
boolean
GPSFlag
=
true
;
//char ssid[] = "VM6119700";
//char pass[] = "pnFfsnmy6sky";
char
ssid
[]
=
"JoelsConnection"
;
char
pass
[]
=
"Frezzle99"
;
int
status
=
WL_IDLE_STATUS
;
const
unsigned
long
channel_id
=
1226910
;
const
char
write_api_key
[]
=
"82SVTTB823BBCAJV"
;
WiFiClient
client
;
//Setup RX and TX Pins for NEO-6M Sensor
static
const
int
RXPin
=
4
,
TXPin
=
3
;
//Set the board rate for the serial monitor
static
const
uint32_t
GPSBaud
=
9600
;
// The TinyGPS++ object
TinyGPSPlus
gps
;
// The serial connection to the GPS device
SoftwareSerial
ss
(
RXPin
,
TXPin
);
void
setup
()
{
//Pin Setup
pinMode
(
ledpin
,
OUTPUT
);
pinMode
(
buttonPin
,
INPUT_PULLUP
);
pinMode
(
led
,
OUTPUT
);
pinMode
(
sensor
,
INPUT
);
Serial
.
begin
(
9600
);
ss
.
begin
(
GPSBaud
);
// attempt to connect using WPA2 encryption:
Serial
.
println
(
"Attempting to connect to WPA network..."
);
status
=
WiFi
.
begin
(
ssid
,
pass
);
// if you're not connected, stop here:
if
(
status
!=
WL_CONNECTED
)
{
Serial
.
println
(
"Couldn't get a wifi connection"
);
while
(
true
);
}
// if you are connected, print out info about the connection:
else
{
Serial
.
println
(
"Connected to network"
);
ThingSpeak
.
begin
(
client
);
}
}
void
loop
()
{
// if the flag value is false this means movement has been detected and the GPSFlag can be switched for the GPS Sensor
if
(
!
flag
)
{
digitalWrite
(
ledpin
,
HIGH
);
int
sensorValue
=
digitalRead
(
sensor
);
//Serial.println(sensorValue);
if
(
sensorValue
==
HIGH
)
{
GPSFlag
=
false
;
}
}
else
{
digitalWrite
(
ledpin
,
LOW
);
}
if
(
digitalRead
(
buttonPin
)
==
HIGH
){
flag
=
!
flag
;
delay
(
10
);
}
//when GPSFlag and flag are false the gps latitude and longitude begin detection
if
(
GPSFlag
==
false
&&
flag
==
false
)
{
digitalWrite
(
led
,
HIGH
);
//Tiny GPS library information
while
(
ss
.
available
()
>
0
){
gps
.
encode
(
ss
.
read
());
if
(
gps
.
location
.
isUpdated
()){
Serial
.
print
(
"Latitude= "
);
Serial
.
print
(
gps
.
location
.
lat
(),
6
);
Serial
.
print
(
" Longitude= "
);
Serial
.
println
(
gps
.
location
.
lng
(),
6
);
//Send data to thingspeak
ThingSpeak
.
setField
(
1
,
!
GPSFlag
);
ThingSpeak
.
setField
(
2
,
float
(
gps
.
location
.
lat
()));
ThingSpeak
.
setField
(
3
,
float
(
gps
.
location
.
lng
()));
ThingSpeak
.
writeFields
(
channel_id
,
write_api_key
);
//}
}
}
}
else
{
digitalWrite
(
led
,
LOW
);
}
delay
(
100
);
}
Live-Google-Maps-Location.html
0 → 100644
View file @
3bbde2f9
<!DOCTYPE html>
<html>
<head>
<title>
Joel Guest - IOT - 3CB105
</title>
<meta
name=
"viewport"
content=
"initial-scale=1.0, user-scalable=no"
>
<meta
charset=
"utf-8"
>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map
{
height
:
100%
;
}
/* Optional: Makes the sample page fill the window. */
html
,
body
{
height
:
100%
;
margin
:
0
;
padding
:
0
;
}
</style>
<script
src=
"https://maps.googleapis.com/maps/api/js?key=AIzaSyA47cRE0V-jMTslx_P4fadeuaSUhp4gENo"
></script>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"
></script>
<script>
var
map
;
var
x
;
function
loadmaps
(){
$
.
getJSON
(
"
https://api.thingspeak.com/channels/1226910/fields/2/last.json?api_key=F9MF90NII2YW7DZP
"
,
function
(
result
){
var
m
=
result
;
x
=
Number
(
m
.
field2
);
//alert(x);
});
$
.
getJSON
(
"
https://api.thingspeak.com/channels/1226910/fields/3/last.json?api_key=F9MF90NII2YW7DZP
"
,
function
(
result
){
var
m
=
result
;
y
=
Number
(
m
.
field3
);
}).
done
(
function
()
{
initialize
();
});
}
window
.
setInterval
(
function
(){
loadmaps
();
},
9000
);
function
initialize
()
{
//alert(y);
var
mapOptions
=
{
zoom
:
18
,
center
:
{
lat
:
x
,
lng
:
y
}
};
map
=
new
google
.
maps
.
Map
(
document
.
getElementById
(
'
map
'
),
mapOptions
);
var
marker
=
new
google
.
maps
.
Marker
({
position
:
{
lat
:
x
,
lng
:
y
},
map
:
map
});
var
infowindow
=
new
google
.
maps
.
InfoWindow
({
content
:
'
<p>Marker Location:
'
+
marker
.
getPosition
()
+
'
</p>
'
});
google
.
maps
.
event
.
addListener
(
marker
,
'
click
'
,
function
()
{
infowindow
.
open
(
map
,
marker
);
});
}
google
.
maps
.
event
.
addDomListener
(
window
,
'
load
'
,
initialize
);
</script>
</head>
<body>
<div
id=
"map"
></div>
</body>
</html>
\ No newline at end of file
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