Components and supplies
Resistor 10k ohm
Arduino Mini USB serial adapter
LED (generic)
Solderless Breadboard Full Size
Micro-USB to USB Cable (Generic)
9V battery (generic)
Reyax RYLR890 LoRa Transmitter/Receiver
Wire, Wrapping Wire
Altitude/Pressure Sensor Breakout MPL3115A2
Through Hole Resistor, 5.1 kohm
Arduino Nano Every
Industrial SLC microSD
Adafruit MicroSD card breakout board+
Adafruit SHT31 Temperature and Humidity Sensor
Rocket Engines and Supplies
9V Battery Clip
Adafruit Ultimate GPS Breakout
Estes Loadstar II Rocket
Tools and machines
Soldering iron (generic)
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Apps and platforms
Arduino IDE
Project description
Code
Transmitter.ino
c_cpp
Code to use for the data collector that goes on the rocket.
1/**************************************************************************/ 2/*! 3 @file Transmitter.ino 4 @author Thomas Knepshield (POWR Rocket Capstone Project (UNCG Spring 2022)) 5 6 Code for POWR Rocket implementing the following sensors: 7 1. Adafruit MPL3115A2 --- https://www.adafruit.com/product/992 8 2. Adafruit SHT31 --- https://www.adafruit.com/product/2857 9 3. Adafruit Ultimate GPS --- https://www.adafruit.com/product/746 10 4. Adafruit MicroSD card Breakout --- https://www.adafruit.com/product/254 11 4.1. I used a 32 gb SD card but any size works 12 5. Reyax RYLR 890 LoRa Module --- https://www.amazon.com/gp/product/B07NB3BK5H/ref=ox_sc_saved_image_4?smid=A2M9CC26G0VWTA&psc=1 13 14 Arduino Board Used: 15 1. Arduino Nano Every --- https://store-usa.arduino.cc/products/arduino-nano-every 16 1.1. Must use a board with specs similar to or greater than this board. Arduino Nano will NOT work. 17 18 Rocket Used 19 1. Estes Loadstar --> https://www.discountrocketry.com/estes-loadstar-p-1772.html 20 21 Do not buy any electronics (other than Reyax Module) with headers. It will be hard to assemble with them. 22 23 Other Useful Things: 24 1. Wires --> https://www.amazon.com/dp/B07TX6BX47?psc=1&ref=ppx_yo2ov_dt_b_product_details 25 2. Bread Boards --> https://www.amazon.com/dp/B01EV6LJ7G?psc=1&ref=ppx_yo2ov_dt_b_product_details 26 3. Serial Adapter --> https://www.amazon.com/dp/B00LODGRV8?psc=1&ref=ppx_yo2ov_dt_b_product_details 27 4. Soder Set (Random one found) --> https://www.amazon.com/dp/B08R3515SF/ref=cm_sw_r_tw_dp_84MB274FP0PBHQ0C8E53 28 5. Wire Strippers --> https://www.amazon.com/dp/B000JNNWQ2/ref=cm_sw_r_tw_dp_FKMH2KSDEG139P8VXCN3 29 6. 9v Batteries --> Anywhere 30 7. 2x LED lights --> https://www.amazon.com/dp/B06XPV4CSH/ref=cm_sw_r_tw_dp_2Z13Y5QNM745NK9KX8ZM 31 32 Pinouts: 33 1. MPL3115A2 34 Vin --> 5v 35 GND --> GND 36 SCL --> A5 37 SDA --> A4 38 2. SHT31 39 Vin --> 5v 40 GND --> GND 41 SCL --> A5 42 SDA --> A4 43 3. Ultimate GPS 44 Vin --> 5v 45 GND --> GND 46 RX --> D7 47 TX --> D8 48 4. MicroSD card Breakout 49 5v --> 5v 50 GND --> GND 51 CLK --> D13 52 DO --> D12 53 DI --> D11 54 CS --> (ChipSelect) D10 55 5. LoRa Module 56 VDD --> 3.3v 57 GND --> GND 58 RX --> D9 59 10k Ohm Resisitor D9 --> RX 60 5k Ohm Resistor RX --> GND 61 6. LED Lights 62 1. D2 and GND for Transmission 63 2. D3 and GND for GPS 64 65 66 Reyax AT Commands: 67 Done in the serial monitor (in tools) using a Serial Adapter. Change Baud to 115200 and "Both NL & CR". 68 1. AT 69 2. AT+RESET 70 3. AT+ADDRESS=1 (Change this number to your favorite number. Do not use 1) 71 4. AT+IPR=38400 72 5. AT+PARAMETER=12,4,1,7 73 6. AT (Change baud rate to 38400 before doing this. Should get +OK) 74 75 76 Description 77 This code uses the described sensors to collect the barometric pressure, humidity, temperature, latitude, longitude, altitude, time and speed. 78 It then will concatenate the float values into strings and transmit it using LoRa. Once it transmits the data, it will also save the 79 values on a micro SD card. This SD card will hold every data point. LoRa transmitter with selected parameter space will transmit data 80 with a max of 4.5 - 8km without any objects in the way. 81 This code will not print anything to the seial monitor other than the setup lines to verify everything is working. 82 Using RX/TX pins on the Arduino Nano Every will not work so SoftwareSerial must be used for transmissions. 83 First LED will blink once the code starts transmitting data. 84 85 Tips 86 If any errors pop up it could be from incorrect wiring, failed boot or broken sensors. Incorrect wiring is a very common issue. 87 Also make sure you do not have any soder touching a reset pin. That will cause issues. 88 89 90 v1.0 - First release 91 UNCG, POWR Rocket project members, arduino and relevant parties are not responsible for any action that results in harm due to this project. 92 93 If you do recreate this project, let me know on Twitter (@tknep3) so I can follow along with your project and keep up with improvements. 94 Please send me your data so I can use it for future research. 95*/ 96/**************************************************************************/ 97 98#include "Adafruit_SHT31.h" 99#include <Adafruit_MPL3115A2.h> 100#include <SPI.h> 101#include <SD.h> 102#include <Arduino.h> 103#include <Wire.h> 104#include <SoftwareSerial.h> 105#include "TinyGPS++.h" 106 107 108//Make sure to download the libararies in tools/manage libraries. Type in each sensor name. 109 110#define pin 2 // Used with the LED 111#define gpsPin 3 //Used with GPS 112 113SoftwareSerial GPS(8, 7); // RX, TX 114SoftwareSerial Reyax(8, 9); // RX, TX 115TinyGPSPlus tinygps; 116 117Adafruit_SHT31 sht31 = Adafruit_SHT31(); // Initialize SHT31 sensor 118Adafruit_MPL3115A2 baro; // Setup the pressure for the MPL3115A2 sensor (value put in below) 119const int chipSelect = 10; // port for CS with the SD card 120const double currentPressure = 1013.26; //Change this to currect pressure in hPa for accurate results 121int id = 0; 122 123 124void setup() { 125 // initialize digital pin LED_BUILTIN as an output. 126 pinMode(pin, OUTPUT); // Initialize LED as output for Transmission 127 pinMode(gpsPin, OUTPUT); // Initialize LED as output for GPS fix 128 Serial.begin(9600); // Start the serial ports 129 Reyax.begin(38400); // Start the Reyax module Software Serial port 130 GPS.begin(9600); //Start the GPS module 131 132 // Make sure all sensors are initialized, wired correctly and are operational 133 134 Serial.println("SHT31 test"); //Test SHT31 Sensor 135 if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr 136 Serial.println("Couldn't find SHT31"); 137 while (1) delay(1); 138 } 139 140 Serial.println("Adafruit_MPL3115A2 test!"); //Test MPL3115A2 sensor 141 142 if (!baro.begin()) { 143 Serial.println("Could not find sensor. Check wiring."); 144 while (1); 145 } 146 147 // use to set pressure for current location 148 baro.setSeaPressure(currentPressure); 149 150 Serial.print("Initializing SD card..."); 151 // see if the card is present and can be initialized: 152 if (!SD.begin(chipSelect)) { 153 Serial.println("Card failed, or not present"); 154 while (1); 155 } 156 Serial.println("card initialized."); 157 158 Serial.println("Setup complete"); 159 //Loop will start once this is printed to Serial Monitor. 160 161} 162 163void loop() { 164 165 while (GPS.available() > 0) { 166 if (tinygps.encode(GPS.read())) { // Did a new valid sentence come in? 167 digitalWrite(gpsPin, HIGH); // turn the LED on signaling transmission was sent 168 delay(100); 169 digitalWrite(gpsPin, LOW); 170 } 171 } 172 173 String pressureString = ""; // empty strings for data 174 String altitudeString = ""; 175 String temperatureString = ""; 176 String humidityString = ""; 177 String latitudeString = ""; 178 String longitudeString = ""; 179 String speedString = ""; 180 String idString = ""; 181 String hourString = ""; 182 String minuteString = ""; 183 String secondString = ""; 184 String timeString = ""; 185 String dataString = ""; 186 187 pressureString.concat(baro.getPressure()); // Concatenate number values into Strings 188 altitudeString.concat(tinygps.altitude.meters()); 189 temperatureString.concat(baro.getTemperature()); 190 humidityString.concat(sht31.readHumidity()); 191 latitudeString.concat(String(tinygps.location.lng(),6)); 192 longitudeString.concat(String(tinygps.location.lat(),6)); 193 speedString.concat(tinygps.speed.kmph()); 194 hourString.concat(tinygps.time.hour()); 195 minuteString.concat(tinygps.time.minute()); 196 secondString.concat(tinygps.time.second()); 197 198 timeString += hourString; // Create time string in XX:XX:XX format 199 timeString += ":"; 200 timeString += minuteString; 201 timeString += ":"; 202 timeString += secondString; 203 204 idString = String(id++); 205 206 dataString += idString; 207 dataString += ","; 208 dataString += temperatureString; //Create string for data transmission separated by , 209 dataString += ","; 210 dataString += humidityString; 211 dataString += ","; 212 dataString += pressureString; 213 dataString += ","; 214 dataString += altitudeString; 215 dataString += ","; 216 dataString += latitudeString; 217 dataString += ","; 218 dataString += longitudeString; 219 dataString += ","; 220 dataString += speedString; 221 dataString += ","; 222 dataString += timeString; 223 224 Serial.println(dataString); 225 226 227 String first = "AT+SEND=0,"; // AT command for sending data to Software Serial port for Reyax module. Set this equal to the address for your reciever 228 first += String(dataString.length()); //number of characters in the transmission string 229 first += ","; 230 first += String(dataString); //Data string to be sent 231 Reyax.println(first); //Transmit data 232 digitalWrite(pin, HIGH); // turn the LED on signaling transmission was sent 233 delay(100); 234 digitalWrite(pin, LOW); 235 236 237 // open the file 238 File dataFile = SD.open("datalog.csv", FILE_WRITE); // Open file (1 can be open at a time) 239 240 if (dataFile) { // if the file is available, write to it: 241 dataFile.println(dataString); // Write data to SD card 242 dataFile.close(); // Close the file 243 } 244 // if the file isn't open, error 245 else { 246 Serial.println("error opening datalog.txt"); //If you recieve this error then you are not saving data. 247 } 248 249 //Each Transmission takes 0.2 seconds + runtime each. If you want it to be faster, reduce the delays on the LED flash. 250 //GPS will post data even if a fix is not met. Reccomended you wait until you recieve a fix before you use the device. 251 //This code will run until the 9v battery becomes too weak to use. Data processiong will be needed. 252} 253
Receiver.ino
c_cpp
This receives data from the transmitter, parses it and then saves it to an SD card.
1/**************************************************************************/ 2/*! 3 @file Reciever.ino 4 @author Thomas Knepshield (POWR Rocket Capstone Project (UNCG Spring 2022)) 5 6 Code for POWR Rocket implementing the following sensors: 7 1.Adafruit MicroSD card Breakout --- https://www.adafruit.com/product/254 8 1.1. I used a 32 gb SD card but any size works 9 2. Reyax RYLR 890 LoRa Module --- https://www.amazon.com/gp/product/B07NB3BK5H/ref=ox_sc_saved_image_4?smid=A2M9CC26G0VWTA&psc=1 10 11 Do not buy anything (other than Reyax Module) with headers unless you want the reciever on a breadboard. 12 13 Other Useful Things: 14 1. Wires --> https://www.amazon.com/dp/B07TX6BX47?psc=1&ref=ppx_yo2ov_dt_b_product_details 15 2. Bread Boards --> https://www.amazon.com/dp/B01EV6LJ7G?psc=1&ref=ppx_yo2ov_dt_b_product_details 16 3. Serial Adapter --> https://www.amazon.com/dp/B00LODGRV8?psc=1&ref=ppx_yo2ov_dt_b_product_details 17 4. Soder Set (Random one found) --> https://www.amazon.com/dp/B08R3515SF/ref=cm_sw_r_tw_dp_84MB274FP0PBHQ0C8E53 18 5. Wire Strippers --> https://www.amazon.com/dp/B000JNNWQ2/ref=cm_sw_r_tw_dp_FKMH2KSDEG139P8VXCN3 19 6. LED lights --> https://www.amazon.com/dp/B06XPV4CSH/ref=cm_sw_r_tw_dp_2Z13Y5QNM745NK9KX8ZM 20 21 Arduino Board Used: 22 1. Arduino Nano Every --- https://store-usa.arduino.cc/products/arduino-nano-every 23 1.1. Arduino Nano will work, but the every is better. 24 25 Pinouts: 26 1. MicroSD card Breakout 27 5v --> 5v 28 GND --> GND 29 CLK --> D13 30 DO --> D12 31 DI --> D11 32 CS --> (chipSelect) D10 33 2. LoRa Module 34 VDD --> 3.3v 35 GND --> GND 36 TX --> D8 37 3. LED Lights 38 D2 and GND for Recieving 39 40 41 Reyax AT Commands: 42 Done in the serial monitor (in tools) using a Serial Adapter. Change Baud to 115200 and "Both NL & CR". 43 1. AT 44 2. AT+RESET 45 3. AT+ADDRESS=1 (Change this number to your favorite number. Do not use 1 or the same number as the transmitter) 46 This is the recieving address so you have to change the code in transmitter.ino at AT+SEND= to equal this number 47 4. AT+IPR=38400 48 5. AT+PARAMETER=12,4,1,7 49 6. AT (Change baud rate to 38400 before doing this. Should get +OK) 50 51 52 Description 53 This code will recieve data from a Reyax RYLR 890 module and save it to an SD card. 54 LoRa reciever with selected parameter space will recieve data from a transmitter with a max of 4.5 - 8km without any objects in the way. 55 This code will print the recieved data to the seial monitor along with the setup lines to verify everything is working. 56 Using RX/TX pins on the Arduino Nano Every will not work so SoftwareSerial must be used for transmissions. 57 LED will blink once the code starts recieving data. Each blink is a revieved data point. 58 It will then parse the data into comma separated values for easier processing. 59 60 Tips 61 If any errors pop up it could be from incorrect wiring, failed boot or broken sensors. Incorrect wiring is a very common issue. 62 Also make sure you do not have any soder touching a reset pin. That will cause issues. 63 64 65 v1.0 - First release 66 UNCG, POWR Rocket project members, arduino and relevant parties are not responsible for any action that results in harm due to this project. 67 68 If you do recreate this project, let me know on Twitter (@tknep3) so I can follow along with your project and keep up with improvements. 69 Please send me your data so I can use it for future research. 70 71*/ 72/**************************************************************************/ 73 74#include <SoftwareSerial.h> 75#include <SPI.h> 76#include <SD.h> 77 78SoftwareSerial Reyax(8, 9); // RX, TX 79 80#define pin 2 81 82int chipSelect = 10; 83 84 85void setup() { 86 pinMode(pin, OUTPUT); 87 Serial.begin(9600); 88 Reyax.begin(38400); 89 90 Serial.print("Initializing SD card..."); 91 // see if the card is present and can be initialized: 92 if (!SD.begin(chipSelect)) { 93 Serial.println("Card failed, or not present"); 94 // don't do anything more: 95 while (1); 96 } 97 Serial.println("card initialized."); 98} 99 100void loop() { 101 if (Reyax.available()) { 102 String received = Reyax.readString(); 103 104 digitalWrite(pin, HIGH); // turn the LED on signaling data is recieved 105 delay(100); // wait for 1/10 106 digitalWrite(pin, LOW); 107 108 if (received.indexOf("+RCV") >= 0) { 109 int parser, parser_1, parser_2, parser_3; 110 parser = received.indexOf(","); 111 parser_1 = received.indexOf(",", parser + 1); 112 parser_2 = received.indexOf(",", parser_1 + 1); 113 parser_3 = received.indexOf(",", parser_2 + 1); 114 int lenMessage = received.substring(parser + 1, parser_1).toInt(); 115 116 String message = received.substring(parser_1 + 1, parser_1 + lenMessage + 1); 117 118 Serial.print("Recived message: "); 119 Serial.println(message); 120 121 // open the file 122 File dataFile = SD.open("datalog.csv", FILE_WRITE); // Open file (1 can be open at a time) 123 124 if (dataFile) { // if the file is available, write to it: 125 dataFile.println(message); // Write data to SD card 126 dataFile.close(); // Close the file 127 } 128 // if the file isn't open, error 129 else { 130 Serial.println("error opening datalog.txt"); 131 } 132 } 133 } 134}
Transmitter.ino
c_cpp
Code to use for the data collector that goes on the rocket.
1/**************************************************************************/ 2/*! 3 4 @file Transmitter.ino 5 @author Thomas Knepshield (POWR Rocket Capstone 6 Project (UNCG Spring 2022)) 7 8 Code for POWR Rocket implementing the following 9 sensors: 10 1. Adafruit MPL3115A2 --- https://www.adafruit.com/product/992 11 12 2. Adafruit SHT31 --- https://www.adafruit.com/product/2857 13 3. Adafruit 14 Ultimate GPS --- https://www.adafruit.com/product/746 15 4. Adafruit MicroSD 16 card Breakout --- https://www.adafruit.com/product/254 17 4.1. I used a 32 18 gb SD card but any size works 19 5. Reyax RYLR 890 LoRa Module --- https://www.amazon.com/gp/product/B07NB3BK5H/ref=ox_sc_saved_image_4?smid=A2M9CC26G0VWTA&psc=1 20 21 22 Arduino Board Used: 23 1. Arduino Nano Every --- https://store-usa.arduino.cc/products/arduino-nano-every 24 25 1.1. Must use a board with specs similar to or greater than this board. Arduino 26 Nano will NOT work. 27 28 Rocket Used 29 1. Estes Loadstar --> https://www.discountrocketry.com/estes-loadstar-p-1772.html 30 31 32 Do not buy any electronics (other than Reyax Module) with headers. It will 33 be hard to assemble with them. 34 35 Other Useful Things: 36 1. Wires --> 37 https://www.amazon.com/dp/B07TX6BX47?psc=1&ref=ppx_yo2ov_dt_b_product_details 38 39 2. Bread Boards --> https://www.amazon.com/dp/B01EV6LJ7G?psc=1&ref=ppx_yo2ov_dt_b_product_details 40 41 3. Serial Adapter --> https://www.amazon.com/dp/B00LODGRV8?psc=1&ref=ppx_yo2ov_dt_b_product_details 42 43 4. Soder Set (Random one found) --> https://www.amazon.com/dp/B08R3515SF/ref=cm_sw_r_tw_dp_84MB274FP0PBHQ0C8E53 44 45 5. Wire Strippers --> https://www.amazon.com/dp/B000JNNWQ2/ref=cm_sw_r_tw_dp_FKMH2KSDEG139P8VXCN3 46 47 6. 9v Batteries --> Anywhere 48 7. 2x LED lights --> https://www.amazon.com/dp/B06XPV4CSH/ref=cm_sw_r_tw_dp_2Z13Y5QNM745NK9KX8ZM 49 50 51 Pinouts: 52 1. MPL3115A2 53 Vin --> 5v 54 GND --> GND 55 SCL 56 --> A5 57 SDA --> A4 58 2. SHT31 59 Vin --> 5v 60 GND --> 61 GND 62 SCL --> A5 63 SDA --> A4 64 3. Ultimate GPS 65 Vin 66 --> 5v 67 GND --> GND 68 RX --> D7 69 TX --> D8 70 4. MicroSD 71 card Breakout 72 5v --> 5v 73 GND --> GND 74 CLK --> D13 75 76 DO --> D12 77 DI --> D11 78 CS --> (ChipSelect) D10 79 5. 80 LoRa Module 81 VDD --> 3.3v 82 GND --> GND 83 RX --> D9 84 10k 85 Ohm Resisitor D9 --> RX 86 5k Ohm Resistor RX --> GND 87 6. LED Lights 88 89 1. D2 and GND for Transmission 90 2. D3 and GND for GPS 91 92 93 94 Reyax AT Commands: 95 Done in the serial monitor (in tools) using a Serial 96 Adapter. Change Baud to 115200 and "Both NL & CR". 97 1. AT 98 2. 99 AT+RESET 100 3. AT+ADDRESS=1 (Change this number to your favorite number. Do 101 not use 1) 102 4. AT+IPR=38400 103 5. AT+PARAMETER=12,4,1,7 104 6. 105 AT (Change baud rate to 38400 before doing this. Should get +OK) 106 107 108 Description 109 110 This code uses the described sensors to collect the barometric pressure, 111 humidity, temperature, latitude, longitude, altitude, time and speed. 112 It 113 then will concatenate the float values into strings and transmit it using LoRa. 114 Once it transmits the data, it will also save the 115 values on a micro SD 116 card. This SD card will hold every data point. LoRa transmitter with selected parameter 117 space will transmit data 118 with a max of 4.5 - 8km without any objects in 119 the way. 120 This code will not print anything to the seial monitor other 121 than the setup lines to verify everything is working. 122 Using RX/TX pins 123 on the Arduino Nano Every will not work so SoftwareSerial must be used for transmissions. 124 125 First LED will blink once the code starts transmitting data. 126 127 Tips 128 129 If any errors pop up it could be from incorrect wiring, failed boot or broken 130 sensors. Incorrect wiring is a very common issue. 131 Also make sure you do 132 not have any soder touching a reset pin. That will cause issues. 133 134 135 v1.0 136 - First release 137 UNCG, POWR Rocket project members, arduino and relevant parties 138 are not responsible for any action that results in harm due to this project. 139 140 141 If you do recreate this project, let me know on Twitter (@tknep3) so I can follow 142 along with your project and keep up with improvements. 143 Please send me your 144 data so I can use it for future research. 145*/ 146/**************************************************************************/ 147 148#include 149 "Adafruit_SHT31.h" 150#include <Adafruit_MPL3115A2.h> 151#include <SPI.h> 152#include 153 <SD.h> 154#include <Arduino.h> 155#include <Wire.h> 156#include <SoftwareSerial.h> 157#include 158 "TinyGPS++.h" 159 160 161//Make sure to download the libararies in tools/manage 162 libraries. Type in each sensor name. 163 164#define pin 2 // Used with the LED 165#define 166 gpsPin 3 //Used with GPS 167 168SoftwareSerial GPS(8, 7); // RX, TX 169SoftwareSerial 170 Reyax(8, 9); // RX, TX 171TinyGPSPlus tinygps; 172 173Adafruit_SHT31 sht31 = Adafruit_SHT31(); 174 // Initialize SHT31 sensor 175Adafruit_MPL3115A2 baro; // Setup the pressure for 176 the MPL3115A2 sensor (value put in below) 177const int chipSelect = 10; // port 178 for CS with the SD card 179const double currentPressure = 1013.26; //Change this 180 to currect pressure in hPa for accurate results 181int id = 0; 182 183 184void setup() 185 { 186 // initialize digital pin LED_BUILTIN as an output. 187 pinMode(pin, OUTPUT); 188 // Initialize LED as output for Transmission 189 pinMode(gpsPin, OUTPUT); // Initialize 190 LED as output for GPS fix 191 Serial.begin(9600); // Start the serial ports 192 193 Reyax.begin(38400); // Start the Reyax module Software Serial port 194 GPS.begin(9600); 195 //Start the GPS module 196 197 // Make sure all sensors are initialized, wired 198 correctly and are operational 199 200 Serial.println("SHT31 test"); //Test SHT31 201 Sensor 202 if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr 203 204 Serial.println("Couldn't find SHT31"); 205 while (1) delay(1); 206 } 207 208 209 Serial.println("Adafruit_MPL3115A2 test!"); //Test MPL3115A2 sensor 210 211 212 if (!baro.begin()) { 213 Serial.println("Could not find sensor. Check wiring."); 214 215 while (1); 216 } 217 218 // use to set pressure for current location 219 baro.setSeaPressure(currentPressure); 220 221 222 Serial.print("Initializing SD card..."); 223 // see if the card is present 224 and can be initialized: 225 if (!SD.begin(chipSelect)) { 226 Serial.println("Card 227 failed, or not present"); 228 while (1); 229 } 230 Serial.println("card initialized."); 231 232 233 Serial.println("Setup complete"); 234 //Loop will start once this is printed 235 to Serial Monitor. 236 237} 238 239void loop() { 240 241 while (GPS.available() 242 > 0) { 243 if (tinygps.encode(GPS.read())) { // Did a new valid sentence come 244 in? 245 digitalWrite(gpsPin, HIGH); // turn the LED on signaling transmission 246 was sent 247 delay(100); 248 digitalWrite(gpsPin, LOW); 249 } 250 } 251 252 253 String pressureString = ""; // empty strings for data 254 String altitudeString 255 = ""; 256 String temperatureString = ""; 257 String humidityString = ""; 258 259 String latitudeString = ""; 260 String longitudeString = ""; 261 String 262 speedString = ""; 263 String idString = ""; 264 String hourString = ""; 265 266 String minuteString = ""; 267 String secondString = ""; 268 String timeString 269 = ""; 270 String dataString = ""; 271 272 pressureString.concat(baro.getPressure()); 273 // Concatenate number values into Strings 274 altitudeString.concat(tinygps.altitude.meters()); 275 276 temperatureString.concat(baro.getTemperature()); 277 humidityString.concat(sht31.readHumidity()); 278 279 latitudeString.concat(String(tinygps.location.lng(),6)); 280 longitudeString.concat(String(tinygps.location.lat(),6)); 281 282 speedString.concat(tinygps.speed.kmph()); 283 hourString.concat(tinygps.time.hour()); 284 285 minuteString.concat(tinygps.time.minute()); 286 secondString.concat(tinygps.time.second()); 287 288 289 timeString += hourString; // Create time string in XX:XX:XX format 290 timeString 291 += ":"; 292 timeString += minuteString; 293 timeString += ":"; 294 timeString 295 += secondString; 296 297 idString = String(id++); 298 299 dataString += idString; 300 301 dataString += ","; 302 dataString += temperatureString; //Create string for 303 data transmission separated by , 304 dataString += ","; 305 dataString += humidityString; 306 307 dataString += ","; 308 dataString += pressureString; 309 dataString += ","; 310 311 dataString += altitudeString; 312 dataString += ","; 313 dataString += latitudeString; 314 315 dataString += ","; 316 dataString += longitudeString; 317 dataString += ","; 318 319 dataString += speedString; 320 dataString += ","; 321 dataString += timeString; 322 323 324 Serial.println(dataString); 325 326 327 String first = "AT+SEND=0,"; // AT 328 command for sending data to Software Serial port for Reyax module. Set this equal 329 to the address for your reciever 330 first += String(dataString.length()); //number 331 of characters in the transmission string 332 first += ","; 333 first += String(dataString); 334 //Data string to be sent 335 Reyax.println(first); //Transmit data 336 digitalWrite(pin, 337 HIGH); // turn the LED on signaling transmission was sent 338 delay(100); 339 340 digitalWrite(pin, LOW); 341 342 343 // open the file 344 File dataFile = SD.open("datalog.csv", 345 FILE_WRITE); // Open file (1 can be open at a time) 346 347 if (dataFile) { // 348 if the file is available, write to it: 349 dataFile.println(dataString); // Write 350 data to SD card 351 dataFile.close(); // Close the file 352 } 353 // if the 354 file isn't open, error 355 else { 356 Serial.println("error opening datalog.txt"); 357 //If you recieve this error then you are not saving data. 358 } 359 360 //Each 361 Transmission takes 0.2 seconds + runtime each. If you want it to be faster, reduce 362 the delays on the LED flash. 363 //GPS will post data even if a fix is not met. 364 Reccomended you wait until you recieve a fix before you use the device. 365 //This 366 code will run until the 9v battery becomes too weak to use. Data processiong will 367 be needed. 368} 369
Downloadable files
Receiver Diagram
This is the pinout diagram for the Receiver.
Receiver Diagram
Transmitter Diagram
Here is the breadboard wiring of the rocket. Code has comments describing the pinouts. Photos added will help with the resistors.
Transmitter Diagram
Receiver Diagram
This is the pinout diagram for the Receiver.
Receiver Diagram
Transmitter Diagram
Here is the breadboard wiring of the rocket. Code has comments describing the pinouts. Photos added will help with the resistors.
Transmitter Diagram
Comments
Only logged in users can leave comments