Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Smart_Agro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
28
Issues
28
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
TMP-23-236
Smart_Agro
Commits
ccd54558
Commit
ccd54558
authored
Sep 07, 2023
by
RR Nimesha Manchalee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
d41dc9ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
Soil monitoring/npk_test/npk_test.ino
Soil monitoring/npk_test/npk_test.ino
+96
-0
No files found.
Soil monitoring/npk_test/npk_test.ino
0 → 100644
View file @
ccd54558
#include <SoftwareSerial.h>
#define RE 2
#define DE 0
//const byte code[]= {0x01, 0x03, 0x00, 0x1e, 0x00, 0x03, 0x65, 0xCD};
const
byte
nitro
[]
=
{
0x01
,
0x03
,
0x00
,
0x1e
,
0x00
,
0x01
,
0xe4
,
0x0c
};
const
byte
phos
[]
=
{
0x01
,
0x03
,
0x00
,
0x1f
,
0x00
,
0x01
,
0xb5
,
0xcc
};
const
byte
pota
[]
=
{
0x01
,
0x03
,
0x00
,
0x20
,
0x00
,
0x01
,
0x85
,
0xc0
};
byte
values
[
11
];
SoftwareSerial
mod
(
14
,
12
);
void
setup
()
{
Serial
.
begin
(
9600
);
mod
.
begin
(
4800
);
pinMode
(
RE
,
OUTPUT
);
pinMode
(
DE
,
OUTPUT
);
Serial
.
print
(
"Initializing"
);
delay
(
3000
);
}
void
loop
()
{
byte
val1
,
val2
,
val3
;
val1
=
nitrogen
();
delay
(
250
);
val2
=
phosphorous
();
delay
(
250
);
val3
=
potassium
();
delay
(
250
);
Serial
.
print
(
"Nitrogen: "
);
Serial
.
print
(
val1
);
Serial
.
println
(
" mg/kg"
);
Serial
.
print
(
"Phosphorous: "
);
Serial
.
print
(
val2
);
Serial
.
println
(
" mg/kg"
);
Serial
.
print
(
"Potassium: "
);
Serial
.
print
(
val3
);
Serial
.
println
(
" mg/kg"
);
delay
(
2000
);
}
byte
nitrogen
(){
digitalWrite
(
DE
,
HIGH
);
digitalWrite
(
RE
,
HIGH
);
delay
(
10
);
if
(
mod
.
write
(
nitro
,
sizeof
(
nitro
))
==
8
){
digitalWrite
(
DE
,
LOW
);
digitalWrite
(
RE
,
LOW
);
for
(
byte
i
=
0
;
i
<
7
;
i
++
){
//Serial.print(mod.read(),HEX);
values
[
i
]
=
mod
.
read
();
//Serial.print(values[i],HEX);
}
//Serial.println();
}
return
values
[
4
];
}
byte
phosphorous
(){
digitalWrite
(
DE
,
HIGH
);
digitalWrite
(
RE
,
HIGH
);
delay
(
10
);
if
(
mod
.
write
(
phos
,
sizeof
(
phos
))
==
8
){
digitalWrite
(
DE
,
LOW
);
digitalWrite
(
RE
,
LOW
);
for
(
byte
i
=
0
;
i
<
7
;
i
++
){
//Serial.print(mod.read(),HEX);
values
[
i
]
=
mod
.
read
();
//Serial.print(values[i],HEX);
}
//Serial.println();
}
return
values
[
4
];
}
byte
potassium
(){
digitalWrite
(
DE
,
HIGH
);
digitalWrite
(
RE
,
HIGH
);
delay
(
10
);
if
(
mod
.
write
(
pota
,
sizeof
(
pota
))
==
8
){
digitalWrite
(
DE
,
LOW
);
digitalWrite
(
RE
,
LOW
);
for
(
byte
i
=
0
;
i
<
7
;
i
++
){
//Serial.print(mod.read(),HEX);
values
[
i
]
=
mod
.
read
();
//Serial.print(values[i],HEX);
}
Serial
.
println
();
}
return
values
[
4
];
}
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