Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoT 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
austin.blanke
IoT Project
Commits
8992ab7e
Commit
8992ab7e
authored
Jan 14, 2024
by
austin.blanke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
0 deletions
+115
-0
IoT_Arduino_File.ino
IoT_Arduino_File/IoT_Arduino_File.ino
+91
-0
arduino_secrets.h
IoT_Arduino_File/arduino_secrets.h
+6
-0
roomTemp.html
roomTemp.html
+18
-0
No files found.
IoT_Arduino_File/IoT_Arduino_File.ino
0 → 100644
View file @
8992ab7e
#include <WiFiNINA.h>
#include "arduino_secrets.h"
#include "ThingSpeak.h"
#include <math.h>
#include <Servo.h>
#define TS_ENABLE_SSL
Servo
myservo
;
unsigned
long
myChannelNumber
=
SECRET_CH_ID
;
const
char
*
myWriteAPIKey
=
SECRET_WRITE_APIKEY
;
char
ssid
[]
=
SECRET_SSID
;
char
usrnm
[]
=
SECRET_USRNM
;
char
pass
[]
=
SECRET_PASS
;
WiFiClient
client
;
int
a
;
float
temperature
;
int
B
=
3975
;
//B value of the thermistor
float
resistance
;
float
tempThreshold
=
21
;
void
setup
()
{
Serial
.
begin
(
9600
);
myservo
.
attach
(
4
);
myservo
.
write
(
130
);
// check for the WiFi module:
if
(
WiFi
.
status
()
==
WL_NO_MODULE
)
{
Serial
.
println
(
"Communication with WiFi module failed!"
);
while
(
true
);
}
ThingSpeak
.
begin
(
client
);
//Initialize ThingSpeak
Serial
.
println
(
""
);
Serial
.
println
(
""
);
Serial
.
print
(
"Temperature threshold is "
);
Serial
.
println
(
tempThreshold
);
Serial
.
println
(
""
);
Serial
.
println
(
""
);
}
void
loop
()
{
a
=
analogRead
(
0
);
resistance
=
(
float
)(
1023
-
a
)
*
10000
/
a
;
//get the resistance of the sensor;
temperature
=
1
/
(
log
(
resistance
/
10000
)
/
B
+
1
/
298.15
)
-
273.15
;
//convert to temperature via datasheet ;
// Connect or reconnect to WiFi
if
(
WiFi
.
status
()
!=
WL_CONNECTED
){
Serial
.
print
(
"Attempting to connect to SSID: "
);
Serial
.
println
(
SECRET_SSID
);
while
(
WiFi
.
status
()
!=
WL_CONNECTED
){
WiFi
.
begin
(
ssid
,
pass
);
Serial
.
print
(
"."
);
delay
(
6000
);
}
Serial
.
println
(
"
\n
Connected."
);
}
int
x
=
ThingSpeak
.
writeField
(
myChannelNumber
,
1
,
temperature
,
myWriteAPIKey
);
if
(
x
==
200
){
Serial
.
println
(
"Channel Temp updated"
);
}
else
{
Serial
.
println
(
"Error: "
+
String
(
x
));
}
if
(
temperature
<
tempThreshold
){
myservo
.
write
(
100
);
// sets the servo position according to the scaled value
delay
(
2000
);
myservo
.
write
(
130
);
Serial
.
println
(
"Servo Activated!"
);
delay
(
300000
);
}
Serial
.
print
(
"Current temperature is "
);
Serial
.
println
(
temperature
);
delay
(
15000
);
}
IoT_Arduino_File/arduino_secrets.h
0 → 100644
View file @
8992ab7e
#define SECRET_SSID "ASK4 Wireless"
#define SECRET_USRNM ""
#define SECRET_PASS ""
#define SECRET_CH_ID "2401626"
#define SECRET_WRITE_APIKEY "6DEH0JTDYDX6MHKX"
#define SECRET_READ_APIKEY "Y4U4Z6P3BCTQIXA5"
roomTemp.html
0 → 100644
View file @
8992ab7e
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Change Setpoint
</title>
</head>
<body>
<div>
<h1>
Current Room Temp
</h1>
<iframe
width=
"450"
height=
"260"
style=
"border: 1px solid #cccccc;"
src=
"https://thingspeak.com/channels/2401626/widgets/784926"
></iframe>
</div>
<div>
<h1>
Room Temperature Over Time
</h1>
<iframe
width=
"450"
height=
"260"
style=
"border: 1px solid #cccccc;"
src=
"https://thingspeak.com/channels/2401626/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&type=line&update=15"
></iframe>
</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