From 97adb4feab9f5ccb6d8ec126141abe482c94bf61 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 13:05:38 -0500 Subject: [PATCH 01/27] initial add of payload telemetry string uploader to tago dashboard --- groundstation/aprs-upload.py | 130 +++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 groundstation/aprs-upload.py diff --git a/groundstation/aprs-upload.py b/groundstation/aprs-upload.py new file mode 100644 index 00000000..4dc0b5a1 --- /dev/null +++ b/groundstation/aprs-upload.py @@ -0,0 +1,130 @@ +import tago + +print("Input telemetry string") + +telem_string = input() + +chunks = telem_string.split(' ') + +#printchunks = str.split(' ') + +print(chunks) + +temp = 0 +pressure = 0 +altitude = 0 +humidity = 0 + +timestamp = chunks[0] + " " + chunks[1] +print(timestamp) + +lat1 = chunks[3].split("=") +lat2_dm = lat1[1].split("N") +lat_float = float(lat2_dm[0]) + +lon1 = lat2_dm[1].split("/") +lon2_dm = lon1[1].split("W") +lon_float = float(lon2_dm[0]) + +print(lat_float) +print(lon_float) + +lat_int = int(lat_float/100) +lat_mm = int(lat_float - lat_int * 100) +lat_mm2 = lat_float - int(lat_float) * 100 + +lat = lat_int + (lat_mm / 60.0) + (lat_mm2 / (60.0 * 60.0)) + +lon_int = int(lon_float/100) +lon_mm = int(lon_float - lon_int * 100) +lon_mm2 = lon_float - int(lon_float) * 100 + +lon = -1.0 * (lon_int + (lon_mm / 60.0) + (lon_mm2 / (60.0 * 60.0))) + +print(lat) +print(lon) + +lat = lat_float / 100.0 +lon = lon_float / (-100.0) + +for i in range(len(chunks)): + if (chunks[i] == "BME280"): + print("Found BME280") + temp = chunks[i+1] + pressure = chunks[i+2] + altitude = chunks[i+3] + humidity = chunks[i+4] + print(temp) + print(humidity) + + +#print(telem_string) + + +my_device = tago.Device('a824cdc6-dc87-4c54-a848-41dabb8873ad') + +""" +The following code defines the set of data to be sent to TagoIO +data fields: +- variable name +- variable unit +- variable value +- Optional: desired data timestamp +- Optional: lat/long location (associated to your data) +""" +data = { + 'variable': 'temperature', + 'unit' : 'C', + 'value' : temp, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} + +result = my_device.insert(data) +print(result) + +#print(data) + +data = { + 'variable': 'pressure', + 'unit' : 'kPa', + 'value' : pressure, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} + +result = my_device.insert(data) +print(result) + +data = { + 'variable': 'altitude', + 'unit' : 'm', + 'value' : altitude, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} + +result = my_device.insert(data) +print(result) + +data = { + 'variable': 'humidity', + 'unit' : '%', + 'value' : humidity, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} + +result = my_device.insert(data) +print(result) + +data = { + "variable": "location", + "value": "Villanova University HAB-2", + "location": { + "lat": lat, + "lng": lon + } +} +result = my_device.insert(data) +print(result) From 4a6ce151bd735bfe3fc98eb5e93c5975e8610cd9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 13:06:25 -0500 Subject: [PATCH 02/27] Rename aprs-upload.py to tago-upload.py --- groundstation/{aprs-upload.py => tago-upload.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename groundstation/{aprs-upload.py => tago-upload.py} (100%) diff --git a/groundstation/aprs-upload.py b/groundstation/tago-upload.py similarity index 100% rename from groundstation/aprs-upload.py rename to groundstation/tago-upload.py From b46c48f3f2094a5af03cb6896790a98c5fd7ed67 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 13:56:04 -0500 Subject: [PATCH 03/27] start MPU6050 --- groundstation/tago-upload.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 4dc0b5a1..8566c679 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -56,7 +56,9 @@ for i in range(len(chunks)): humidity = chunks[i+4] print(temp) print(humidity) - + if (chunks[i] == "MPU6050"): + print("Found MPU6050") + x_rotate = chunks[i+1] #print(telem_string) From ce28246c092b249544ead046bd016740268ed801 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 14:00:33 -0500 Subject: [PATCH 04/27] added x, y, z rotation --- groundstation/tago-upload.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 8566c679..56185c5a 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -59,7 +59,9 @@ for i in range(len(chunks)): if (chunks[i] == "MPU6050"): print("Found MPU6050") x_rotate = chunks[i+1] - + y_rotate = chunks[i+2] + z_rotate = chunks[i+3] + #print(telem_string) @@ -116,10 +118,39 @@ data = { 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} } +result = my_device.insert(data) +print(result) +data = { + 'variable': 'x_rotate', + 'unit' : '%', + 'value' : x_rotate, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} result = my_device.insert(data) print(result) - + +data = { + 'variable': 'y_rotate', + 'unit' : '%', + 'value' : y_rotate, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} +result = my_device.insert(data) + +print(result) +data = { + 'variable': 'z_rotate', + 'unit' : '%', + 'value' : z_rotate, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} +result = my_device.insert(data) +print(result) + data = { "variable": "location", "value": "Villanova University HAB-2", From 863c49cfdd6a95bf5bc745a08933fbc8597b9e84 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 14:05:19 -0500 Subject: [PATCH 05/27] added x, y, z accel --- groundstation/tago-upload.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 56185c5a..ada8793c 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -61,6 +61,9 @@ for i in range(len(chunks)): x_rotate = chunks[i+1] y_rotate = chunks[i+2] z_rotate = chunks[i+3] + x_accel = chunks[i+4] + y_accel = chunks[i+5] + z_accel = chunks[i+6] #print(telem_string) @@ -141,6 +144,7 @@ data = { result = my_device.insert(data) print(result) + data = { 'variable': 'z_rotate', 'unit' : '%', @@ -151,6 +155,36 @@ data = { result = my_device.insert(data) print(result) +data = { + 'variable': 'x_accel', + 'unit' : '%', + 'value' : x_accel, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} +result = my_device.insert(data) +print(result) + +data = { + 'variable': 'y_accel', + 'unit' : '%', + 'value' : y_accel, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} +result = my_device.insert(data) +print(result) + +data = { + 'variable': 'z_accel', + 'unit' : '%', + 'value' : z_accel, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} +} +result = my_device.insert(data) +print(result) + data = { "variable": "location", "value": "Villanova University HAB-2", From 2e290db1970a0eca953f16ebff1f62c35decd93c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 22:54:52 -0500 Subject: [PATCH 06/27] fixed units --- groundstation/tago-upload.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index ada8793c..7404b823 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -126,7 +126,7 @@ print(result) data = { 'variable': 'x_rotate', - 'unit' : '%', + 'unit' : 'dps', 'value' : x_rotate, 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} @@ -136,7 +136,7 @@ print(result) data = { 'variable': 'y_rotate', - 'unit' : '%', + 'unit' : 'dps', 'value' : y_rotate, 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} @@ -147,7 +147,7 @@ print(result) data = { 'variable': 'z_rotate', - 'unit' : '%', + 'unit' : 'dps', 'value' : z_rotate, 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} @@ -157,7 +157,7 @@ print(result) data = { 'variable': 'x_accel', - 'unit' : '%', + 'unit' : 'g', 'value' : x_accel, 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} @@ -167,7 +167,7 @@ print(result) data = { 'variable': 'y_accel', - 'unit' : '%', + 'unit' : 'g', 'value' : y_accel, 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} @@ -177,7 +177,7 @@ print(result) data = { 'variable': 'z_accel', - 'unit' : '%', + 'unit' : 'g', 'value' : z_accel, 'time' : timestamp, 'location': {'lat': lat, 'lng': lon} From ba5f042bfb3b5c3fd383149e9f05984980963046 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 22:56:45 -0500 Subject: [PATCH 07/27] added while loop --- groundstation/tago-upload.py | 392 ++++++++++++++++++----------------- 1 file changed, 197 insertions(+), 195 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 7404b823..3b396727 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -1,197 +1,199 @@ import tago + +while (true): -print("Input telemetry string") - -telem_string = input() - -chunks = telem_string.split(' ') - -#printchunks = str.split(' ') - -print(chunks) - -temp = 0 -pressure = 0 -altitude = 0 -humidity = 0 - -timestamp = chunks[0] + " " + chunks[1] -print(timestamp) - -lat1 = chunks[3].split("=") -lat2_dm = lat1[1].split("N") -lat_float = float(lat2_dm[0]) - -lon1 = lat2_dm[1].split("/") -lon2_dm = lon1[1].split("W") -lon_float = float(lon2_dm[0]) - -print(lat_float) -print(lon_float) - -lat_int = int(lat_float/100) -lat_mm = int(lat_float - lat_int * 100) -lat_mm2 = lat_float - int(lat_float) * 100 - -lat = lat_int + (lat_mm / 60.0) + (lat_mm2 / (60.0 * 60.0)) - -lon_int = int(lon_float/100) -lon_mm = int(lon_float - lon_int * 100) -lon_mm2 = lon_float - int(lon_float) * 100 - -lon = -1.0 * (lon_int + (lon_mm / 60.0) + (lon_mm2 / (60.0 * 60.0))) - -print(lat) -print(lon) - -lat = lat_float / 100.0 -lon = lon_float / (-100.0) - -for i in range(len(chunks)): - if (chunks[i] == "BME280"): - print("Found BME280") - temp = chunks[i+1] - pressure = chunks[i+2] - altitude = chunks[i+3] - humidity = chunks[i+4] - print(temp) - print(humidity) - if (chunks[i] == "MPU6050"): - print("Found MPU6050") - x_rotate = chunks[i+1] - y_rotate = chunks[i+2] - z_rotate = chunks[i+3] - x_accel = chunks[i+4] - y_accel = chunks[i+5] - z_accel = chunks[i+6] - -#print(telem_string) - - -my_device = tago.Device('a824cdc6-dc87-4c54-a848-41dabb8873ad') - -""" -The following code defines the set of data to be sent to TagoIO -data fields: -- variable name -- variable unit -- variable value -- Optional: desired data timestamp -- Optional: lat/long location (associated to your data) -""" -data = { - 'variable': 'temperature', - 'unit' : 'C', - 'value' : temp, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} - -result = my_device.insert(data) -print(result) - -#print(data) - -data = { - 'variable': 'pressure', - 'unit' : 'kPa', - 'value' : pressure, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} - -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'altitude', - 'unit' : 'm', - 'value' : altitude, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} - -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'humidity', - 'unit' : '%', - 'value' : humidity, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'x_rotate', - 'unit' : 'dps', - 'value' : x_rotate, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'y_rotate', - 'unit' : 'dps', - 'value' : y_rotate, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) - -print(result) - -data = { - 'variable': 'z_rotate', - 'unit' : 'dps', - 'value' : z_rotate, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'x_accel', - 'unit' : 'g', - 'value' : x_accel, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'y_accel', - 'unit' : 'g', - 'value' : y_accel, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) -print(result) - -data = { - 'variable': 'z_accel', - 'unit' : 'g', - 'value' : z_accel, - 'time' : timestamp, - 'location': {'lat': lat, 'lng': lon} -} -result = my_device.insert(data) -print(result) - -data = { - "variable": "location", - "value": "Villanova University HAB-2", - "location": { - "lat": lat, - "lng": lon - } -} -result = my_device.insert(data) -print(result) + print("Input telemetry string (or Control-C to exit)") + + telem_string = input() + + chunks = telem_string.split(' ') + + #printchunks = str.split(' ') + + print(chunks) + + temp = 0 + pressure = 0 + altitude = 0 + humidity = 0 + + timestamp = chunks[0] + " " + chunks[1] + print(timestamp) + + lat1 = chunks[3].split("=") + lat2_dm = lat1[1].split("N") + lat_float = float(lat2_dm[0]) + + lon1 = lat2_dm[1].split("/") + lon2_dm = lon1[1].split("W") + lon_float = float(lon2_dm[0]) + + print(lat_float) + print(lon_float) + + lat_int = int(lat_float/100) + lat_mm = int(lat_float - lat_int * 100) + lat_mm2 = lat_float - int(lat_float) * 100 + + lat = lat_int + (lat_mm / 60.0) + (lat_mm2 / (60.0 * 60.0)) + + lon_int = int(lon_float/100) + lon_mm = int(lon_float - lon_int * 100) + lon_mm2 = lon_float - int(lon_float) * 100 + + lon = -1.0 * (lon_int + (lon_mm / 60.0) + (lon_mm2 / (60.0 * 60.0))) + + print(lat) + print(lon) + + lat = lat_float / 100.0 + lon = lon_float / (-100.0) + + for i in range(len(chunks)): + if (chunks[i] == "BME280"): + print("Found BME280") + temp = chunks[i+1] + pressure = chunks[i+2] + altitude = chunks[i+3] + humidity = chunks[i+4] + print(temp) + print(humidity) + if (chunks[i] == "MPU6050"): + print("Found MPU6050") + x_rotate = chunks[i+1] + y_rotate = chunks[i+2] + z_rotate = chunks[i+3] + x_accel = chunks[i+4] + y_accel = chunks[i+5] + z_accel = chunks[i+6] + + #print(telem_string) + + + my_device = tago.Device('a824cdc6-dc87-4c54-a848-41dabb8873ad') + + """ + The following code defines the set of data to be sent to TagoIO + data fields: + - variable name + - variable unit + - variable value + - Optional: desired data timestamp + - Optional: lat/long location (associated to your data) + """ + data = { + 'variable': 'temperature', + 'unit' : 'C', + 'value' : temp, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + + result = my_device.insert(data) + print(result) + + #print(data) + + data = { + 'variable': 'pressure', + 'unit' : 'kPa', + 'value' : pressure, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'altitude', + 'unit' : 'm', + 'value' : altitude, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'humidity', + 'unit' : '%', + 'value' : humidity, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'x_rotate', + 'unit' : 'dps', + 'value' : x_rotate, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'y_rotate', + 'unit' : 'dps', + 'value' : y_rotate, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + + print(result) + + data = { + 'variable': 'z_rotate', + 'unit' : 'dps', + 'value' : z_rotate, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'x_accel', + 'unit' : 'g', + 'value' : x_accel, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'y_accel', + 'unit' : 'g', + 'value' : y_accel, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'z_accel', + 'unit' : 'g', + 'value' : z_accel, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + "variable": "location", + "value": "Villanova University HAB-2", + "location": { + "lat": lat, + "lng": lon + } + } + result = my_device.insert(data) + print(result) From b5cb19e07e0ac85cdd42652c9e1eb43035a54db3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Mar 2022 22:57:21 -0500 Subject: [PATCH 08/27] typo --- groundstation/tago-upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 3b396727..f10b70d4 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -1,6 +1,6 @@ import tago -while (true): +while (True): print("Input telemetry string (or Control-C to exit)") From c1cb70f5c6a6c1a0f80737b141fc47d822908e59 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Mar 2022 08:48:42 -0500 Subject: [PATCH 09/27] Create Payload_OK_SGP30.ino --- stempayload/Payload_OK_SGP30.ino | 385 +++++++++++++++++++++++++++++++ 1 file changed, 385 insertions(+) create mode 100644 stempayload/Payload_OK_SGP30.ino diff --git a/stempayload/Payload_OK_SGP30.ino b/stempayload/Payload_OK_SGP30.ino new file mode 100644 index 00000000..cc267f72 --- /dev/null +++ b/stempayload/Payload_OK_SGP30.ino @@ -0,0 +1,385 @@ +// code for Pro Micro or STM32 on the CubeSat Simulator STEM Payload board +// answers "OK" on the serial port Serial1 when queried by the Pi +// includes code by Christy Ammon + + +#include +#include +#include +#include +#include +#include +#define SEALEVELPRESSURE_HPA (1013.25) + +Adafruit_BME280 bme; +Adafruit_SGP30 sgp; +MPU6050 mpu6050(Wire); + +long timer = 0; +int bmePresent; +int RXLED = 17; // The RX LED has a defined Arduino pin +int greenLED = 9; +int blueLED = 8; +int Sensor1 = 0; +float Sensor2 = 0; +void eeprom_word_write(int addr, int val); +short eeprom_word_read(int addr); +int first_time = true; +int first_read = true; + +#if defined __AVR_ATmega32U4__ +float T2 = 26.3; // Temperature data point 1 +float R2 = 167; // Reading data point 1 +float T1 = 2; // Temperature data point 2 +float R1 = 179; // Reading data point 2 +#endif +#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) +float T2 = 25; // Temperature data point 1 +float R2 = 671; // Reading data point 1 +float T1 = 15.5; // Temperature data point 2 +float R1 = 695; // Reading data point 2 +#endif + +int sensorValue; +float Temp; +float rest; + +void setup() { + Serial.begin(9600); // Serial Monitor for testing + + Serial1.begin(115200); // Pi UART faster speed +// Serial1.begin(9600); // Pi UART faster speed + + Serial.println("Starting!"); + + blink_setup(); + + blink(500); + delay(250); + blink(500); + delay(250); + led_set(greenLED, HIGH); + delay(250); + led_set(greenLED, LOW); + led_set(blueLED, HIGH); + delay(250); + led_set(blueLED, LOW); + + if (bme.begin(0x76)) { + bmePresent = 1; + } else { + Serial.println("Could not find a valid BME280 sensor, check wiring!"); + bmePresent = 0; + } + + mpu6050.begin(); + + if (eeprom_word_read(0) == 0xA07) + { + Serial.println("Reading gyro offsets from EEPROM\n"); + + float xOffset = ((float)eeprom_word_read(1)) / 100.0; + float yOffset = ((float)eeprom_word_read(2)) / 100.0; + float zOffset = ((float)eeprom_word_read(3)) / 100.0; + + Serial.println(xOffset, DEC); + Serial.println(yOffset, DEC); + Serial.println(zOffset, DEC); + + mpu6050.setGyroOffsets(xOffset, yOffset, zOffset); + } + else + { + Serial.println("Calculating gyro offsets and storing in EEPROM\n"); + + mpu6050.calcGyroOffsets(true); + + eeprom_word_write(0, 0xA07); + eeprom_word_write(1, (int)(mpu6050.getGyroXoffset() * 100.0) + 0.5); + eeprom_word_write(2, (int)(mpu6050.getGyroYoffset() * 100.0) + 0.5); + eeprom_word_write(3, (int)(mpu6050.getGyroZoffset() * 100.0) + 0.5); + + Serial.println(eeprom_word_read(0), HEX); + Serial.println(((float)eeprom_word_read(1)) / 100.0, DEC); + Serial.println(((float)eeprom_word_read(2)) / 100.0, DEC); + Serial.println(((float)eeprom_word_read(3)) / 100.0, DEC); + } +/**/ + if (! sgp.begin()){ + Serial.println("Sensor not found :("); + while (1); + } + Serial.print("Found SGP30 serial #"); + Serial.print(sgp.serialnumber[0], HEX); + Serial.print(sgp.serialnumber[1], HEX); + Serial.println(sgp.serialnumber[2], HEX); + + // If you have a baseline measurement from before you can assign it to start, to 'self-calibrate' + //sgp.setIAQBaseline(0x8E68, 0x8F41); // Will vary for each sensor! + +} + +void loop() { + + if (Serial1.available() > 0) { + blink(50); + char result = Serial1.read(); +// Serial1.println(result); +// Serial1.println("OK"); + +// if (result == '?') + { + if (bmePresent) { + Serial1.print("OK BME280 "); + Serial1.print(bme.readTemperature()); + Serial1.print(" "); + Serial1.print(bme.readPressure() / 100.0F); + Serial1.print(" "); + Serial1.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); + Serial1.print(" "); + Serial1.print(bme.readHumidity()); + } else + { + Serial1.print("OK BME280 0.0 0.0 0.0 0.0"); + } + mpu6050.update(); + + Serial1.print(" MPU6050 "); + Serial1.print(mpu6050.getGyroX()); + Serial1.print(" "); + Serial1.print(mpu6050.getGyroY()); + Serial1.print(" "); + Serial1.print(mpu6050.getGyroZ()); + + Serial1.print(" "); + Serial1.print(mpu6050.getAccX()); + Serial1.print(" "); + Serial1.print(mpu6050.getAccY()); + Serial1.print(" "); + Serial1.print(mpu6050.getAccZ()); + + sensorValue = read_analog(); + +// Serial.println(sensorValue); + Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); + + Serial1.print(" XS "); + Serial1.print(Temp); + Serial1.print(" "); + Serial1.println(Sensor2); + + 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); +// Serial.print(" "); +// Serial.println(acceleration); + + if (first_read == true) { + first_read = false; + rest = acceleration; + } + + if (acceleration > 1.2 * rest) + led_set(greenLED, HIGH); + else + led_set(greenLED, LOW); + + if (rotation > 5) + led_set(blueLED, HIGH); + else + led_set(blueLED, LOW); + } + + } + + if (Serial.available() > 0) { + blink(50); + char result = Serial.read(); +// Serial.println(result); +// Serial.println("OK"); +// Serial.println(counter++); + + if (result == 'R') { + Serial1.println("OK"); + delay(100); + first_read = true; + setup(); + } + else if (result == 'C') { + Serial.println("Clearing stored gyro offsets in EEPROM\n"); + eeprom_word_write(0, 0x00); + first_time = true; + setup(); + } + + if ((result == '?') || first_time == true) + { + first_time = false; + if (bmePresent) { + Serial.print("OK BME280 "); + Serial.print(bme.readTemperature()); + Serial.print(" "); + Serial.print(bme.readPressure() / 100.0F); + Serial.print(" "); + Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); + Serial.print(" "); + Serial.print(bme.readHumidity()); + } else + { + Serial.print("OK BME280 0.0 0.0 0.0 0.0"); + } + mpu6050.update(); + + Serial.print(" MPU6050 "); + Serial.print(mpu6050.getGyroX()); + Serial.print(" "); + Serial.print(mpu6050.getGyroY()); + Serial.print(" "); + Serial.print(mpu6050.getGyroZ()); + + Serial.print(" "); + Serial.print(mpu6050.getAccX()); + Serial.print(" "); + Serial.print(mpu6050.getAccY()); + Serial.print(" "); + Serial.print(mpu6050.getAccZ()); + + sensorValue = read_analog(); + + Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); +/* + Serial.print(" XS "); + Serial.print(Temp); + Serial.print(" "); + Serial.print(Sensor2); + Serial.print(" ("); + Serial.print(sensorValue); + Serial.print(")"); +*/ + 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); +// Serial.print(" "); +// Serial.println(acceleration); + + if (first_read == true) { + first_read = false; + rest = acceleration; + } + + if (acceleration > 1.2 * rest) + led_set(greenLED, HIGH); + else + led_set(greenLED, LOW); + + if (rotation > 5) + led_set(blueLED, HIGH); + else + led_set(blueLED, LOW); + } + + //SGP SENSOR DATA + if (! sgp.IAQmeasure()) { + Serial.println("SGP 30 Measurement failed"); +// return; + } + Serial.print(" SGP30 "); + Serial.print(sgp.TVOC); + Serial.print(" "); + //Serial.print("eCO2 "); + Serial.print(sgp.eCO2); + Serial.print(" "); + + if (! sgp.IAQmeasureRaw()) { + Serial.println("SGP 30 Raw Measurement failed"); +// return; + } + + //Serial.print("Raw H2 "); + Serial.print(sgp.rawH2); + Serial.print(" "); + //Serial.print("Raw Ethanol "); + Serial.print(sgp.rawEthanol); + Serial.println("-"); + } + delay(100); +} + +void eeprom_word_write(int addr, int val) +{ + EEPROM.write(addr * 2, lowByte(val)); + EEPROM.write(addr * 2 + 1, highByte(val)); +} + +short eeprom_word_read(int addr) +{ + return ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); +} + +void blink_setup() +{ +#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + // initialize digital pin PB1 as an output. + pinMode(PC13, OUTPUT); + pinMode(PB9, OUTPUT); + pinMode(PB8, OUTPUT); +#endif + +#if defined __AVR_ATmega32U4__ + pinMode(RXLED, OUTPUT); // Set RX LED as an output + // TX LED is set as an output behind the scenes + pinMode(greenLED, OUTPUT); + pinMode(blueLED,OUTPUT); +#endif +} + +void blink(int length) +{ +#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + digitalWrite(PC13, LOW); // turn the LED on (HIGH is the voltage level) +#endif + +#if defined __AVR_ATmega32U4__ + digitalWrite(RXLED, LOW); // set the RX LED ON + TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF +#endif + + delay(length); // wait for a lenth of time + +#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + digitalWrite(PC13, HIGH); // turn the LED off by making the voltage LOW +#endif + +#if defined __AVR_ATmega32U4__ + digitalWrite(RXLED, HIGH); // set the RX LED OFF + TXLED0; //TX LED macro to turn LED ON +#endif +} + +void led_set(int ledPin, bool state) +{ +#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + if (ledPin == greenLED) + digitalWrite(PB9, state); + else if (ledPin == blueLED) + digitalWrite(PB8, state); +#endif + +#if defined __AVR_ATmega32U4__ + digitalWrite(ledPin, state); +#endif +} + +int read_analog() +{ + int sensorValue; + #if defined __AVR_ATmega32U4__ + sensorValue = analogRead(A3); +#endif +#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + sensorValue = analogRead(PA7); +#endif + return(sensorValue); + + +} From 0a592fe80debe64ee1ccfa26d087ba9a28bc4714 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Mar 2022 09:35:53 -0500 Subject: [PATCH 10/27] added SGP30 sensor to Serial1 to the Pi --- stempayload/Payload_OK_SGP30.ino | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/stempayload/Payload_OK_SGP30.ino b/stempayload/Payload_OK_SGP30.ino index cc267f72..31c8da95 100644 --- a/stempayload/Payload_OK_SGP30.ino +++ b/stempayload/Payload_OK_SGP30.ino @@ -162,12 +162,12 @@ void loop() { // Serial.println(sensorValue); Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); - +/* Serial1.print(" XS "); Serial1.print(Temp); Serial1.print(" "); Serial1.println(Sensor2); - +*/ 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); @@ -188,6 +188,30 @@ void loop() { led_set(blueLED, HIGH); else led_set(blueLED, LOW); + + //SGP SENSOR DATA + if (! sgp.IAQmeasure()) { + Serial.println("SGP 30 Measurement failed"); +// return; + } + Serial1.print(" SGP30 "); + Serial1.print(sgp.TVOC); + Serial1.print(" "); + //Serial.print("eCO2 "); + Serial1.print(sgp.eCO2); + Serial1.print(" "); + + if (! sgp.IAQmeasureRaw()) { + Serial1.println("SGP 30 Raw Measurement failed"); +// return; + } + + //Serial.print("Raw H2 "); + Serial1.print(sgp.rawH2); + Serial1.print(" "); + //Serial.print("Raw Ethanol "); + Serial1.print(sgp.rawEthanol); + Serial1.println("-"); } } From 1f9941ecc953bd4f7044071bfc069a0c98dabe01 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Mar 2022 10:35:52 -0500 Subject: [PATCH 11/27] working over Serial1 --- stempayload/Payload_OK_SGP30.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stempayload/Payload_OK_SGP30.ino b/stempayload/Payload_OK_SGP30.ino index 31c8da95..8ce4c2be 100644 --- a/stempayload/Payload_OK_SGP30.ino +++ b/stempayload/Payload_OK_SGP30.ino @@ -211,7 +211,7 @@ void loop() { Serial1.print(" "); //Serial.print("Raw Ethanol "); Serial1.print(sgp.rawEthanol); - Serial1.println("-"); + Serial1.println(" "); } } @@ -324,7 +324,7 @@ void loop() { Serial.print(" "); //Serial.print("Raw Ethanol "); Serial.print(sgp.rawEthanol); - Serial.println("-"); + Serial.println(" "); } delay(100); } From a40d9b8c8aef419caf6c4189b7f71240b6fd1cda Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Mar 2022 12:14:15 -0500 Subject: [PATCH 12/27] added sgp30 sensor data --- groundstation/tago-upload.py | 48 +++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index f10b70d4..ffd29336 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -66,7 +66,13 @@ while (True): x_accel = chunks[i+4] y_accel = chunks[i+5] z_accel = chunks[i+6] - + if (chunks[i] == "SGP30"): + print("Found SGP30") + tvoc = chunks[i+1] + e_co2 = chunks[i+2] + raw_h2 = chunks[i+3] + raw_ethanol= chunks[i+4] + #print(telem_string) @@ -186,6 +192,46 @@ while (True): } result = my_device.insert(data) print(result) + + data = { + 'variable': 'tvoc', + 'unit' : 'ppb', + 'value' : tvoc, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'e_co2', + 'unit' : 'ppm', + 'value' : e_co2, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'raw_h2', + 'unit' : 'raw', + 'value' : raw_h2, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) + + data = { + 'variable': 'raw_ethanol', + 'unit' : 'raw', + 'value' : raw_ethanol, + 'time' : timestamp, + 'location': {'lat': lat, 'lng': lon} + } + result = my_device.insert(data) + print(result) data = { "variable": "location", From 5a65b5f2f470dee7acb236a77cdd3ffa8e6733f4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Mar 2022 22:31:09 -0500 Subject: [PATCH 13/27] moved } in serial to avoid double SGP print --- stempayload/Payload_OK_SGP30.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stempayload/Payload_OK_SGP30.ino b/stempayload/Payload_OK_SGP30.ino index 8ce4c2be..ba6047e0 100644 --- a/stempayload/Payload_OK_SGP30.ino +++ b/stempayload/Payload_OK_SGP30.ino @@ -107,7 +107,7 @@ void setup() { /**/ if (! sgp.begin()){ Serial.println("Sensor not found :("); - while (1); +// while (1); } Serial.print("Found SGP30 serial #"); Serial.print(sgp.serialnumber[0], HEX); @@ -300,7 +300,6 @@ void loop() { led_set(blueLED, HIGH); else led_set(blueLED, LOW); - } //SGP SENSOR DATA if (! sgp.IAQmeasure()) { @@ -325,7 +324,8 @@ void loop() { //Serial.print("Raw Ethanol "); Serial.print(sgp.rawEthanol); Serial.println(" "); - } + } + } delay(100); } From 3d010cc2497956ca8207501fd1eb074adec4f106 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Mar 2022 15:19:23 -0500 Subject: [PATCH 14/27] added all zeros for SGP30 sensor failure and baseline printout --- .../Payload_OK_SGP30.ino | 102 +++++++++--------- 1 file changed, 54 insertions(+), 48 deletions(-) rename stempayload/{ => Payload_OK_SGP30}/Payload_OK_SGP30.ino (85%) diff --git a/stempayload/Payload_OK_SGP30.ino b/stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino similarity index 85% rename from stempayload/Payload_OK_SGP30.ino rename to stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino index ba6047e0..ee9db94b 100644 --- a/stempayload/Payload_OK_SGP30.ino +++ b/stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino @@ -106,14 +106,13 @@ void setup() { } /**/ if (! sgp.begin()){ - Serial.println("Sensor not found :("); -// while (1); + Serial.println("SGP30 sensor not found :("); + } else { + Serial.print("Found SGP30 serial #"); + Serial.print(sgp.serialnumber[0], HEX); + Serial.print(sgp.serialnumber[1], HEX); + Serial.println(sgp.serialnumber[2], HEX); } - Serial.print("Found SGP30 serial #"); - Serial.print(sgp.serialnumber[0], HEX); - Serial.print(sgp.serialnumber[1], HEX); - Serial.println(sgp.serialnumber[2], HEX); - // If you have a baseline measurement from before you can assign it to start, to 'self-calibrate' //sgp.setIAQBaseline(0x8E68, 0x8F41); // Will vary for each sensor! @@ -190,30 +189,29 @@ void loop() { led_set(blueLED, LOW); //SGP SENSOR DATA - if (! sgp.IAQmeasure()) { - Serial.println("SGP 30 Measurement failed"); -// return; + if (! sgp.IAQmeasure()) { +// Serial.println("SGP 30 Measurement failed"); + Serial1.print(" SGP30 0 0 "); + } else { + Serial1.print(" SGP30 "); + Serial1.print(sgp.TVOC); + Serial1.print(" "); + //Serial.print("eCO2 "); + Serial1.print(sgp.eCO2); + Serial1.print(" "); } - Serial1.print(" SGP30 "); - Serial1.print(sgp.TVOC); - Serial1.print(" "); - //Serial.print("eCO2 "); - Serial1.print(sgp.eCO2); - Serial1.print(" "); - if (! sgp.IAQmeasureRaw()) { - Serial1.println("SGP 30 Raw Measurement failed"); -// return; - } - - //Serial.print("Raw H2 "); - Serial1.print(sgp.rawH2); - Serial1.print(" "); - //Serial.print("Raw Ethanol "); - Serial1.print(sgp.rawEthanol); - Serial1.println(" "); - } - +// Serial.println(" SGP 30 Raw Measurement failed"); + Serial1.println(" 0 0 "); + ) else { + //Serial.print("Raw H2 "); + Serial1.print(sgp.rawH2); + Serial1.print(" "); + //Serial.print("Raw Ethanol "); + Serial1.print(sgp.rawEthanol); + Serial1.println(" "); + } + } } if (Serial.available() > 0) { @@ -304,26 +302,34 @@ void loop() { //SGP SENSOR DATA if (! sgp.IAQmeasure()) { Serial.println("SGP 30 Measurement failed"); -// return; - } - Serial.print(" SGP30 "); - Serial.print(sgp.TVOC); - Serial.print(" "); - //Serial.print("eCO2 "); - Serial.print(sgp.eCO2); - Serial.print(" "); - + Serial1.print(" SGP30 0 0 "); + } else { + Serial.print(" SGP30 "); + Serial.print(sgp.TVOC); + Serial.print(" "); + //Serial.print("eCO2 "); + Serial.print(sgp.eCO2); + Serial.print(" "); + } if (! sgp.IAQmeasureRaw()) { - Serial.println("SGP 30 Raw Measurement failed"); -// return; - } - - //Serial.print("Raw H2 "); - Serial.print(sgp.rawH2); - Serial.print(" "); - //Serial.print("Raw Ethanol "); - Serial.print(sgp.rawEthanol); - Serial.println(" "); +// Serial.println("SGP 30 Raw Measurement failed"); + Serial1.println("0 0"); + } else { + //Serial.print("Raw H2 "); + Serial.print(sgp.rawH2); + Serial.print(" "); + //Serial.print("Raw Ethanol "); + Serial.print(sgp.rawEthanol); + Serial.println(" "); + + uint16_t TVOC_base, eCO2_base; + if (! sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) { + Serial.println("Failed to get baseline readings"); + } + Serial.print("****Baseline values: eCO2: 0x"); Serial.print(eCO2_base, HEX); + Serial.print(" & TVOC: 0x"); Serial.println(TVOC_base, HEX); + + } } } delay(100); From 14807e217ca43d503dfcc149804740d6fd688a39 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Mar 2022 22:58:36 -0500 Subject: [PATCH 15/27] added APRS.fi API --- groundstation/tago-upload.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index ffd29336..6d503f02 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -1,10 +1,15 @@ import tago +import requests while (True): print("Input telemetry string (or Control-C to exit)") - telem_string = input() + # telem_string = input() + + telem_string = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json') + + print(telem_string) chunks = telem_string.split(' ') @@ -243,3 +248,5 @@ while (True): } result = my_device.insert(data) print(result) + + sleep(90) From ba31148ea2b44d3785a22e31806980c300f920b8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Mar 2022 23:03:02 -0500 Subject: [PATCH 16/27] fixed indent --- groundstation/tago-upload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 6d503f02..afff9cbe 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -208,7 +208,7 @@ while (True): result = my_device.insert(data) print(result) - data = { + data = { 'variable': 'e_co2', 'unit' : 'ppm', 'value' : e_co2, @@ -218,7 +218,7 @@ while (True): result = my_device.insert(data) print(result) - data = { + data = { 'variable': 'raw_h2', 'unit' : 'raw', 'value' : raw_h2, From c93c53f6fea12c805e681dc46742385d65c6533f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Mar 2022 23:05:36 -0500 Subject: [PATCH 17/27] added .text --- groundstation/tago-upload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index afff9cbe..44300c0f 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -9,9 +9,9 @@ while (True): telem_string = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json') - print(telem_string) + print(telem_string.text) - chunks = telem_string.split(' ') + chunks = telem_string.text.split(' ') #printchunks = str.split(' ') From f93eb11c24411d713d738b9aec7022d56b80c34a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Mar 2022 23:10:16 -0500 Subject: [PATCH 18/27] parse json --- groundstation/tago-upload.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 44300c0f..dbcea6f0 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -1,5 +1,6 @@ import tago import requests +import json while (True): @@ -7,9 +8,13 @@ while (True): # telem_string = input() - telem_string = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json') + telem_json = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json') - print(telem_string.text) + telem_parsed = json.loads(telem_json) + + telem_string = telem_parsed["comment"] + + print(telem_string) chunks = telem_string.text.split(' ') From a1294961f3951512d74d1a46893ca849a9a624bd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 07:35:15 -0400 Subject: [PATCH 19/27] fixed indent --- groundstation/tago-upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index dbcea6f0..0496e0bd 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -233,7 +233,7 @@ while (True): result = my_device.insert(data) print(result) - data = { + data = { 'variable': 'raw_ethanol', 'unit' : 'raw', 'value' : raw_ethanol, From e1d1f961ab5b7a534b4c5c98a208da7468090634 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 08:22:20 -0400 Subject: [PATCH 20/27] json parsing --- groundstation/tago-upload.py | 43 +++++++----------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 0496e0bd..e5c73bcc 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -8,15 +8,17 @@ while (True): # telem_string = input() - telem_json = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json') - - telem_parsed = json.loads(telem_json) - - telem_string = telem_parsed["comment"] + telem_json = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json').json() + lat = telem_json['entries'][0]['lat'] + lon = telem_json['entries'][0]['lng'] + telem_string = telem_json['entries'][0]['comment'] + + print(lat_json) + print(lon_json) print(telem_string) - chunks = telem_string.text.split(' ') + chunks = telem_string.split(' ') #printchunks = str.split(' ') @@ -30,35 +32,6 @@ while (True): timestamp = chunks[0] + " " + chunks[1] print(timestamp) - lat1 = chunks[3].split("=") - lat2_dm = lat1[1].split("N") - lat_float = float(lat2_dm[0]) - - lon1 = lat2_dm[1].split("/") - lon2_dm = lon1[1].split("W") - lon_float = float(lon2_dm[0]) - - print(lat_float) - print(lon_float) - - lat_int = int(lat_float/100) - lat_mm = int(lat_float - lat_int * 100) - lat_mm2 = lat_float - int(lat_float) * 100 - - lat = lat_int + (lat_mm / 60.0) + (lat_mm2 / (60.0 * 60.0)) - - lon_int = int(lon_float/100) - lon_mm = int(lon_float - lon_int * 100) - lon_mm2 = lon_float - int(lon_float) * 100 - - lon = -1.0 * (lon_int + (lon_mm / 60.0) + (lon_mm2 / (60.0 * 60.0))) - - print(lat) - print(lon) - - lat = lat_float / 100.0 - lon = lon_float / (-100.0) - for i in range(len(chunks)): if (chunks[i] == "BME280"): print("Found BME280") From e6dbdd1f3b4704549bb82ad1bbab367798aa1545 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 08:27:56 -0400 Subject: [PATCH 21/27] typo --- groundstation/tago-upload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index e5c73bcc..72f43560 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -14,8 +14,8 @@ while (True): lon = telem_json['entries'][0]['lng'] telem_string = telem_json['entries'][0]['comment'] - print(lat_json) - print(lon_json) + print(lat) + print(lon) print(telem_string) chunks = telem_string.split(' ') From c1f0fa72600938083431ae89937e059e65ddf52e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 08:38:22 -0400 Subject: [PATCH 22/27] convert linux time to timestamp --- groundstation/tago-upload.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 72f43560..e6d17f75 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -29,7 +29,8 @@ while (True): altitude = 0 humidity = 0 - timestamp = chunks[0] + " " + chunks[1] + time = chunks[0] + " " + chunks[1] + timestamp = datetime.utcfromtimestamp(time).strftime('%Y-%m-%d %H:%M:%S') print(timestamp) for i in range(len(chunks)): From d51f014fbfd823313fcb87113830697abf116dd3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 08:46:20 -0400 Subject: [PATCH 23/27] time from json --- groundstation/tago-upload.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index e6d17f75..6b1706b1 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -1,6 +1,7 @@ import tago import requests import json +from datetime import datetime while (True): @@ -13,7 +14,8 @@ while (True): lat = telem_json['entries'][0]['lat'] lon = telem_json['entries'][0]['lng'] telem_string = telem_json['entries'][0]['comment'] - + time = int(telem_json['timestamp']) + print(lat) print(lon) print(telem_string) @@ -29,8 +31,8 @@ while (True): altitude = 0 humidity = 0 - time = chunks[0] + " " + chunks[1] - timestamp = datetime.utcfromtimestamp(time).strftime('%Y-%m-%d %H:%M:%S') + + timestamp = datetime.fromtimestamp(time).strftime('%Y-%m-%d %H:%M:%S') print(timestamp) for i in range(len(chunks)): From 6e65e5bd848c6802048ebc8cbc1f543bfd889509 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 09:14:02 -0400 Subject: [PATCH 24/27] fixed timestamp --- groundstation/tago-upload.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index 6b1706b1..f89f798b 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -2,6 +2,7 @@ import tago import requests import json from datetime import datetime +import time while (True): @@ -11,10 +12,10 @@ while (True): telem_json = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json').json() - lat = telem_json['entries'][0]['lat'] - lon = telem_json['entries'][0]['lng'] + lat = float(telem_json['entries'][0]['lat']) + lon = float(telem_json['entries'][0]['lng']) telem_string = telem_json['entries'][0]['comment'] - time = int(telem_json['timestamp']) + times = int(telem_json['timestamp']) print(lat) print(lon) @@ -32,7 +33,7 @@ while (True): humidity = 0 - timestamp = datetime.fromtimestamp(time).strftime('%Y-%m-%d %H:%M:%S') + timestamp = datetime.utcfromtimestamp(times).strftime('%Y-%m-%d %H:%M:%S') print(timestamp) for i in range(len(chunks)): @@ -230,4 +231,4 @@ while (True): result = my_device.insert(data) print(result) - sleep(90) + time.sleep(60) From dc3c6f637c2724ad78a60f925e154a7ef4c38947 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 09:22:25 -0400 Subject: [PATCH 25/27] typo in times --- groundstation/tago-upload.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/groundstation/tago-upload.py b/groundstation/tago-upload.py index f89f798b..7690b317 100644 --- a/groundstation/tago-upload.py +++ b/groundstation/tago-upload.py @@ -15,7 +15,8 @@ while (True): lat = float(telem_json['entries'][0]['lat']) lon = float(telem_json['entries'][0]['lng']) telem_string = telem_json['entries'][0]['comment'] - times = int(telem_json['timestamp']) + times = int(telem_json['entries'][0]['time']) + print(lat) print(lon) From f0882682ca83a62abd414fbf08ffdb2b4a148f00 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 11:33:38 -0400 Subject: [PATCH 26/27] updates for no sensor and printing baseline --- stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino b/stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino index ee9db94b..203afad6 100644 --- a/stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino +++ b/stempayload/Payload_OK_SGP30/Payload_OK_SGP30.ino @@ -24,6 +24,11 @@ int Sensor1 = 0; float Sensor2 = 0; void eeprom_word_write(int addr, int val); short eeprom_word_read(int addr); +void blink_setup(); +void blink(int length); +int read_analog(); +void led_set(int ledPin, bool state); + int first_time = true; int first_read = true; @@ -203,7 +208,7 @@ void loop() { if (! sgp.IAQmeasureRaw()) { // Serial.println(" SGP 30 Raw Measurement failed"); Serial1.println(" 0 0 "); - ) else { + } else { //Serial.print("Raw H2 "); Serial1.print(sgp.rawH2); Serial1.print(" "); @@ -301,8 +306,8 @@ void loop() { //SGP SENSOR DATA if (! sgp.IAQmeasure()) { - Serial.println("SGP 30 Measurement failed"); - Serial1.print(" SGP30 0 0 "); + // Serial.println("SGP 30 Measurement failed"); + Serial.print(" SGP30 0 0 "); } else { Serial.print(" SGP30 "); Serial.print(sgp.TVOC); @@ -313,7 +318,7 @@ void loop() { } if (! sgp.IAQmeasureRaw()) { // Serial.println("SGP 30 Raw Measurement failed"); - Serial1.println("0 0"); + Serial.println("0 0"); } else { //Serial.print("Raw H2 "); Serial.print(sgp.rawH2); @@ -410,6 +415,4 @@ int read_analog() sensorValue = analogRead(PA7); #endif return(sensorValue); - - } From 7a6081641d2a8bff63818c1d066b79e3fd4c2b6d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 13 Mar 2022 13:20:25 -0400 Subject: [PATCH 27/27] send altitude in place of 2nd hi --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 7db643be..a7302dd4 100644 --- a/main.c +++ b/main.c @@ -955,7 +955,8 @@ void get_tlm(void) { sprintf(header_str2b, "=%s%c%sShi hi ", header_lat, 0x5c, header_long); // add APRS lat and long else // sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long - sprintf(header_str2b, "=%s/%sOhi hi ", header_lat, header_long); // add APRS lat and long +// sprintf(header_str2b, "=%s/%sOhi hi ", header_lat, header_long); // add APRS lat and long + sprintf(header_str2b, "=%s/%sOhi %8.1f ", header_lat, header_long, alt_gps); // add APRS lat and long and altitude printf("\n\nAPRS string is %s \n\n", header_str2b); strcat(str, header_str2b); } else {