Commit 592713d7 authored by Ondřej Kučera's avatar Ondřej Kučera

update SW examples & HW designs, general cleanup

parent a1190eb2
Pipeline #12 failed with stages
This diff is collapsed.
#include <Adafruit_BME280.h>
#define Serial SerialUSB
#define BME280_ADDRESS 0x77
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
int ms_delay = 500;
float temperature_bme280 = 0;
float pressure_bme280 = 0;
float altitude_bme280 = 0;
float humidity_bme280 = 0;
void setup()
{
Serial.begin(9600);
while(!Serial);
Serial.println("CANSAT kit BME280 test started.");
if (!bme.begin(BME280_ADDRESS))
{
Serial.println("Could not find a valid BME280 sensor, check wiring!");
return;
}
Serial.println();
}
void loop()
{
temperature_bme280 = bme.readTemperature();
pressure_bme280 = bme.readPressure() / 100.0F;
altitude_bme280 = bme.readAltitude(SEALEVELPRESSURE_HPA);
humidity_bme280 = bme.readHumidity();
Serial.println("Temperature = " + (String) temperature_bme280 + " °C");
Serial.println("Pressure = " + (String) pressure_bme280 + " hPa");
Serial.println("Approx altitude = " + (String) altitude_bme280 + " m");
Serial.println("Humidity = " + (String) humidity_bme280 + " %");
Serial.println();
delay(ms_delay);
}
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h> #include <Adafruit_BMP280.h>
#define SerialUSB Serial; #define Serial SerialUSB
Adafruit_BMP280 bmp; // I2C #define BMP280_ADDRESS 0x76
#define BMP280_CHIPID 0x58
Adafruit_BMP280 bmp;
// number of ms between another measurement
int ms_delay = 2000; int ms_delay = 2000;
float temperature_bmp280 = 0; float temperature_bmp280 = 0;
...@@ -16,20 +15,20 @@ float altitude_bmp280 = 0; ...@@ -16,20 +15,20 @@ float altitude_bmp280 = 0;
void setup() void setup()
{ {
int a = 1;
Serial.begin(9600); Serial.begin(9600);
while(!Serial); while(!Serial);
Serial.println("CANSAT kit BMP280 test started."); Serial.println("CANSAT kit BMP280 test started.");
if (!bmp.begin()) if (!bmp.begin(BMP280_ADDRESS, BMP280_CHIPID))
{ {
Serial.println("Could not find a valid BMP280 sensor, check wiring!"); Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1); return;
} }
Serial.println();
} }
// the loop function runs over and over again forever
void loop() void loop()
{ {
temperature_bmp280 = bmp.readTemperature(); temperature_bmp280 = bmp.readTemperature();
......
// EN: Official USB serial console for SAM21D core
// CZ: Oficiální USB serial port pro SAM21D
#define Serial SerialUSB
// EN: Variables setting
// CZ: Nastavení proměnných
int d13_led = 42;
int tx_led = 31;
int rx_led = 30;
int m_led = 36;
// EN: Number of ms between led ON and OFF
// CZ: Počet milisekund pro prodlevu mezi zanutím a vypnutím LED diod
int ms_delay = 1000;
// EN: Setup function runs once
// CZ: Nastavení parametrů, které proběhne jen jednou
void setup()
{
Serial.begin(9600);
//EN: Wait until Serial connection is ready
//CZ: Čekej dokud nebude sériová linka připravena
while(!Serial);
Serial.println("CANSAT kit LED test.");
pinMode(d13_led, OUTPUT);
pinMode(tx_led, OUTPUT);
pinMode(rx_led, OUTPUT);
pinMode(m_led, OUTPUT);
}
//EN: The loop function runs over and over again forever
//CZ: Nekonečná smyčka
void loop()
{
Serial.println("Zapnutí LED diod (D13, TX, RX, MLED).");
digitalWrite(d13_led, HIGH);
digitalWrite(tx_led, LOW);
digitalWrite(rx_led, LOW);
digitalWrite(m_led, HIGH);
//EN: Wait on set ms_delay
//CZ: Počkej nastavený počet milisekund
delay(ms_delay);
Serial.println("Vypnutí LED diod (D13, TX, RX, MLED).");
digitalWrite(d13_led, LOW);
digitalWrite(tx_led, HIGH);
digitalWrite(rx_led, HIGH);
digitalWrite(m_led, LOW);
//EN: Wait on set ms_delay
//CZ: Počkej nastavený počet milisekund
delay(ms_delay);
}
#include <Wire.h>
#define Serial SerialUSB
void setup()
{
Wire.begin();
Serial.begin(9600);
while(!Serial);
Serial.println("GPS started");
}
void loop()
{
Wire.requestFrom(0x42, 64);
while(Wire.available())
{
char c = Wire.read();
Serial.print(c);
}
Serial.println();
delay(500);
}
#include <Wire.h>
#include <Adafruit_INA219.h> #include <Adafruit_INA219.h>
// EN: Official USB serial console for Arduino SAMD core // EN: Official USB serial console for Arduino SAMD core
// CZ: Oficiální USB serial port pro Arduino SAMD // CZ: Oficiální USB serial port pro Arduino SAMD
#define Serial SerialUSB #define Serial SerialUSB
Adafruit_INA219 ina219; Adafruit_INA219 ina219(0x40);
// EN: Number of ms between another measurement // EN: Number of ms between another measurement
// CZ: Počet milisekund mezi dalším měření // CZ: Počet milisekund mezi dalším měření
int ms_delay = 2000; int ms_delay = 500;
// EN: Variables for measurement or calculation // EN: Variables for measurement or calculation
// CZ: Proměnné pro měření nebo výpočet // CZ: Proměnné pro měření nebo výpočet
...@@ -30,8 +28,7 @@ void setup(void) ...@@ -30,8 +28,7 @@ void setup(void)
while(!Serial); while(!Serial);
Serial.println("CANSAT kit INA219 test."); Serial.println("CANSAT kit INA219 test.");
Serial.println();
ina219.begin(); ina219.begin();
} }
...@@ -55,4 +52,4 @@ void loop(void) ...@@ -55,4 +52,4 @@ void loop(void)
//EN: Wait on set ms_delay //EN: Wait on set ms_delay
//CZ: Počkej nastavený počet milisekund //CZ: Počkej nastavený počet milisekund
delay(ms_delay); delay(ms_delay);
} }
//CanSat kit I/O test
#define D13SCK 42
#define D12MISO 39
#define D11MOSI 40
#define D10SS 41
#define D9 9
#define D8 8
#define D7 7
#define D6 6
#define D5 5
#define D4 4
#define D3 3
#define D2 2
#define TX 1
#define RX 0
#define A5 29
#define A4 28
#define A3 27
#define A2 26
#define A1 25
#define A0 24
#define SDA 37
#define SCL 38
void setup() {
//define all pins as output
pinMode(D13SCK, OUTPUT);
pinMode(D12MISO, OUTPUT);
pinMode(D11MOSI, OUTPUT);
pinMode(D10SS, OUTPUT);
pinMode(D9, OUTPUT);
pinMode(D8, OUTPUT);
pinMode(D7, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(D4, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(TX, OUTPUT);
pinMode(RX, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(SDA, OUTPUT);
pinMode(SCL, OUTPUT);
}
void loop() {
digitalWrite(D13SCK, HIGH);
digitalWrite(D12MISO, HIGH);
digitalWrite(D11MOSI, HIGH);
digitalWrite(D10SS, HIGH);
digitalWrite(D9, HIGH);
digitalWrite(D8, HIGH);
digitalWrite(D7, HIGH);
digitalWrite(D6, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(D4, HIGH);
digitalWrite(D3, HIGH);
digitalWrite(D2, HIGH);
digitalWrite(TX, HIGH);
digitalWrite(RX, HIGH);
digitalWrite(A5, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A0, HIGH);
digitalWrite(SDA, HIGH);
digitalWrite(SCL, HIGH);
delay(750);
digitalWrite(D13SCK, LOW);
digitalWrite(D12MISO, LOW);
digitalWrite(D11MOSI, LOW);
digitalWrite(D10SS, LOW);
digitalWrite(D9, LOW);
digitalWrite(D8, LOW);
digitalWrite(D7, LOW);
digitalWrite(D6, LOW);
digitalWrite(D5, LOW);
digitalWrite(D4, LOW);
digitalWrite(D3, LOW);
digitalWrite(D2, LOW);
digitalWrite(TX, LOW);
digitalWrite(RX, LOW);
digitalWrite(A5, LOW);
digitalWrite(A4, LOW);
digitalWrite(A3, LOW);
digitalWrite(A2, LOW);
digitalWrite(A1, LOW);
digitalWrite(A0, LOW);
digitalWrite(SDA, LOW);
digitalWrite(SCL, LOW);
delay(750);
}
#define Serial SerialUSB
#define D13_LED 42
#define M_LED 36
int ms_delay = 500;
void setup()
{
Serial.begin(9600);
while(!Serial);
Serial.println("CANSAT kit LED test.");
pinMode(D13_LED, OUTPUT);
}
void loop()
{
pinMode(M_LED, OUTPUT);
Serial.println("Zapnutí LED diod D13, MLED červená.");
digitalWrite(D13_LED, HIGH);
digitalWrite(M_LED, HIGH);
delay(ms_delay);
Serial.println("Vypnutí LED diody D13, zapnutí MLED modrá.");
digitalWrite(D13_LED, LOW);
digitalWrite(M_LED, LOW);
delay(ms_delay);
Serial.println("Vypnutí MLED.");
pinMode(M_LED, INPUT);
delay(ms_delay);
}
...@@ -2,61 +2,48 @@ ...@@ -2,61 +2,48 @@
#include <RH_RF69.h> #include <RH_RF69.h>
#define Serial SerialUSB #define Serial SerialUSB
#define ss_pin 43 //radio chip select
#define interupt_pin 9 //radio interrupt
// Variables setting RH_RF69 rf69(ss_pin, interupt_pin); //create an RFM69 instance
int ss_pin = 43;
int tx_pin = 14;
int interupt_pin = 9;
RH_RF69 rf69(ss_pin, interupt_pin);
// the setup function runs once // the setup function runs once
void setup() void setup()
{ {
Serial.begin(9600); Serial.begin(9600);
while(!Serial); while(!Serial); //required for devices with native USB
Serial.println("CANSAT kit RFM69_rx test started."); Serial.println("CANSAT kit RFM69_rx test started.");
if (!rf69.init()) // initialize the radio
{ if (!rf69.init()) {
Serial.println("Init of RFM69 failed"); Serial.println("Init of RFM69 failed");
} } else {
else
{
Serial.println("Init of RFM69 ok"); Serial.println("Init of RFM69 ok");
} }
// set frequency
if (!rf69.setFrequency(433.0)) if (!rf69.setFrequency(433.0)) {
{
Serial.println("Set frequency failed."); Serial.println("Set frequency failed.");
} } else {
else
{
Serial.println("Set frequency ok."); Serial.println("Set frequency ok.");
} }
// ? needed
rf69.setTxPower(tx_pin);
} }
void loop() void loop()
{ {
if (rf69.available()) if (rf69.available()) {
{ uint8_t buf[RH_RF69_MAX_MESSAGE_LEN]; //create a huge buffer for received data
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf); uint8_t len = sizeof(buf);
if (rf69.recv(buf, &len)) // receive to the buffer and print to serial
{ if (rf69.recv(buf, &len)){
Serial.print("Data received: "); Serial.print("Data received: ");
Serial.println((char*)buf); Serial.println((char*)buf);
} } else {
else
{
Serial.println("Data receiving failed."); Serial.println("Data receiving failed.");
} }
} }
} }
#include <SPI.h>
#include <RH_RF69.h>
#define Serial SerialUSB
#define ss_pin 43 //radio chip select
#define interupt_pin 9 //radio interrupt
RH_RF69 rf69(ss_pin, interupt_pin); //create an RFM69 instance
// declaration of the structure and its variables
typedef struct {
bool BoolVariable;
int IntVariable;
} payloadIn;
//declaration of local variables; we'll put the received data here
bool boolVariable;
int intVariable;
payloadIn recvData;
// the setup function runs once
void setup()
{
Serial.begin(9600);
while(!Serial); //required for devices with native USB
Serial.println("CANSAT kit RFM69_rx test started.");
// initialize the radio
if (!rf69.init()) {
Serial.println("Init of RFM69 failed");
} else {
Serial.println("Init of RFM69 ok");
}
// set frequency
if (!rf69.setFrequency(433.0)) {
Serial.println("Set frequency failed.");
} else {
Serial.println("Set frequency ok.");
}
}
void loop() {
if (rf69.available()) {
// receive the structure
uint8_t len = sizeof(payloadIn);
rf69.recv((uint8_t *)&recvData, &len);
// load data where we want them
boolVariable = recvData.BoolVariable;
intVariable = recvData.IntVariable;
// print the received data to serial
Serial.println(boolVariable);
Serial.println(intVariable);
}
}
#include <SPI.h>
#include <RH_RF69.h>
#define Serial SerialUSB
#define ss_pin 43 //radio chip select
#define interupt_pin 9 //radio interrupt
int ms_delay = 100;
RH_RF69 rf69(ss_pin, interupt_pin);
// define our own struct with some variables; used to send stuff
typedef struct {
bool BoolVariable;
int IntVariable;
} payloadOut;
payloadOut senData; //create the struct variable
void setup() {
Serial.begin(9600);
//while(!Serial); //required for devices with native USB
Serial.println("CANSAT kit RFM69_tx test started.");
// initialize the radio
if (!rf69.init()) {
Serial.println("Init of RFM69 failed");
} else {
Serial.println("Init of RFM69 ok");
}
// set frequency
if (!rf69.setFrequency(433.0)) {
Serial.println("Set frequency failed.");
} else {
Serial.println("Set frequency ok.");
}
rf69.setTxPower(15); // set transmit power
// load some values into the variables; you'll probably want to do this somewhere in the loop
senData.BoolVariable = true;
senData.IntVariable = 123;
}
void loop()
{
// create buffer with data and transmit it
if(!rf69.send((uint8_t *)&senData, sizeof(senData))) {
Serial.println("Failed");
} else {
Serial.println("Sent");
}
delay(ms_delay); //wait
}
...@@ -2,58 +2,46 @@ ...@@ -2,58 +2,46 @@
#include <RH_RF69.h> #include <RH_RF69.h>
#define Serial SerialUSB #define Serial SerialUSB
#define ss_pin 43 //radio chip select
#define interupt_pin 9 //radio interrupt
// Variables setting int ms_delay = 100;
int ss_pin = 43;
int tx_pin = 14;
int interupt_pin = 9;
// number of ms between receiving
int ms_delay = 100;
RH_RF69 rf69(ss_pin, interupt_pin); RH_RF69 rf69(ss_pin, interupt_pin);
void setup() void setup()
{ {
Serial.begin(9600); Serial.begin(9600);
while(!Serial); while(!Serial); //required for devices with native USB
Serial.println("CANSAT kit RFM69_tx test started."); Serial.println("CANSAT kit RFM69_tx test started.");
if (!rf69.init()) // initialize the radio
{ if (!rf69.init()) {
Serial.println("Init of RFM69 failed"); Serial.println("Init of RFM69 failed");
} } else {
else
{
Serial.println("Init of RFM69 ok"); Serial.println("Init of RFM69 ok");
} }
// set frequency
if (!rf69.setFrequency(433.0)) if (!rf69.setFrequency(433.0)) {
{
Serial.println("Set frequency failed."); Serial.println("Set frequency failed.");
} } else {
else
{
Serial.println("Set frequency ok."); Serial.println("Set frequency ok.");
} }
// ? needed rf69.setTxPower(15); // set transmit power
rf69.setTxPower(tx_pin);
} }
void loop() void loop()
{ {
// create buffer with data and transmit it
uint8_t data[20] = "Cansat tx test!"; uint8_t data[20] = "Cansat tx test!";
if(!rf69.send(data, sizeof(data))) if(!rf69.send(data, sizeof(data))) {
{
Serial.println("Failed."); Serial.println("Failed.");
} } else {
else
{
Serial.println("Sended."); Serial.println("Sended.");
} }
delay(ms_delay); delay(ms_delay); //wait
} }
This diff is collapsed.