-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroundStation.ino
167 lines (138 loc) · 3.89 KB
/
GroundStation.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/************************************************************
SPANISH
Ground station
Ground station - Estacion Terrena para CatSat
Eduardo Contreras @ Electronic Cats
Original Creation Date: Oct 8, 2018
https://github.com/ElectronicCats/CatSatZero
Este ejemplo demuestra el funcionamiento basico de la estacion terrena
la cual filtra los Satelites
http://electroniccats.com
Especificaciones del entorno de Desarrollo:
IDE: Arduino 1.8.4
Plataforma de Hardware:
Estacion terrena CanSat Zero
- USB Stick CatWAN
Este código es beerware si tu me ves ( o cualquier otro miembro de Electronic Cats)
a nivel local, y tu has encontrado nuestro código útil ,
por favor comprar una ronda de cervezas!
Distribuido como; no se da ninguna garantía.
************************************************************/
/************************************************************
ENGLISH
Ground Station
Ground Station - Ground-Station for CatSat
Eduardo contreras @ Electronic Cats
Original Creation Date: Oct 8, 2018
https://github.com/ElectronicCats/CatSatZero
http://electroniccats.com
This example demonstrates how to use the ground-station for CatSat
Development environment specifics:
IDE: Arduino 1.8.4
Hardware Platform:
Kit CanSat Zero
- USB Stick CatWAN
This code is beerware; if you see me (or any other Electronic Cats
member) at the local, and you've found our code helpful,
please buy us a round!
Distributed as-is; no warranty is given.
**********************************************************
*IMPORTANTE CAMBIA TU ID DEPENDIENDO DE TU CANSAT *
**********************************************************/
#include <SPI.h>
#include <LoRa.h>
/************************************************************
* IMPORTANTE CAMBIAR id_node DEPENDIENDO TU CANSAT *
************************************************************/
String ID = "A1";
/*******************************************************
*Selecciona un canal entre 0 y 12 este debe coincidir *
*con el canal de tu satelite *
*******************************************************/
int chan = 12;
String buff;
//For other device
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2
long selectBand(int);
void setup()
{
Serial.begin(9600);
while (!Serial);
pinMode(LED_BUILTIN,OUTPUT);
Serial.println("LoRa Receiver");
//Re-write pins CS, reset, y IRQ for other device
// LoRa.setPins(RFM95_CS, RFM95_RST, RFM95_INT); // CS, reset, int pin
//Re-write pins CS, reset, y IRQ for CatWAN USB Stick Electronic Cats
LoRa.setPins(SS, RFM_RST, RFM_DIO0);
if (!LoRa.begin(selectBand(chan))) {
Serial.println("Starting LoRa failed!");
while (1);
}
LoRa.enableCrc();
LoRa.setTxPower(20); //Set the max transmition power
LoRa.setSpreadingFactor(10); //Change the SF to get longer distances
}
void loop()
{
int packetSize = LoRa.parsePacket();
if (packetSize) {
digitalWrite(LED_BUILTIN,HIGH);
// read packet
while (LoRa.available()) {
buff+=(char)LoRa.read();
}
buff+=",";
buff+=String(LoRa.packetRssi());
if(buff.startsWith(ID)){
Serial.println(buff);
}
buff="";
digitalWrite(LED_BUILTIN,LOW);
}
}
long selectBand(int a)
{
switch(a){
case 0:
return 903080000; //903.08Mhz
break;
case 1:
return 905240000; //905.24
break;
case 2:
return 907400000; //907.40
break;
case 3:
return 909560000; //909.56
break;
case 4:
return 911720000; //911.72
break;
case 5:
return 913880000; //913.88
break;
case 6:
return 916040000; //916.04
break;
case 7:
return 918200000; // 918.20
break;
case 8:
return 920360000; //920.36
break;
case 9:
return 922520000; //922.52
break;
case 10:
return 924680000; //924.68
break;
case 11:
return 926840000; //926.84
break;
case 12:
return 915000000; //915
break;
}
}