Commit 22ac3a7e authored by Markéta Jedličková's avatar Markéta Jedličková
Browse files

CanSat lite cosmetic update

parent a2e20090
......@@ -15,12 +15,11 @@
Please maintain this license information along with authorship
and copyright notices in any redistribution of this code
*/
#include <RFM69.h>
#define Serial SerialUSB
//// RFM69
/// RFM69 variables
#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
......@@ -30,8 +29,10 @@
RFM69 radio(chip_select_pin, interupt_pin, true);
bool isRadioOk = true;
//// RFM69
/*
* Structure for CanSat lite
*/
typedef struct
{
uint16_t messageId;
......@@ -41,24 +42,26 @@ typedef struct
int16_t rssi;
} message;
// Income message data storage
message incomeMessage = {0, 0, 0, 0, 0};
void setup()
{
Serial.begin(57600);
Serial.begin(57600); // Start serial comm with baud rate of 57600Bd
// Wait for the Arduino serial (on your PC) to connect
// 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);
Serial.println("openCanSat GPS test started");
Serial.print("Node " + static_cast<String>(MYNODEID) + " ready");
// RFM69
Serial.print("Node ");
Serial.print(MYNODEID,DEC);
Serial.println(" ready");
// Radio RFM69 init (Frequency, node id and network id needed)
if(!radio.initialize(FREQUENCY, MYNODEID, NETWORKID))
{
isRadioOk = false;
isRadioOk = false; // radio init failed flag
Serial.println("RFM69HW initialization failed!");
}
else
......@@ -69,12 +72,15 @@ void setup()
void loop()
{
if (radio.receiveDone()) // Got one!
// If radio received message print out received data
if (radio.receiveDone())
{
Serial.println("Received from node " + static_cast<String>(radio.SENDERID));
// Convert income data into data structure
incomeMessage = *(message*)radio.DATA;
// Print out received 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");
......
......@@ -15,17 +15,16 @@
Please maintain this license information along with authorship
and copyright notices in any redistribution of this code
*/
#include <Adafruit_BMP280.h> // include Adafruit BMP280 library
#include <SD.h> // include Arduino SD library
#include <RFM69.h> // include RFM69 library
// Local
// Local constants
#define PC_BAUDRATE 56700
#define MS_DELAY 1500 // Number of milliseconds between data sending and LED signalization
#define Serial SerialUSB
// RFM69
// RFM69 constants
#define NETWORKID 0 // Must be the same for all nodes (0 to 255)
#define MYNODEID 1 // My node ID (0 to 255)
#define TONODEID 2 // Destination node ID (0 to 254, 255 = broadcast)
......@@ -33,17 +32,16 @@
#define CHIP_SELECT_PIN 43 //radio chip select
#define INTERUP_PIN 9 //radio interrupt
// BMP280
// BMP280 constants
#define BMP280_ADDRESS_OPEN_CANSAT 0x76
// BME280 SETTING
// BME280 constants
#define BME280_ADDRESS_OPEN_CANSAT 0x77
#define SEALEVELPRESSURE_HPA 1013.25
// SD card
// SD card constants
#define sd_cs_pin 35 // set SD's chip select pin (according to the circuit)
// create object 'rf69' from the library, which will
// be used to access the library methods by a dot notation
RFM69 radio(CHIP_SELECT_PIN, INTERUP_PIN, true, INTERUP_PIN);
......@@ -64,7 +62,7 @@ message data; //create the struct variable
// be used to access the library methods by a dot notation
Adafruit_BMP280 bmp;
// LEDS
// LEDS variables
#define D13_led_pin 42 // D13 LED
#define M_led_pin 36 // MLED
......@@ -78,10 +76,10 @@ void setup()
Serial.begin(PC_BAUDRATE);
// wait for the Arduino serial (on your PC) to connect
// 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);
// 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);
Serial.println("openCanSat LITE");
......@@ -147,23 +145,17 @@ void loop()
Serial.println();
// START LED hart beat
// Led hart beat
pinMode(M_led_pin, OUTPUT);
digitalWrite(D13_led_pin, HIGH);
digitalWrite(M_led_pin, HIGH);
delay(MS_DELAY);
digitalWrite(D13_led_pin, LOW);
pinMode(M_led_pin, INPUT);
// END LED hart beat
delay(MS_DELAY);
// Increase message id
idCounter ++;
// Wait before another measurement and set data
delay(MS_DELAY);
}
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