Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
COM6005M
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
cameron.rayfield
COM6005M
Commits
19f3d341
Commit
19f3d341
authored
Jan 17, 2023
by
cameron.rayfield
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
4534c715
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
130 additions
and
0 deletions
+130
-0
iot_project.ino
iot_project.ino
+130
-0
No files found.
iot_project.ino
0 → 100644
View file @
19f3d341
#include <Wire.h>
#include <LiquidCrystal.h>
#include "rgb_lcd.h"
#include <SPI.h>
#include <WiFiNINA.h>
#include <ThingSpeak.h>
#include <Pushsafer.h>
rgb_lcd
lcd
;
const
int
pinTemp
=
A0
;
const
int
B
=
3975
;
//wifi setup
const
char
ssid
[]
=
"BT-65CWRF"
;
const
char
password
[]
=
"Y6MXcpC7LMqKbX"
;
#define PushsaferKey "tCP14do8Oc6C0eKXyiZP"
//thingspeak setup
const
unsigned
long
channel_id
=
1907432
;
const
char
write_api_key
[]
=
"LH1FINQ6IO2F3DT3"
;
WiFiClient
client
;
Pushsafer
pushsafer
(
PushsaferKey
,
client
);
void
setup
()
{
Serial
.
begin
(
9600
);
Serial
.
print
(
"Connecting to "
);
Serial
.
print
(
ssid
);
WiFi
.
begin
(
ssid
,
password
);
Serial
.
println
();
Serial
.
println
(
"Connected to your WiFi!"
);
delay
(
60
);
ThingSpeak
.
begin
(
client
);
lcd
.
begin
(
16
,
2
);
lcd
.
print
(
"Temperature:"
);
delay
(
1000
);
}
void
loop
()
{
lcd
.
setCursor
(
0
,
1
);
int
val
=
analogRead
(
pinTemp
);
float
resistance
=
(
float
)(
1023
-
val
)
*
10000
/
val
;
float
temperature
=
1
/
(
log
(
resistance
/
10000
)
/
B
+
1
/
298.15
)
-
273.15
;
lcd
.
print
(
temperature
);
Serial
.
println
(
"Your current room temperature is: "
+
String
(
temperature
)
+
"."
);
ThingSpeak
.
setField
(
1
,
String
(
temperature
,
2
));
ThingSpeak
.
writeFields
(
channel_id
,
write_api_key
);
delay
(
60
);
pushsafer
.
debug
=
true
;
delay
(
60
);
if
(
temperature
>
20.00
&&
temperature
<
25.00
){
const
int
colorR
=
0
;
const
int
colorG
=
255
;
const
int
colorB
=
0
;
lcd
.
setRGB
(
colorR
,
colorG
,
colorB
);
}
if
(
temperature
>
25.00
){
const
int
colorR
=
255
;
const
int
colorG
=
0
;
const
int
colorB
=
0
;
lcd
.
setRGB
(
colorR
,
colorG
,
colorB
);
delay
(
60
);
Serial
.
println
(
"Your room temperature is currently too high!"
);
delay
(
60
);
struct
PushSaferInput
input
;
input
.
message
=
"Your room is currently too hot."
;
input
.
title
=
"Temperature Alert!"
;
input
.
sound
=
"8"
;
input
.
vibration
=
"1"
;
input
.
icon
=
"1"
;
input
.
iconcolor
=
"#FFCCCC"
;
input
.
priority
=
"1"
;
input
.
device
=
"a"
;
input
.
url
=
"https://www.pushsafer.com/api"
;
input
.
urlTitle
=
"Open Pushsafer.com"
;
delay
(
60
);
Serial
.
println
(
pushsafer
.
sendEvent
(
input
));
Serial
.
println
(
"Notification Sent"
);
delay
(
60
);
}
if
(
temperature
<
20.00
){
const
int
colorR
=
0
;
const
int
colorG
=
0
;
const
int
colorB
=
255
;
lcd
.
setRGB
(
colorR
,
colorG
,
colorB
);
delay
(
60
);
Serial
.
println
(
"Your room temperature is currently too low!"
);
delay
(
60
);
struct
PushSaferInput
input
;
input
.
message
=
"Your room is currently too cold."
;
input
.
title
=
"Temperature Alert!"
;
input
.
sound
=
"8"
;
input
.
vibration
=
"1"
;
input
.
icon
=
"1"
;
input
.
iconcolor
=
"#FFCCCC"
;
input
.
priority
=
"1"
;
input
.
device
=
"a"
;
input
.
url
=
"https://www.pushsafer.com/api"
;
input
.
urlTitle
=
"Open Pushsafer.com"
;
delay
(
60
);
Serial
.
println
(
pushsafer
.
sendEvent
(
input
));
Serial
.
println
(
"Notification Sent"
);
delay
(
60
);
}
delay
(
15000
);
}
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