moved GPS data to XS

pull/79/head
alanbjohnston 5 years ago committed by GitHub
parent 27df3ec3c7
commit 355af78402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,3 +1,10 @@
// Payload software for CubeSatSim STEM Payload Board
// Arduino software for STM32 or Arduino Pro Micro
//
// BME280 code based on
// MPU6050 code based on
// GPS code based on TinyGPS simple_test example
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
@ -17,9 +24,9 @@ int mpuPresent = 0;
int RXLED = 17; // The RX LED has a defined Arduino pin
int greenLED = 9;
int blueLED = 8;
int Sensor1 = 0;
int Sensor2 = 0;
float Sensor3 = 0;
float Sensor1 = 0.0;
float Sensor2 = 0.0;
float Sensor3 = 0.0;
void eeprom_word_write(int addr, int val);
short eeprom_word_read(int addr);
float lat = 0.0, lon = 0.0, alt = 0.0;
@ -27,9 +34,7 @@ float lat = 0.0, lon = 0.0, alt = 0.0;
void setup() {
Serial.begin(9600); // Serial Monitor for testing
Serial1.begin(9600); // Pi UART
Serial2.begin(9600); // GPS on STM32 pins PA2, PA3
Serial.println("Starting!");
@ -50,7 +55,6 @@ void setup() {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
bmePresent = 0;
}
/**/
Wire.beginTransmission(0x68);
// Serial.print(address, HEX);
@ -153,51 +157,17 @@ void loop() {
Serial.print(" ");
Serial.print(Sensor2);
Serial.print(" ");
Serial.print(Sensor3);
Serial.println(Sensor3);
/*
Serial.print(" GPS "); // return previous GPS data (can't wait due to 1 sec delay)
Serial.print(lat);
Serial.print(" ");
Serial.print(lon);
Serial.print(" ");
Serial.println(alt);
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;) // 1000;)
{
while (Serial2.available())
{
char c = Serial2.read();
// Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}
if (newData)
{
float flon, flat;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
lat = flat * 100;
lon = flon * 100;
alt = (float) gps.altitude()/100.0;
*/
/*
Serial.print("LAT=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" LON=");
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
Serial.print(" SAT=");
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
Serial.print(" PREC=");
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
*/
}
float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()*mpu6050.getGyroZ());
float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ());
// Serial.print(rotation);
@ -212,7 +182,8 @@ void loop() {
if (rotation > 5)
digitalWrite(blueLED, HIGH);
else
digitalWrite(blueLED, LOW);
digitalWrite(blueLED, LOW);
*/
}
}
@ -270,8 +241,45 @@ void loop() {
Serial1.print(" ");
Serial1.print(Sensor3);
Serial1.println(" GPS 0.0 0.0");
// Serial1.println(" GPS 0.0 0.0");
}
}
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;) // 1000;)
{
while (Serial2.available())
{
char c = Serial2.read();
// Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}
if (newData)
{
float flon, flat;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Sensor1 = flat * 100;
Sensor2 = flon * 100;
Sensor3 = (float) gps.altitude()/100.0;
/*
Serial.print("LAT=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" LON=");
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
Serial.print(" SAT=");
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
Serial.print(" PREC=");
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
*/
}
float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()*mpu6050.getGyroZ());
float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ());
// Serial.print(rotation);
@ -287,9 +295,6 @@ void loop() {
digitalWrite(blueLED, HIGH);
else
digitalWrite(blueLED, LOW);
}
}
// delay(100);
}

Loading…
Cancel
Save

Powered by TurnKey Linux.