Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
COM6005M The Internet of Things 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
jake.beetham
COM6005M The Internet of Things Project
Commits
9d020d3f
Commit
9d020d3f
authored
Jan 21, 2023
by
jake.beetham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
0 deletions
+133
-0
PetFoodDispenserIoTProject.ino
PetFoodDispenserIoTProject.ino
+133
-0
No files found.
PetFoodDispenserIoTProject.ino
0 → 100644
View file @
9d020d3f
//including necessary librarys
#include <ThreeWire.h>
#include <RtcDS1302.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include "ThingSpeak.h"
#include <Servo.h>
#include <Pushsafer.h>
//WiFi setup
char
ssid
[]
=
"VM9745152"
;
char
pass
[]
=
"4zpmvcNPtwbb"
;
int
keyIndex
=
0
;
int
WIFIstatus
=
WL_IDLE_STATUS
;
//ThingSpeak Setup
const
unsigned
long
channel_id
=
2001759
;
const
char
write_api_key
[]
=
"5LQ7U666RIJW7AOX"
;
//Pushsafer Setup
#define PushsaferKey "O1cQuA8UPrYzEhxdPBxa"
//Servo Motor Setup
Servo
myservo
;
int
pos
=
180
;
WiFiClient
client
;
Pushsafer
pushsafer
(
PushsaferKey
,
client
);
ThreeWire
myWire
(
4
,
5
,
2
);
RtcDS1302
<
ThreeWire
>
Rtc
(
myWire
);
void
setup
()
{
Serial
.
begin
(
9600
);
//checking whether the wifi shield is present
if
(
WiFi
.
status
()
==
WL_NO_SHIELD
){
Serial
.
print
(
"The WiFi shield is currently not present."
);
while
(
true
);
}
//checking whether a wifi connection has been secured
while
(
WIFIstatus
!=
WL_CONNECTED
){
Serial
.
print
(
"Attempting to connect to "
);
Serial
.
print
(
ssid
);
Serial
.
println
();
delay
(
30
);
WIFIstatus
=
WiFi
.
begin
(
ssid
,
pass
);
//connecting to wifi using ssid and password
//wait 5 seconds for connection
delay
(
5000
);
}
Serial
.
println
(
"We have established a connection to your Wi-Fi!"
);
delay
(
15
);
ThingSpeak
.
begin
(
client
);
//connect to ThingSpeak
myservo
.
attach
(
A0
);
Rtc
.
Begin
();
delay
(
30
);
}
void
loop
()
{
delay
(
1000
);
RtcDateTime
now
=
Rtc
.
GetDateTime
();
delay
(
90
);
checkDateTime
(
now
);
delay
(
90
);
}
#define countof(a) (sizeof(a) / sizeof(a[0]))
void
checkDateTime
(
const
RtcDateTime
&
dt
){
char
checkDateTime
[
20
];
snprintf_P
(
checkDateTime
,
countof
(
checkDateTime
),
PSTR
(
"%02u/%02u/%04u %02u:%02u:%02u"
),
dt
.
Day
(),
dt
.
Month
(),
dt
.
Year
(),
dt
.
Hour
(),
dt
.
Minute
(),
dt
.
Second
()
);
if
((
dt
.
Hour
()
==
9
&&
dt
.
Minute
()
==
30
&&
dt
.
Second
()
==
0
)
||
(
dt
.
Hour
()
==
13
&&
dt
.
Minute
()
==
30
&&
dt
.
Second
()
==
0
)
||
(
dt
.
Hour
()
==
17
&&
dt
.
Minute
()
==
30
&&
dt
.
Second
()
==
0
)){
for
(
pos
=
0
;
pos
<=
180
;
pos
+=
1
)
{
myservo
.
write
(
pos
);
delay
(
15
);
}
//apply delay here to release more food
for
(
pos
=
180
;
pos
>=
0
;
pos
-=
1
)
{
myservo
.
write
(
pos
);
delay
(
15
);
}
Serial
.
println
(
"Posting the your pets feeding data to ThingSpeak"
);
delay
(
60
);
ThingSpeak
.
setField
(
1
,
"1"
);
delay
(
60
);
ThingSpeak
.
writeFields
(
channel_id
,
write_api_key
);
delay
(
250
);
Serial
.
println
(
"Your pet's feeding data has now been posted successfully!"
);
delay
(
60
);
pushsafer
.
debug
=
true
;
struct
PushSaferInput
input
;
input
.
title
=
"Your pet has been fed!"
;
input
.
message
=
(
checkDateTime
);
input
.
icon
=
"1"
;
input
.
sound
=
"4"
;
input
.
vibration
=
"1"
;
input
.
device
=
"a"
;
input
.
url
=
"https://www.pushsafer.com/api"
;
input
.
urlTitle
=
"Open Pushsafer.com"
;
input
.
time2live
=
"60"
;
input
.
priority
=
"1"
;
input
.
retry
=
""
;
input
.
expire
=
""
;
input
.
answer
=
""
;
Serial
.
println
(
pushsafer
.
sendEvent
(
input
));
Serial
.
println
(
"Notification Sent!"
);
delay
(
90
);
}
}
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