From a8f3abd445f7fda070298e5781b2580b6fa1a496 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 09:40:34 -0500 Subject: [PATCH 01/18] Update Payload_BME280_MPU6050_XS.ino add back in Arduino-Pico support --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 86e6030bc..a2e4ca465 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -10,7 +10,9 @@ #include TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#else +#else ifdef ARDUINO_ARCH_RP2040 +#include +TinyGPSPlus gps; #include #endif @@ -31,7 +33,7 @@ short ee_prom_word_read(int addr); int first_time = true; int first_read = true; -#if defined ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) float T2 = 26.3; // Temperature data point 1 float R2 = 167; // Reading data point 1 float T1 = 2; // Temperature data point 2 From 8fdd931a97f09c87214eb814c751bda73f9a4218 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 09:45:50 -0500 Subject: [PATCH 02/18] Update Payload_BME280_MPU6050_XS.ino add or Arduino Pico --- .../Payload_BME280_MPU6050_XS.ino | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index a2e4ca465..bad51a4ab 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -75,7 +75,7 @@ void setup() { Serial.println("Starting!"); -#ifdef ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) Serial.println("This code is for the Raspberry Pi Pico hardware."); Serial.println("Starting Serial2 for optional GPS on JP12"); @@ -133,7 +133,8 @@ void setup() { { Serial.println("Calculating gyro offsets\n"); mpu6050.calcGyroOffsets(true); -#ifndef ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) +#else Serial.println("Storing gyro offsets in EEPROM\n"); eeprom_word_write(0, 0xA07); @@ -291,7 +292,8 @@ void loop() { // Serial.println(result); // Serial.println("OK"); // Serial.println(counter++); -#ifndef ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) +#else if (result == 'R') { Serial1.println("OK"); delay(100); @@ -307,7 +309,7 @@ void loop() { #endif } -#ifdef ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) Serial.print("Squelch: "); Serial.println(digitalRead(15)); @@ -400,7 +402,7 @@ void led_set(int ledPin, bool state) digitalWrite(ledPin, state); #endif -#ifdef ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) if (ledPin == greenLED) digitalWrite(19, state); else if (ledPin == blueLED) @@ -418,14 +420,14 @@ int read_analog() #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 -#if defined ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) sensorValue = analogRead(28); #endif return(sensorValue); } void get_gps() { -#ifdef ARDUINO_ARCH_MBED_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) Serial.println("Getting GPS data"); bool newData = false; unsigned long start = millis(); From 78d5768633a20c93fe2e58088975167bf16e3e4e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 09:59:33 -0500 Subject: [PATCH 03/18] Update Payload_BME280_MPU6050_XS.ino rest of changes --- .../Payload_BME280_MPU6050_XS.ino | 82 ++++++++++++++++--- 1 file changed, 72 insertions(+), 10 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index bad51a4ab..5b6932654 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -6,13 +6,20 @@ #include #include #include -#ifdef ARDUINO_ARCH_MBED_RP2040 + +#ifdef ARDUINO_ARCH_MBED_RP2040 // if Arduino Mbed OS RP2040 Boards is used in Arduino IDE #include TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#else ifdef ARDUINO_ARCH_RP2040 + +#else ifdef ARDUINO_ARCH_RP2040 // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; +bool check_for_wifi(); +bool wifi = false; +int led_builtin_pin; + +#else // if Sparkfun Pro Micro or STM32 #include #endif @@ -68,7 +75,13 @@ extern void payload_loop(); // sensor extension read function defined in payloa void setup() { Serial.begin(115200); // Serial Monitor for testing - + +#ifdef ARDUINO_ARCH_RP2040 + Serial1.setRX(1); + delay(100); + Serial1.setTX(0); + delay(100); +#endif Serial1.begin(115200); // for communication with Pi Zero delay(1000); @@ -352,10 +365,26 @@ void blink_setup() #endif #if defined ARDUINO_ARCH_MBED_RP2040 - pinMode(LED_BUILTIN, OUTPUT); - pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2 - pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2 + pinMode(LED_BUILTIN, OUTPUT); + pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2 + pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2 #endif + +#if defined ARDUINO_ARCH_RP2040 + if (check_for_wifi()) { + wifi = true; + led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W + pinMode(LED_BUILTIN, OUTPUT); +// configure_wifi(); + } else { + led_builtin_pin = 25; // manually set GPIO 25 for Pico board +// pinMode(25, OUTPUT); + pinMode(led_builtin_pin, OUTPUT); + + pinMode(18, OUTPUT); + pinMode(19, OUTPUT); + } +#endif } void blink(int length) @@ -370,9 +399,16 @@ void blink(int length) #endif #if defined ARDUINO_ARCH_MBED_RP2040 - digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON + digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON #endif +#if defined ARDUINO_ARCH_RP2040 + if (wifi) + digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON + else + digitalWrite(led_builtin_pin, HIGH); // set the built-in LED ON +#endif + delay(length); #if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) @@ -386,7 +422,14 @@ delay(length); #if defined ARDUINO_ARCH_MBED_RP2040 digitalWrite(LED_BUILTIN, LOW); // set the built-in LED OFF -#endif +#endif + +#if defined ARDUINO_ARCH_RP2040 + if (wifi) + digitalWrite(LED_BUILTIN, LOW); // set the built-in LED ON + else + digitalWrite(led_builtin_pin, LOW); // set the built-in LED ON +#endif } void led_set(int ledPin, bool state) @@ -426,8 +469,27 @@ int read_analog() return(sensorValue); } -void get_gps() { +#if defined (ARDUINO_ARCH_MBED_RP2040) +bool check_for_wifi() { + + pinMode(29, INPUT); + const float conversion_factor = 3.3f / (1 << 12); + uint16_t result = analogRead(29); +// Serial.printf("ADC3 value: 0x%03x, voltage: %f V\n", result, result * conversion_factor); + + if (result < 0x10) { + Serial.println("\nPico W detected!\n"); + return(true); + } + else { + Serial.println("\nPico detected!\n"); + return(false); + } +} +#endif + #if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) +void get_gps() { Serial.println("Getting GPS data"); bool newData = false; unsigned long start = millis(); @@ -473,5 +535,5 @@ void get_gps() { } else // Serial.printf("GPS read no new data: %d\n", millis() - start); ; -#endif } +#endif From a1328cf994a1fbe2e0ab3e8ae77e43f5341a34c1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:01:55 -0500 Subject: [PATCH 04/18] Update Payload_BME280_MPU6050_XS.ino fix else --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 5b6932654..e7038274e 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -12,7 +12,7 @@ TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#else ifdef ARDUINO_ARCH_RP2040 // if Raspberry Pi RP2040 Boards in Arduino IDE +#ifdef ARDUINO_ARCH_RP2040 // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; bool check_for_wifi(); From 3b08bac7081d894760435e2d261693939e3bae2e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:04:14 -0500 Subject: [PATCH 05/18] Update Payload_BME280_MPU6050_XS.ino elseif --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index e7038274e..1cac5baca 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -12,7 +12,7 @@ TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#ifdef ARDUINO_ARCH_RP2040 // if Raspberry Pi RP2040 Boards in Arduino IDE +#elseif ARDUINO_ARCH_RP2040 // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; bool check_for_wifi(); From 823cb717ef1c3c099869dda0311c295417e62d59 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:06:20 -0500 Subject: [PATCH 06/18] Update Payload_BME280_MPU6050_XS.ino added defined --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 1cac5baca..1607c9971 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -7,12 +7,12 @@ #include #include -#ifdef ARDUINO_ARCH_MBED_RP2040 // if Arduino Mbed OS RP2040 Boards is used in Arduino IDE +#if defined(ARDUINO_ARCH_MBED_RP2040) // if Arduino Mbed OS RP2040 Boards is used in Arduino IDE #include TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#elseif ARDUINO_ARCH_RP2040 // if Raspberry Pi RP2040 Boards in Arduino IDE +#elseif define(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; bool check_for_wifi(); From e0c097a65206e771d33b28e4445be59b946b48ee Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:06:59 -0500 Subject: [PATCH 07/18] Update Payload_BME280_MPU6050_XS.ino defined --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 1607c9971..6b60046ef 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -12,7 +12,7 @@ TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#elseif define(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE +#elseif defined(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; bool check_for_wifi(); From 826e52e435d53337ff9da391ac2aa00f05bb5718 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:08:46 -0500 Subject: [PATCH 08/18] Update Payload_BME280_MPU6050_XS.ino elif --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 6b60046ef..eee6f75b3 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -12,7 +12,7 @@ TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#elseif defined(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE +#elif defined(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; bool check_for_wifi(); From c6c4e88704617c2b74d5abadc1b703cd87f5d0bf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:13:18 -0500 Subject: [PATCH 09/18] Update Payload_BME280_MPU6050_XS.ino test board print --- .../Payload_BME280_MPU6050_XS.ino | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index eee6f75b3..bb897f0e7 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -75,13 +75,22 @@ extern void payload_loop(); // sensor extension read function defined in payloa void setup() { Serial.begin(115200); // Serial Monitor for testing - + +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) + Serial.println("Pico with Mbed"); +#elif defined (!ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) + Serial.println("Pico with RP2040"); +#else + Serial.println("Pro Micro"); +#endif +/* #ifdef ARDUINO_ARCH_RP2040 Serial1.setRX(1); delay(100); Serial1.setTX(0); delay(100); #endif +*/ Serial1.begin(115200); // for communication with Pi Zero delay(1000); From db113151ace3b6b467c83277ab84af57ff26eb59 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:37:49 -0500 Subject: [PATCH 10/18] Update Payload_BME280_MPU6050_XS.ino fixed board conditionals --- .../Payload_BME280_MPU6050_XS.ino | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index bb897f0e7..fe865953d 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -7,12 +7,12 @@ #include #include -#if defined(ARDUINO_ARCH_MBED_RP2040) // if Arduino Mbed OS RP2040 Boards is used in Arduino IDE +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) // if Arduino Mbed OS RP2040 Boards is used in Arduino IDE #include TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#elif defined(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE +#elif !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE #include TinyGPSPlus gps; bool check_for_wifi(); @@ -76,30 +76,32 @@ void setup() { Serial.begin(115200); // Serial Monitor for testing -#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) - Serial.println("Pico with Mbed"); -#elif defined (!ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) - Serial.println("Pico with RP2040"); -#else - Serial.println("Pro Micro"); -#endif -/* -#ifdef ARDUINO_ARCH_RP2040 +#if defined (!ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) Serial1.setRX(1); delay(100); Serial1.setTX(0); delay(100); #endif -*/ + Serial1.begin(115200); // for communication with Pi Zero - delay(1000); - + delay(2000); + +#if defined (ARDUINO_ARCH_MBED_RP2040) && (ARDUINO_ARCH_RP2040) + Serial.println("Pico with Mbed"); +#elif !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + Serial.println("Pico with RP2040"); +#elif defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + Serial.println("STM32"); +#elif defined __AVR_ATmega32U4__ + Serial.println("Pro Micro"); +#else + Serial.println("Unknown board"); +#endif + Serial.println("Starting!"); #if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) - Serial.println("This code is for the Raspberry Pi Pico hardware."); - Serial.println("Starting Serial2 for optional GPS on JP12"); // Serial2.begin(9600); // serial from - some modules need 115200 Serial2.begin(9600); // serial from GPS or other serial sensor. Some GPS need 115200 @@ -111,8 +113,7 @@ void setup() { pinMode(26, INPUT); pinMode(27, INPUT); pinMode(28, INPUT); - pinMode(15, INPUT_PULLUP); // squelch - + pinMode(15, INPUT_PULLUP); // squelch #endif blink_setup(); @@ -373,13 +374,13 @@ void blink_setup() pinMode(blueLED,OUTPUT); #endif -#if defined ARDUINO_ARCH_MBED_RP2040 +if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) pinMode(LED_BUILTIN, OUTPUT); pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2 pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2 #endif -#if defined ARDUINO_ARCH_RP2040 +if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) if (check_for_wifi()) { wifi = true; led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W @@ -407,11 +408,11 @@ void blink(int length) TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF #endif -#if defined ARDUINO_ARCH_MBED_RP2040 +if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON #endif -#if defined ARDUINO_ARCH_RP2040 +if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) if (wifi) digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON else @@ -429,11 +430,11 @@ delay(length); TXLED0; //TX LED macro to turn LED ON #endif -#if defined ARDUINO_ARCH_MBED_RP2040 +if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) digitalWrite(LED_BUILTIN, LOW); // set the built-in LED OFF #endif -#if defined ARDUINO_ARCH_RP2040 +if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) if (wifi) digitalWrite(LED_BUILTIN, LOW); // set the built-in LED ON else @@ -478,7 +479,7 @@ int read_analog() return(sensorValue); } -#if defined (ARDUINO_ARCH_MBED_RP2040) +if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) bool check_for_wifi() { pinMode(29, INPUT); From 9d347681d6cdc080caa9c152a9dd4b2ee0c8d668 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:41:14 -0500 Subject: [PATCH 11/18] Update Payload_BME280_MPU6050_XS.ino fix define typo --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index fe865953d..995820dd7 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -76,7 +76,7 @@ void setup() { Serial.begin(115200); // Serial Monitor for testing -#if defined (!ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) Serial1.setRX(1); delay(100); Serial1.setTX(0); From 250da61c5bca941b37e9d2d01fffed117ac76377 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:42:43 -0500 Subject: [PATCH 12/18] Update Payload_BME280_MPU6050_XS.ino missing # --- .../Payload_BME280_MPU6050_XS.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 995820dd7..0728ea1ea 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -374,13 +374,13 @@ void blink_setup() pinMode(blueLED,OUTPUT); #endif -if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) pinMode(LED_BUILTIN, OUTPUT); pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2 pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2 #endif -if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) if (check_for_wifi()) { wifi = true; led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W @@ -408,11 +408,11 @@ void blink(int length) TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF #endif -if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON #endif -if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) if (wifi) digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON else @@ -430,11 +430,11 @@ delay(length); TXLED0; //TX LED macro to turn LED ON #endif -if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) digitalWrite(LED_BUILTIN, LOW); // set the built-in LED OFF #endif -if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) if (wifi) digitalWrite(LED_BUILTIN, LOW); // set the built-in LED ON else @@ -479,7 +479,7 @@ int read_analog() return(sensorValue); } -if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) bool check_for_wifi() { pinMode(29, INPUT); From e11d993bd5230d58dd4dcdce9cfb7249518d189f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:47:42 -0500 Subject: [PATCH 13/18] Update Payload_BME280_MPU6050_XS.ino eeprom if fixed --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 0728ea1ea..1d613dd9f 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -345,7 +345,7 @@ void loop() { void eeprom_word_write(int addr, int val) { -#ifndef ARDUINO_ARCH_MBED_RP2040 +#if !defined(ARDUINO_ARCH_MBED_RP2040) && !defined(ARDUINO_ARCH_RP2040) EEPROM.write(addr * 2, lowByte(val)); EEPROM.write(addr * 2 + 1, highByte(val)); #endif @@ -353,7 +353,7 @@ void eeprom_word_write(int addr, int val) short eeprom_word_read(int addr) { -#ifndef ARDUINO_ARCH_MBED_RP2040 +#if !defined(ARDUINO_ARCH_MBED_RP2040) && !defined(ARDUINO_ARCH_RP2040) return ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); #endif } From c98016b26a1d2e85dc462f886b111565bbbdac6a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:50:43 -0500 Subject: [PATCH 14/18] Update Payload_BME280_MPU6050_XS.ino eeprom read returns value --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 1d613dd9f..274648cc4 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -353,9 +353,11 @@ void eeprom_word_write(int addr, int val) short eeprom_word_read(int addr) { + int result = 0; #if !defined(ARDUINO_ARCH_MBED_RP2040) && !defined(ARDUINO_ARCH_RP2040) - return ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); -#endif + result = ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); +#endif + return result } void blink_setup() From 209bfb5ba9bfb74bbe340ed2562c23f01e461a5e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:51:15 -0500 Subject: [PATCH 15/18] Update Payload_BME280_MPU6050_XS.ino missing ; --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 274648cc4..4db0bf6ac 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -357,7 +357,7 @@ short eeprom_word_read(int addr) #if !defined(ARDUINO_ARCH_MBED_RP2040) && !defined(ARDUINO_ARCH_RP2040) result = ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); #endif - return result + return result; } void blink_setup() From 718a728b5ef89351dfba775659a28ce889d71f95 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:55:57 -0500 Subject: [PATCH 16/18] Update Payload_BME280_MPU6050_XS.ino fix !RP2040 --- .../Payload_BME280_MPU6050_XS.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 4db0bf6ac..5ab3f22bf 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -156,8 +156,9 @@ void setup() { { Serial.println("Calculating gyro offsets\n"); mpu6050.calcGyroOffsets(true); -#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) -#else +//#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) +#if !defined (ARDUINO_ARCH_RP2040) +//#else Serial.println("Storing gyro offsets in EEPROM\n"); eeprom_word_write(0, 0xA07); @@ -315,8 +316,9 @@ void loop() { // Serial.println(result); // Serial.println("OK"); // Serial.println(counter++); -#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) -#else +//#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) +#if !defined (ARDUINO_ARCH_RP2040) +//#else if (result == 'R') { Serial1.println("OK"); delay(100); From 312c9035bbc0ff9ec8db004c34ce3c8ebe12357c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 10:59:12 -0500 Subject: [PATCH 17/18] Update Payload_BME280_MPU6050_XS.ino cleanup --- .../Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino index 5ab3f22bf..f64ff084d 100644 --- a/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino +++ b/stempayload/Payload_BME280_MPU6050_XS/Payload_BME280_MPU6050_XS.ino @@ -156,9 +156,7 @@ void setup() { { Serial.println("Calculating gyro offsets\n"); mpu6050.calcGyroOffsets(true); -//#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) #if !defined (ARDUINO_ARCH_RP2040) -//#else Serial.println("Storing gyro offsets in EEPROM\n"); eeprom_word_write(0, 0xA07); @@ -316,9 +314,7 @@ void loop() { // Serial.println(result); // Serial.println("OK"); // Serial.println(counter++); -//#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) #if !defined (ARDUINO_ARCH_RP2040) -//#else if (result == 'R') { Serial1.println("OK"); delay(100); From f26919ae112191a2faeabf5f38313a1ecb74d5ae Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jan 2024 11:31:35 -0500 Subject: [PATCH 18/18] Update Payload_BME280_MPU6050_XS_Extended.ino sync with non extended after changes --- .../Payload_BME280_MPU6050_XS_Extended.ino | 141 ++++++++++++++---- 1 file changed, 109 insertions(+), 32 deletions(-) diff --git a/stempayload/Payload_BME280_MPU6050_XS_Extended/Payload_BME280_MPU6050_XS_Extended.ino b/stempayload/Payload_BME280_MPU6050_XS_Extended/Payload_BME280_MPU6050_XS_Extended.ino index 07ca7c0c7..f64ff084d 100644 --- a/stempayload/Payload_BME280_MPU6050_XS_Extended/Payload_BME280_MPU6050_XS_Extended.ino +++ b/stempayload/Payload_BME280_MPU6050_XS_Extended/Payload_BME280_MPU6050_XS_Extended.ino @@ -6,10 +6,20 @@ #include #include #include + +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) // if Arduino Mbed OS RP2040 Boards is used in Arduino IDE #include -#ifdef ARDUINO_ARCH_RP2040 +TinyGPSPlus gps; UART Serial2(8, 9, 0, 0); -#else + +#elif !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) // if Raspberry Pi RP2040 Boards in Arduino IDE +#include +TinyGPSPlus gps; +bool check_for_wifi(); +bool wifi = false; +int led_builtin_pin; + +#else // if Sparkfun Pro Micro or STM32 #include #endif @@ -17,7 +27,6 @@ UART Serial2(8, 9, 0, 0); Adafruit_BME280 bme; MPU6050 mpu6050(Wire); -TinyGPSPlus gps; long timer = 0; int bmePresent; @@ -31,7 +40,7 @@ short ee_prom_word_read(int addr); int first_time = true; int first_read = true; -#if defined ARDUINO_ARCH_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) float T2 = 26.3; // Temperature data point 1 float R2 = 167; // Reading data point 1 float T1 = 2; // Temperature data point 2 @@ -66,29 +75,45 @@ extern void payload_loop(); // sensor extension read function defined in payloa void setup() { Serial.begin(115200); // Serial Monitor for testing - + +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + Serial1.setRX(1); + delay(100); + Serial1.setTX(0); + delay(100); +#endif + Serial1.begin(115200); // for communication with Pi Zero - delay(1000); - + delay(2000); + +#if defined (ARDUINO_ARCH_MBED_RP2040) && (ARDUINO_ARCH_RP2040) + Serial.println("Pico with Mbed"); +#elif !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + Serial.println("Pico with RP2040"); +#elif defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) + Serial.println("STM32"); +#elif defined __AVR_ATmega32U4__ + Serial.println("Pro Micro"); +#else + Serial.println("Unknown board"); +#endif + Serial.println("Starting!"); -#ifdef ARDUINO_ARCH_RP2040 - Serial.println("This code is for the Raspberry Pi Pico hardware."); - +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) Serial.println("Starting Serial2 for optional GPS on JP12"); // Serial2.begin(9600); // serial from - some modules need 115200 Serial2.begin(9600); // serial from GPS or other serial sensor. Some GPS need 115200 // set all Pico GPIO connected pins to input - for (int i = 6; i < 22; i++) { + for (int i = 10; i < 22; i++) { pinMode(i, INPUT); } pinMode(26, INPUT); pinMode(27, INPUT); pinMode(28, INPUT); - pinMode(15, INPUT_PULLUP); // squelch - + pinMode(15, INPUT_PULLUP); // squelch #endif blink_setup(); @@ -131,7 +156,7 @@ void setup() { { Serial.println("Calculating gyro offsets\n"); mpu6050.calcGyroOffsets(true); -#ifndef ARDUINO_ARCH_RP2040 +#if !defined (ARDUINO_ARCH_RP2040) Serial.println("Storing gyro offsets in EEPROM\n"); eeprom_word_write(0, 0xA07); @@ -289,7 +314,7 @@ void loop() { // Serial.println(result); // Serial.println("OK"); // Serial.println(counter++); -#ifndef ARDUINO_ARCH_RP2040 +#if !defined (ARDUINO_ARCH_RP2040) if (result == 'R') { Serial1.println("OK"); delay(100); @@ -305,7 +330,7 @@ void loop() { #endif } -#ifdef ARDUINO_ARCH_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) Serial.print("Squelch: "); Serial.println(digitalRead(15)); @@ -318,7 +343,7 @@ void loop() { void eeprom_word_write(int addr, int val) { -#ifndef ARDUINO_ARCH_RP2040 +#if !defined(ARDUINO_ARCH_MBED_RP2040) && !defined(ARDUINO_ARCH_RP2040) EEPROM.write(addr * 2, lowByte(val)); EEPROM.write(addr * 2 + 1, highByte(val)); #endif @@ -326,9 +351,11 @@ void eeprom_word_write(int addr, int val) short eeprom_word_read(int addr) { -#ifndef ARDUINO_ARCH_RP2040 - return ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); -#endif + int result = 0; +#if !defined(ARDUINO_ARCH_MBED_RP2040) && !defined(ARDUINO_ARCH_RP2040) + result = ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); +#endif + return result; } void blink_setup() @@ -347,11 +374,27 @@ void blink_setup() pinMode(blueLED,OUTPUT); #endif -#if defined ARDUINO_ARCH_RP2040 - pinMode(LED_BUILTIN, OUTPUT); - pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2 - pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2 +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + pinMode(LED_BUILTIN, OUTPUT); + pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2 + pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2 #endif + +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + if (check_for_wifi()) { + wifi = true; + led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W + pinMode(LED_BUILTIN, OUTPUT); +// configure_wifi(); + } else { + led_builtin_pin = 25; // manually set GPIO 25 for Pico board +// pinMode(25, OUTPUT); + pinMode(led_builtin_pin, OUTPUT); + + pinMode(18, OUTPUT); + pinMode(19, OUTPUT); + } +#endif } void blink(int length) @@ -365,10 +408,17 @@ void blink(int length) TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF #endif -#if defined ARDUINO_ARCH_RP2040 - digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON #endif +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + if (wifi) + digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON + else + digitalWrite(led_builtin_pin, HIGH); // set the built-in LED ON +#endif + delay(length); #if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) @@ -380,9 +430,16 @@ delay(length); TXLED0; //TX LED macro to turn LED ON #endif -#if defined ARDUINO_ARCH_RP2040 +#if defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) digitalWrite(LED_BUILTIN, LOW); // set the built-in LED OFF -#endif +#endif + +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) + if (wifi) + digitalWrite(LED_BUILTIN, LOW); // set the built-in LED ON + else + digitalWrite(led_builtin_pin, LOW); // set the built-in LED ON +#endif } void led_set(int ledPin, bool state) @@ -398,7 +455,7 @@ void led_set(int ledPin, bool state) digitalWrite(ledPin, state); #endif -#ifdef ARDUINO_ARCH_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) if (ledPin == greenLED) digitalWrite(19, state); else if (ledPin == blueLED) @@ -416,14 +473,34 @@ int read_analog() #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 -#if defined ARDUINO_ARCH_RP2040 +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) sensorValue = analogRead(28); #endif return(sensorValue); } +#if !defined(ARDUINO_ARCH_MBED_RP2040) && defined(ARDUINO_ARCH_RP2040) +bool check_for_wifi() { + + pinMode(29, INPUT); + const float conversion_factor = 3.3f / (1 << 12); + uint16_t result = analogRead(29); +// Serial.printf("ADC3 value: 0x%03x, voltage: %f V\n", result, result * conversion_factor); + + if (result < 0x10) { + Serial.println("\nPico W detected!\n"); + return(true); + } + else { + Serial.println("\nPico detected!\n"); + return(false); + } +} +#endif + +#if defined (ARDUINO_ARCH_MBED_RP2040) || (ARDUINO_ARCH_RP2040) void get_gps() { -#ifdef ARDUINO_ARCH_RP2040 + Serial.println("Getting GPS data"); bool newData = false; unsigned long start = millis(); @@ -468,5 +545,5 @@ void get_gps() { } else // Serial.printf("GPS read no new data: %d\n", millis() - start); ; -#endif } +#endif