Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Home Automation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Jason Williams
Home Automation
Commits
1b5d9729
Commit
1b5d9729
authored
Nov 12, 2018
by
Jason Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added code for second temperature sensor.
parent
bc6422f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
Garage.ino
Garage/Garage.ino
+9
-5
No files found.
Garage/Garage.ino
View file @
1b5d9729
...
...
@@ -11,6 +11,8 @@ const int pin_doorclosed = D1;
const
int
pin_sidedoor
=
D2
;
const
int
pin_doortoggle
=
D6
;
const
int
pin_temperature
=
D7
;
DeviceAddress
ambient
=
{
0x28
,
0x6F
,
0x08
,
0x0A
,
0x31
,
0x14
,
0x01
,
0x20
};
DeviceAddress
freezer
=
{
0x28
,
0x6C
,
0x96
,
0x00
,
0x31
,
0x14
,
0x01
,
0x77
};
// WiFi & Connectivity Settings
#include "secrets.h"
...
...
@@ -27,6 +29,7 @@ const char* topic_doorcommand = "garage/door/command";
const
char
*
topic_doorstate
=
"garage/door/state"
;
const
char
*
topic_sidedoor
=
"garage/sidedoor"
;
const
char
*
topic_ambienttemp
=
"garage/temperature"
;
const
char
*
topic_freezertemp
=
"garage/freezer"
;
// Currently reported states and/or times
bool
state_sidedoor
=
1
;
...
...
@@ -136,13 +139,15 @@ void loop() {
delay
(
500
);
}
// Check the temperature every 30 seconds and send an update
// Check the temperature
s
every 30 seconds and send an update
unsigned
long
elapsed_temperature
=
millis
()
-
sent_temperature
;
if
(
elapsed_temperature
>=
30000
)
{
DallasTemp
.
requestTemperatures
();
char
tempstr
[
6
];
sprintf
(
tempstr
,
"%.1f"
,
DallasTemp
.
getTempCByIndex
(
0
));
client
.
publish
(
topic_ambienttemp
,
tempstr
);
char
ambtempstr
[
6
],
frztempstr
[
6
];
sprintf
(
ambtempstr
,
"%.1f"
,
DallasTemp
.
getTempC
(
ambient
));
sprintf
(
frztempstr
,
"%.1f"
,
DallasTemp
.
getTempC
(
freezer
));
client
.
publish
(
topic_ambienttemp
,
ambtempstr
);
client
.
publish
(
topic_freezertemp
,
frztempstr
);
Serial
.
print
(
"The temperature is "
);
Serial
.
print
(
tempstr
);
...
...
@@ -150,7 +155,6 @@ void loop() {
sent_temperature
=
millis
();
}
// TODO: TEMPERATURE SENSOR 2
// TODO: ULTRASONIC DISTANCE SENSORS
// Check how long it's been since the last periodic update, and send another one if required
...
...
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