Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2023-001
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-001
2023-001
Commits
722f38f4
Commit
722f38f4
authored
May 24, 2023
by
Ravindu Dolawatta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
t
parent
8009d699
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
(1)Sensor_box/Sensor_box/Sensor_box.ino
(1)Sensor_box/Sensor_box/Sensor_box.ino
+98
-0
No files found.
(1)Sensor_box/Sensor_box/Sensor_box.ino
0 → 100644
View file @
722f38f4
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <BH1750.h>
#include <AHT10.h>
#define ss 53
#define rst 11
#define dio0 8
#define CJMCU101 A0
#define soil A1
#define ONE_WIRE_BUS 2
int
counter
=
0
;
float
CJM
,
soildata
,
Leaf_temp
,
lux
,
h
,
t
;
String
msg
;
unsigned
long
lastTime
=
0
;
unsigned
long
timerDelay
=
10000
;
BH1750
lightMeter
;
AHT10Class
AHT10
;
OneWire
oneWire
(
ONE_WIRE_BUS
);
DallasTemperature
sensors
(
&
oneWire
);
void
setup
()
{
Serial
.
begin
(
9600
);
Wire
.
begin
();
lightMeter
.
begin
();
sensors
.
begin
();
while
(
!
Serial
);
LoRa
.
setPins
(
ss
,
rst
,
dio0
);
Serial
.
println
(
"LoRa Sender"
);
if
(
!
LoRa
.
begin
(
433E6
))
{
Serial
.
println
(
"Starting LoRa failed!"
);
while
(
1
);
}
if
(
AHT10
.
begin
(
eAHT10Address_Low
))
{
Serial
.
println
(
"Init AHT10 Success!"
);
}
else
{
Serial
.
println
(
"Init AHT10 Failed!"
);
}
}
void
loop
()
{
counter
++
;
CJMCU101Read
();
soilRead
();
probe18b20Read
();
BH1750luxRead
();
AHT10Read
();
if
((
millis
()
-
lastTime
)
>
timerDelay
)
{
msg
=
""
+
(
String
)
CJM
+
";"
+
(
String
)
soildata
+
";"
+
(
String
)
Leaf_temp
+
";"
+
(
String
)
lux
+
";"
+
(
String
)
h
+
";"
+
(
String
)
t
+
""
;
Serial
.
print
(
"msg Data: "
);
Serial
.
println
(
msg
);
LoRa
.
beginPacket
();
LoRa
.
print
(
msg
);
LoRa
.
endPacket
();
lastTime
=
millis
();
}
}
void
CJMCU101Read
()
{
CJM
=
analogRead
(
CJMCU101
);
Serial
.
print
(
"CJMCU101 Read : "
);
Serial
.
println
(
CJM
);
}
void
soilRead
()
{
soildata
=
analogRead
(
soil
);
Serial
.
print
(
"Soil Read : "
);
Serial
.
println
(
soildata
);
}
void
probe18b20Read
()
{
sensors
.
requestTemperatures
();
Leaf_temp
=
sensors
.
getTempCByIndex
(
0
);
Serial
.
print
(
"Leaf temperature: "
);
Serial
.
println
(
Leaf_temp
);
}
void
BH1750luxRead
()
{
lux
=
lightMeter
.
readLightLevel
();
Serial
.
print
(
"Light: "
);
Serial
.
print
(
lux
);
Serial
.
println
(
" lx"
);
}
void
AHT10Read
()
{
h
=
AHT10
.
GetHumidity
();
t
=
AHT10
.
GetTemperature
();
Serial
.
println
(
String
(
""
)
+
"Humidity(%RH):
\t\t
"
+
AHT10
.
GetHumidity
()
+
"%"
);
Serial
.
println
(
String
(
""
)
+
"Temperature(℃):
\t
"
+
AHT10
.
GetTemperature
()
+
"℃"
);
}
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