Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Michal Rybka
openCanSat-2.0-library
Commits
5e2ac3ee
Commit
5e2ac3ee
authored
Aug 21, 2018
by
Markéta Jedličková
Browse files
Lite kit code added, finished and tested
parent
ea9ee7cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/1-LITE-version-examples/OpenCansat_base_lite.ino
0 → 100644
View file @
5e2ac3ee
#include
<RFM69.h>
#define Serial SerialUSB
//// RFM69
#define NETWORKID 0 // Must be the same for all nodes (0 to 255)
#define MYNODEID 2 // My node ID (0 to 255)
#define FREQUENCY RF69_433MHZ
#define chip_select_pin 43
#define interupt_pin 9
RFM69
radio
(
chip_select_pin
,
interupt_pin
,
true
);
bool
isRadioOk
=
true
;
//// RFM69
typedef
struct
{
uint16_t
messageId
;
float
temperature
;
float
pressure
;
float
altitude
;
int16_t
rssi
;
}
message
;
message
incomeMessage
=
{
0
,
0
,
0
,
0
,
0
};
void
setup
()
{
Serial
.
begin
(
57600
);
while
(
!
Serial
);
Serial
.
println
(
"openCanSat GPS test started"
);
// RFM69
Serial
.
print
(
"Node "
);
Serial
.
print
(
MYNODEID
,
DEC
);
Serial
.
println
(
" ready"
);
if
(
!
radio
.
initialize
(
FREQUENCY
,
MYNODEID
,
NETWORKID
))
{
isRadioOk
=
false
;
Serial
.
println
(
"RFM69HW initialization failed!"
);
}
else
{
radio
.
setHighPower
(
true
);
// Always use this for RFM69HW
}
}
void
loop
()
{
if
(
radio
.
receiveDone
())
// Got one!
{
Serial
.
println
(
"Received from node "
+
static_cast
<
String
>
(
radio
.
SENDERID
));
incomeMessage
=
*
(
message
*
)
radio
.
DATA
;
Serial
.
println
(
"MessageId = "
+
static_cast
<
String
>
(
incomeMessage
.
messageId
));
Serial
.
println
(
"Temperature = "
+
static_cast
<
String
>
(
incomeMessage
.
temperature
)
+
" *C"
);
Serial
.
println
(
"Pressure = "
+
static_cast
<
String
>
(
incomeMessage
.
pressure
)
+
" Pa"
);
Serial
.
println
(
"Approx altitude = "
+
static_cast
<
String
>
(
incomeMessage
.
altitude
)
+
" m"
);
Serial
.
println
(
"Rssi signal = "
+
static_cast
<
String
>
(
incomeMessage
.
rssi
));
Serial
.
println
();
}
}
examples/1-LITE-version-examples/OpenCansat_main_lite.ino
View file @
5e2ac3ee
...
...
@@ -51,14 +51,14 @@ RFM69 radio(CHIP_SELECT_PIN, INTERUP_PIN, true, INTERUP_PIN);
// define our own struct data type with variables; used to send data
typedef
struct
{
in
t
messageId
;
float
temperature
;
float
pressure
;
float
altitude
;
int16_t
rssi
;
}
message
Out
;
uint16_
t
messageId
;
float
temperature
;
float
pressure
;
float
altitude
;
int16_t
rssi
;
}
message
;
message
Out
data
;
//create the struct variable
message
data
;
//create the struct variable
// create object 'bmp' from the library, which will
// be used to access the library methods by a dot notation
...
...
@@ -81,7 +81,7 @@ void setup()
// please, open the Arduino serial console (right top corner)
// note that the port may change after uploading the sketch
// COMMENT OUT FOR USAGE WITHOUT A PC!
while
(
!
Serial
);
//
while(!Serial);
Serial
.
println
(
"openCanSat LITE"
);
...
...
Write
Preview
Supports
Markdown
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