From 3eecbb8812376c3f9cb58219dcd5db6435b32e77 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 15:13:41 -0500 Subject: [PATCH 01/18] added PROMPT_I2CSCAN --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 9c5cae80..d5e6ee9c 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -128,6 +128,7 @@ #define PROMPT_TEMP 11 #define PROMPT_FORMAT 12 #define PROMPT_REBOOT 13 +#define PROMPT_I2CSCAN 14 #define PAYLOAD_QUERY 1 #define PAYLOAD_RESET 2 From 0a2fc0459f2bde17ab109aa9fca11323ea85b746 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 15:18:56 -0500 Subject: [PATCH 02/18] added prompt for I2C scan --- cubesatsim/cubesatsim.ino | 88 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1a2ff53b..92f3be0b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4149,11 +4149,15 @@ void serial_input() { break; case 's': - case 'S': Serial.println("Change to SSTV mode"); new_mode = SSTV; break; - + + case 'S': + Serial.println("I2C scan"); + prompt = PROMPT_I2CSCAN; + break; + case 'i': case 'I': Serial.println("Restart CubeSatsim software"); @@ -4244,6 +4248,7 @@ void prompt_for_input() { Serial.println("f FSK/DUV mode"); Serial.println("b BPSK mode"); Serial.println("s SSTV mode"); + Serial.println("S I2C scan"); Serial.println("i Restart"); Serial.println("c CALLSIGN"); Serial.println("t Simulated Telemetry"); @@ -4411,6 +4416,85 @@ void prompt_for_input() { else Serial.println("off"); break; + + case PROMPT_I2CSCAN: + Serial.print("I2C scan"); + +/ -------------------------------------- +// i2c_scanner +// +// Version 1 +// This program (or code that looks like it) +// can be found in many places. +// For example on the Arduino.cc forum. +// The original author is not know. +// Version 2, Juni 2012, Using Arduino 1.0.1 +// Adapted to be as simple as possible by Arduino.cc user Krodal +// Version 3, Feb 26 2013 +// V3 by louarnold +// Version 4, March 3, 2013, Using Arduino 1.0.3 +// by Arduino.cc user Krodal. +// Changes by louarnold removed. +// Scanning addresses changed from 0...127 to 1...119, +// according to the i2c scanner by Nick Gammon +// https://www.gammon.com.au/forum/?id=10896 +// Version 5, March 28, 2013 +// As version 4, but address scans now to 127. +// A sensor seems to use address 120. +// Version 6, November 27, 2015. +// Added waiting for the Leonardo serial communication. +// +// +// This sketch tests the standard 7-bit addresses +// Devices with higher bit address might not be seen properly. +// + + +{ + byte error, address; + int nDevices; + + Serial.println("Scanning..."); + + nDevices = 0; + for(address = 1; address < 127; address++ ) + { + // The i2c_scanner uses the return value of + // the Write.endTransmisstion to see if + // a device did acknowledge to the address. + Wire.beginTransmission(address); + error = Wire.endTransmission(); + + if (error == 0) + { + Serial.print("I2C device found at address 0x"); + if (address<16) + Serial.print("0"); + Serial.print(address,HEX); + Serial.println(" !"); + + nDevices++; + } + else if (error==4) + { + Serial.print("Unknown error at address 0x"); + if (address<16) + Serial.print("0"); + Serial.println(address,HEX); + } + } + if (nDevices == 0) + Serial.println("No I2C devices found\n"); + else + Serial.println("done\n"); + + delay(5000); // wait 5 seconds for next scan +} + + + Serial.println("complete"); + break; + } prompt = false; } From 19d9f8018d37433a1269c9d2719caa11dd3056b1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 15:20:30 -0500 Subject: [PATCH 03/18] typo --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 92f3be0b..6f47d123 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4420,7 +4420,7 @@ void prompt_for_input() { case PROMPT_I2CSCAN: Serial.print("I2C scan"); -/ -------------------------------------- +// -------------------------------------- // i2c_scanner // // Version 1 From 49bb44c5f1e7a9dcb3a30e58632ea525c400f36c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 15:27:04 -0500 Subject: [PATCH 04/18] add bus 2 scanning --- cubesatsim/cubesatsim.ino | 48 +++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6f47d123..72e0e187 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4454,7 +4454,7 @@ void prompt_for_input() { byte error, address; int nDevices; - Serial.println("Scanning..."); + Serial.println("Scanning I2C Bus 1"); nDevices = 0; for(address = 1; address < 127; address++ ) @@ -4467,7 +4467,7 @@ void prompt_for_input() { if (error == 0) { - Serial.print("I2C device found at address 0x"); + Serial.print("I2C device found at bus 1 address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); @@ -4477,21 +4477,55 @@ void prompt_for_input() { } else if (error==4) { - Serial.print("Unknown error at address 0x"); + Serial.print("Unknown error at bus 1 address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); } } if (nDevices == 0) - Serial.println("No I2C devices found\n"); + Serial.println("No I2C devices found on bus 1\n"); else Serial.println("done\n"); delay(5000); // wait 5 seconds for next scan -} - - + + Serial.println("Scanning I2C Bus 2"); + + nDevices = 0; + for(address = 1; address < 127; address++ ) + { + // The i2c_scanner uses the return value of + // the Write.endTransmisstion to see if + // a device did acknowledge to the address. + + Wire1.beginTransmission(address); + error = Wire1.endTransmission(); + + if (error == 0) + { + Serial.print("I2C device found at bus 2 address 0x"); + if (address<16) + Serial.print("0"); + Serial.print(address,HEX); + Serial.println(" !"); + + nDevices++; + } + else if (error==4) + { + Serial.print("Unknown error at bus 2 address 0x"); + if (address<16) + Serial.print("0"); + Serial.println(address,HEX); + } + } + if (nDevices == 0) + Serial.println("No I2C devices found on bus 2\n"); + else + Serial.println("done\n"); + +} Serial.println("complete"); break; From 5c0f2f5c12465b4be27e9da536bec9bb20bddbae Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 15:51:02 -0500 Subject: [PATCH 05/18] short APRS packet --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 72e0e187..8f53edb1 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -463,8 +463,8 @@ void send_aprs_packet() { char str[1000]; char header_str[] = "hi hi "; strcpy(str, header_str); - strcpy(str, tlm_str); - strcat(str, payload_str); +// strcpy(str, tlm_str); // transmit short APRS packet with just lat lon +// strcat(str, payload_str); // print_string(str); // Serial.println(strlen(str)); From bc4782e3cbac3ce47ccb10e15481129481f332d5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:02:03 -0500 Subject: [PATCH 06/18] print uptime each time --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8f53edb1..745450fb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1020,6 +1020,7 @@ void get_tlm_fox() { memset(parities, 0, sizeof(parities)); // Serial.println("After memset"); uptime = (int)(millis() / 1000.0); + Serial.printf("Uptime: %d \n", uptime); h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits // Serial.println("After h[0]"); From cc3abaea1c9e5830072a8141a462e5bd4a27602a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:10:42 -0500 Subject: [PATCH 07/18] run start_ina219() after ina219 problem --- cubesatsim/cubesatsim.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 745450fb..adea6705 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2427,8 +2427,11 @@ void read_ina219() } voltage_read = false; - if ((millis() - read_time) > 1000) + if ((millis() - read_time) > 1000) { Serial.println("There is an I2C sensor problem"); + start_ina219(); + + } } void read_sensors() From 52c26bd9eb9e3805702806ae40f1342d056341ab Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:14:03 -0500 Subject: [PATCH 08/18] set ina219_started false --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index adea6705..4a947061 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2429,6 +2429,7 @@ void read_ina219() if ((millis() - read_time) > 1000) { Serial.println("There is an I2C sensor problem"); + ina219_started = false; start_ina219(); } From 6beaf3cf5b5389a69cc386a84f2f55e6dc35cd12 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:19:40 -0500 Subject: [PATCH 09/18] if I2C sensor problem, check all sensors --- cubesatsim/cubesatsim.ino | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4a947061..d89ee876 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2429,8 +2429,21 @@ void read_ina219() if ((millis() - read_time) > 1000) { Serial.println("There is an I2C sensor problem"); - ina219_started = false; - start_ina219(); + + if (!(i2c_1 = ina219_1_0x40.begin())) // check i2c bus 1 + Serial.println("I2C +X sensor (bus 1 0x40) not found"); + if (!(i2c2 = ina219_1_0x41.begin())) + Serial.println("I2C +Y sensor (bus 1 0x41) not found"); + if (!(i2c3 = ina219_1_0x44.begin())) + Serial.println("I2C Batt sensor (bus 1 0x44) not found"); + if (!(i2c5 = ina219_2_0x40.begin(&Wire1))) // check i2c bus 2 + Serial.println("I2C +Z sensor (bus 2 0x40) not found"); + if (!(i2c6 = ina219_2_0x41.begin(&Wire1))) + Serial.println("I2C -X sensor (bus 2 0x41) not found"); + if (!(i2c7 = ina219_2_0x44.begin(&Wire1))) + Serial.println("I2C -Y sensor (bus 2 0x44) not found"); + if (!(i2c8 = ina219_2_0x45.begin(&Wire1))) + Serial.println("I2C -Z sensor (bus 2 0x45) not found"); } } From c96cf8fbea278790e5d08fdcf5bc6d3ddade2740 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:31:42 -0500 Subject: [PATCH 10/18] turn off sensor if longer than 1 second read --- cubesatsim/cubesatsim.ino | 52 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index d89ee876..9e75fbc8 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2283,6 +2283,13 @@ void read_ina219() } voltage[PLUS_X] = loadvoltage; current[PLUS_X] = current_mA; + + if ((millis() - read_time) > 1000) { + i2c_1 = false; + Serial.println("There is a problem with bus 1 0x40"); + } + millis() - read_time; + } else { voltage[PLUS_X] = 0.0; current[PLUS_X] = 0.0; @@ -2303,6 +2310,13 @@ void read_ina219() } voltage[PLUS_Y] = loadvoltage; current[PLUS_Y] = current_mA; + + if ((millis() - read_time) > 1000) { + i2c2 = false; + Serial.println("There is a problem with bus 1 0x41"); + } + millis() - read_time; + } else { voltage[PLUS_Y] = 0.0; current[PLUS_Y] = 0.0; @@ -2340,7 +2354,12 @@ void read_ina219() voltage[BUS] = loadvoltage; // since battery directly supplies, make BUS same as BAT for FoxTelem current[BUS] = current_mA; - + if ((millis() - read_time) > 1000) { + i2c3 = false; + Serial.println("There is a problem with bus 1 0x44"); + } + millis() - read_time; + } else { voltage[BAT] = 0.0; current[BAT] = 0.0; @@ -2361,6 +2380,12 @@ void read_ina219() } voltage[PLUS_Z] = loadvoltage; current[PLUS_Z] = current_mA; + + if ((millis() - read_time) > 1000) { + i2c5 = false; + Serial.println("There is a problem with bus 2 0x40"); + } + millis() - read_time; } else { voltage[PLUS_Z] = 0.0; current[PLUS_Z] = 0.0; @@ -2381,6 +2406,13 @@ void read_ina219() } voltage[MINUS_X] = loadvoltage; current[MINUS_X] = current_mA; + + if ((millis() - read_time) > 1000) { + i2c6 = false; + Serial.println("There is a problem with bus 2 0x41"); + } + millis() - read_time; + } else { voltage[MINUS_X] = 0.0; current[MINUS_X] = 0.0; @@ -2401,6 +2433,13 @@ void read_ina219() } voltage[MINUS_Y] = loadvoltage; current[MINUS_Y] = current_mA; + + if ((millis() - read_time) > 1000) { + i2c7 = false; + Serial.println("There is a problem with bus 2 0x44"); + } + millis() - read_time; + } else { voltage[MINUS_Y] = 0.0; current[MINUS_Y] = 0.0; @@ -2421,12 +2460,19 @@ void read_ina219() } voltage[MINUS_Z] = loadvoltage; current[MINUS_Z] = current_mA; + + if ((millis() - read_time) > 1000) { + i2c8 = false; + Serial.println("There is a problem with bus 2 0x45"); + } + millis() - read_time; + } else { voltage[MINUS_Z] = 0.0; current[MINUS_Z] = 0.0; } voltage_read = false; - +/* if ((millis() - read_time) > 1000) { Serial.println("There is an I2C sensor problem"); @@ -2444,7 +2490,7 @@ void read_ina219() Serial.println("I2C -Y sensor (bus 2 0x44) not found"); if (!(i2c8 = ina219_2_0x45.begin(&Wire1))) Serial.println("I2C -Z sensor (bus 2 0x45) not found"); - +*/ } } From a75846420c62680f544b00608fe594afb3f66076 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:46:55 -0500 Subject: [PATCH 11/18] typo --- cubesatsim/cubesatsim.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9e75fbc8..1a7ffae7 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2288,7 +2288,7 @@ void read_ina219() i2c_1 = false; Serial.println("There is a problem with bus 1 0x40"); } - millis() - read_time; + read_time = millis(); } else { voltage[PLUS_X] = 0.0; @@ -2315,7 +2315,7 @@ void read_ina219() i2c2 = false; Serial.println("There is a problem with bus 1 0x41"); } - millis() - read_time; + read_time = millis(); } else { voltage[PLUS_Y] = 0.0; @@ -2358,7 +2358,7 @@ void read_ina219() i2c3 = false; Serial.println("There is a problem with bus 1 0x44"); } - millis() - read_time; + read_time = millis(); } else { voltage[BAT] = 0.0; @@ -2385,7 +2385,7 @@ void read_ina219() i2c5 = false; Serial.println("There is a problem with bus 2 0x40"); } - millis() - read_time; + read_time = millis(); } else { voltage[PLUS_Z] = 0.0; current[PLUS_Z] = 0.0; @@ -2411,7 +2411,7 @@ void read_ina219() i2c6 = false; Serial.println("There is a problem with bus 2 0x41"); } - millis() - read_time; + read_time = millis(); } else { voltage[MINUS_X] = 0.0; @@ -2438,7 +2438,7 @@ void read_ina219() i2c7 = false; Serial.println("There is a problem with bus 2 0x44"); } - millis() - read_time; + read_time = millis(); } else { voltage[MINUS_Y] = 0.0; @@ -2465,7 +2465,7 @@ void read_ina219() i2c8 = false; Serial.println("There is a problem with bus 2 0x45"); } - millis() - read_time; + read_time = millis(); } else { voltage[MINUS_Z] = 0.0; From 0870a0e6e1a8b72f64faff4dcd08c0a1ee26cc20 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:49:00 -0500 Subject: [PATCH 12/18] typo --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1a7ffae7..f098b60d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2489,9 +2489,9 @@ void read_ina219() if (!(i2c7 = ina219_2_0x44.begin(&Wire1))) Serial.println("I2C -Y sensor (bus 2 0x44) not found"); if (!(i2c8 = ina219_2_0x45.begin(&Wire1))) - Serial.println("I2C -Z sensor (bus 2 0x45) not found"); -*/ + Serial.println("I2C -Z sensor (bus 2 0x45) not found"); } + */ } void read_sensors() From 4ea4ea9c943a79011ff7abcc36f05a560db0792b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 16:54:01 -0500 Subject: [PATCH 13/18] changed from 1000 to 100 for ms per sensor read --- cubesatsim/cubesatsim.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f098b60d..1e052b0e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2284,7 +2284,7 @@ void read_ina219() voltage[PLUS_X] = loadvoltage; current[PLUS_X] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c_1 = false; Serial.println("There is a problem with bus 1 0x40"); } @@ -2311,7 +2311,7 @@ void read_ina219() voltage[PLUS_Y] = loadvoltage; current[PLUS_Y] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c2 = false; Serial.println("There is a problem with bus 1 0x41"); } @@ -2354,7 +2354,7 @@ void read_ina219() voltage[BUS] = loadvoltage; // since battery directly supplies, make BUS same as BAT for FoxTelem current[BUS] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c3 = false; Serial.println("There is a problem with bus 1 0x44"); } @@ -2381,7 +2381,7 @@ void read_ina219() voltage[PLUS_Z] = loadvoltage; current[PLUS_Z] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c5 = false; Serial.println("There is a problem with bus 2 0x40"); } @@ -2407,7 +2407,7 @@ void read_ina219() voltage[MINUS_X] = loadvoltage; current[MINUS_X] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c6 = false; Serial.println("There is a problem with bus 2 0x41"); } @@ -2434,7 +2434,7 @@ void read_ina219() voltage[MINUS_Y] = loadvoltage; current[MINUS_Y] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c7 = false; Serial.println("There is a problem with bus 2 0x44"); } @@ -2461,7 +2461,7 @@ void read_ina219() voltage[MINUS_Z] = loadvoltage; current[MINUS_Z] = current_mA; - if ((millis() - read_time) > 1000) { + if ((millis() - read_time) > 100) { i2c8 = false; Serial.println("There is a problem with bus 2 0x45"); } From a8ac7c9aacaa610cf98385253ce8e56b18f507b1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 17:00:54 -0500 Subject: [PATCH 14/18] added reat_time_total --- cubesatsim/cubesatsim.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1e052b0e..c1693e42 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2255,7 +2255,7 @@ void test_radio() void read_ina219() { unsigned long read_time = millis(); - + unsigned long read_time_total = millis(); if (voltage_read && !i2c_bus1 && !i2c_bus3) Serial.println("Nothing to read"); /* @@ -2472,10 +2472,10 @@ void read_ina219() current[MINUS_Z] = 0.0; } voltage_read = false; -/* - if ((millis() - read_time) > 1000) { + + if ((millis() - read_time_total) > 1000) { Serial.println("There is an I2C sensor problem"); - +/* if (!(i2c_1 = ina219_1_0x40.begin())) // check i2c bus 1 Serial.println("I2C +X sensor (bus 1 0x40) not found"); if (!(i2c2 = ina219_1_0x41.begin())) From 3edec723752e01a4151f42ad635d48ce343ec4a0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 17:02:01 -0500 Subject: [PATCH 15/18] typo --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c1693e42..dc381b2a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2475,6 +2475,7 @@ void read_ina219() if ((millis() - read_time_total) > 1000) { Serial.println("There is an I2C sensor problem"); + } /* if (!(i2c_1 = ina219_1_0x40.begin())) // check i2c bus 1 Serial.println("I2C +X sensor (bus 1 0x40) not found"); From 3507a7297dc667931f9ecbfefafe41be39937b58 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 17:10:07 -0500 Subject: [PATCH 16/18] added read_time for bme and mpg --- cubesatsim/cubesatsim.ino | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index dc381b2a..c940a370 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2645,6 +2645,7 @@ void start_payload() { void read_payload() { + unsigned long read_time = millis(); payload_str[0] = '\0'; // clear the payload string // print_string(payload_str); @@ -2664,8 +2665,13 @@ void read_payload() else sprintf(str, "0.0 0.0 0.0 0.0 "); strcat(payload_str, str); -// print_string(payload_str); - +// print_string(payload_str); + if ((millis() - read_time) > 500) { + Serial.println("There is a bme280 sensor problem"); + bnePresent = false; + } + read_time = millis(); + if (mpuPresent) { // print_string(payload_str); mpu6050.update(); @@ -2688,8 +2694,12 @@ void read_payload() if (rotation > 5) led_set(STEM_LED_BLUE, HIGH); else - led_set(STEM_LED_BLUE, LOW); + led_set(STEM_LED_BLUE, LOW); + if ((millis() - read_time) > 500) { + Serial.println("There is an mpu6050 sensor problem"); + mpuPresent = false; + } } else sprintf(str, "MPU6050 0.0 0.0 0.0 0.0 0.0 0.0 "); strcat(payload_str, str); From a23c4a8980d8f4b37b0229be9ad528db72e891e0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 17:12:40 -0500 Subject: [PATCH 17/18] typo --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c940a370..fcfda0a9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2668,7 +2668,7 @@ void read_payload() // print_string(payload_str); if ((millis() - read_time) > 500) { Serial.println("There is a bme280 sensor problem"); - bnePresent = false; + bmePresent = false; } read_time = millis(); From 175539aaf2934c8e65c174947a8ce10657b4edc3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 12 Dec 2022 17:59:52 -0500 Subject: [PATCH 18/18] don't print uptime --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fcfda0a9..c2637098 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1020,7 +1020,7 @@ void get_tlm_fox() { memset(parities, 0, sizeof(parities)); // Serial.println("After memset"); uptime = (int)(millis() / 1000.0); - Serial.printf("Uptime: %d \n", uptime); +// Serial.printf("Uptime: %d \n", uptime); h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits // Serial.println("After h[0]");