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
robert.sharp
IoT_Project
Commits
c95d51a8
Commit
c95d51a8
authored
Jan 06, 2022
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Main.ino to use the new Grove library.
parent
2016ee2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
Main.ino
sketch_main/Main/Main.ino
+18
-19
No files found.
sketch_main/Main/Main.ino
View file @
c95d51a8
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include <lmic.h> //IBM LMIC Library
#include <lmic.h> //IBM LMIC Library
#include <hal/hal.h>
#include <hal/hal.h>
#include <SPI.h>
#include <SPI.h>
#include
"AirQuality
.h"
#include
"Air_Quality_Sensor
.h"
#include"Arduino.h"
#include"Arduino.h"
// This EUI must be in little-endian format, so least-significant-byte
// This EUI must be in little-endian format, so least-significant-byte
...
@@ -54,7 +54,7 @@ static const u1_t PROGMEM APPKEY[16] = { 0xEE, 0xB3, 0xA4, 0x83, 0xBF, 0xEC, 0x0
...
@@ -54,7 +54,7 @@ static const u1_t PROGMEM APPKEY[16] = { 0xEE, 0xB3, 0xA4, 0x83, 0xBF, 0xEC, 0x0
void
os_getDevKey
(
u1_t
*
buf
)
{
memcpy_P
(
buf
,
APPKEY
,
16
);}
void
os_getDevKey
(
u1_t
*
buf
)
{
memcpy_P
(
buf
,
APPKEY
,
16
);}
static
int
mydata
=
-
1
;
static
int
mydata
=
-
1
;
AirQuality
airqualitysensor
;
AirQuality
Sensor
sensor
(
A0
)
;
static
osjob_t
sendjob
;
static
osjob_t
sendjob
;
...
@@ -142,7 +142,11 @@ void onEvent (ev_t ev) {
...
@@ -142,7 +142,11 @@ void onEvent (ev_t ev) {
void
do_send
(
osjob_t
*
j
){
void
do_send
(
osjob_t
*
j
){
//Update mydata to be the current value of the sensor
//Update mydata to be the current value of the sensor
mydata
=
airqualitysensor
.
slope
();
mydata
=
sensor
.
getValue
();
//test the sensor is working
Serial
.
print
(
"Sensor value: "
);
Serial
.
println
(
sensor
.
getValue
());
// Check if there is not a current TX/RX job running
// Check if there is not a current TX/RX job running
if
(
LMIC
.
opmode
&
OP_TXRXPEND
)
{
if
(
LMIC
.
opmode
&
OP_TXRXPEND
)
{
...
@@ -157,9 +161,17 @@ void do_send(osjob_t* j){
...
@@ -157,9 +161,17 @@ void do_send(osjob_t* j){
void
setup
()
{
void
setup
()
{
Serial
.
begin
(
115200
);
Serial
.
begin
(
115200
);
airqualitysensor
.
init
(
A0
);
Serial
.
println
(
F
(
"Starting"
));
Serial
.
println
(
F
(
"Starting"
));
Serial
.
println
(
"Waiting sensor to init..."
);
delay
(
20000
);
if
(
sensor
.
init
())
{
Serial
.
println
(
"Sensor ready."
);
}
else
{
Serial
.
println
(
"Sensor ERROR!"
);
}
#ifdef VCC_ENABLE
#ifdef VCC_ENABLE
// For Pinoccio Scout boards
// For Pinoccio Scout boards
pinMode
(
VCC_ENABLE
,
OUTPUT
);
pinMode
(
VCC_ENABLE
,
OUTPUT
);
...
@@ -178,17 +190,4 @@ void setup() {
...
@@ -178,17 +190,4 @@ void setup() {
void
loop
()
{
void
loop
()
{
os_runloop_once
();
os_runloop_once
();
}
}
\ No newline at end of file
ISR
(
TIMER2_OVF_vect
){
if
(
airqualitysensor
.
counter
==
122
){
//set 2 seconds as a detected duty{
airqualitysensor
.
last_vol
=
airqualitysensor
.
first_vol
;
airqualitysensor
.
first_vol
=
analogRead
(
A0
);
airqualitysensor
.
counter
=
0
;
airqualitysensor
.
timer_index
=
1
;
PORTB
=
PORTB
^
0x20
;
}
else
{
airqualitysensor
.
counter
++
;
}
}
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