Commit 5e2ac3ee authored by Markéta Jedličková's avatar Markéta Jedličková
Browse files

Lite kit code added, finished and tested

parent ea9ee7cd
#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();
}
}
......@@ -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
{
int messageId;
float temperature;
float pressure;
float altitude;
int16_t rssi;
} messageOut;
uint16_t messageId;
float temperature;
float pressure;
float altitude;
int16_t rssi;
} message;
messageOut 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");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment