From 2ed5e81d8ce047023b5eccbcf34d3ef2f555b659 Mon Sep 17 00:00:00 2001 From: Evilgeniusnerd Date: Wed, 13 May 2020 18:45:32 -0400 Subject: [PATCH 1/3] Added Heltec Esp32 Lora Board function Signed-off-by: Evilgeniusnerd --- .../BasicSend_v2_Heltec__Lora.ino | 78 +++++++++++++++++++ .../BasicSend_v2_Heltec__Lora.ino | 78 +++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino create mode 100644 examples/Time/BasicSend_v2_Heltec__Lora/BasicSend_v2_Heltec__Lora.ino diff --git a/examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino b/examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino new file mode 100644 index 0000000..06fe58a --- /dev/null +++ b/examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino @@ -0,0 +1,78 @@ +#include + +/* + BasicSend + + This sketch sends a "Hello, world!" message from the satellite modem. + If you have activated your account and have credits, this message + should arrive at the endpoints you have configured (email address or + HTTP POST). + + Assumptions + + The sketch assumes an Arduino Mega or other Arduino-like device with + multiple HardwareSerial ports. It assumes the satellite modem is + connected to Serial3. Change this as needed. SoftwareSerial on an Uno + works fine as well. + + you can't use U0TXD and U0RXD becuase they are used for the programming of the board, quite why Heltec brought these pins + out to the edge connector I don't know, I suppose to allow an external programmer, who knows. + The pins that are free are as follows: + GPIO-17 + GPIO-2 + GPIO-22 + GPIO-23 + GPIO-0 + GPIO-12 + GPIO-13 + GPIO-25 + + All other spare pins are inputs only, best avoided. + + I've modified the code here accordingly to use (say) 12 and 13 + + Wiring: + Heltec Pin 12 (rxpin) --- Iridium txdata pin + Heltec Pin 13 (txpin) --- Iridium rxdata pin + +*/ + +#define IridiumSerial Serial2 +#define DIAGNOSTICS false// Change this to see diagnostics +#define RXD2 2 +#define TXD2 0 + +// Declare the IridiumSBD object +IridiumSBD modem(IridiumSerial); + + +void setup() +{ + Serial.begin(19200); + Serial.println("Starting setup..."); + + int signalQuality = -1; + int err; + + // Start the serial port connected to the satellite modem + Serial.println("Starting satellite serial connection (swSer)"); + Serial2.begin(19200, SERIAL_8N1, RXD2, TXD2); + + // Begin satellite modem operation + Serial.println("Starting modem..."); + err = modem.begin(); + Serial.print("modem: "); + Serial.println(err); + + if (err != ISBD_SUCCESS) + { + Serial.print("Begin failed: error "); + Serial.println(err); + if (err == ISBD_NO_MODEM_DETECTED) + Serial.println("No modem detected: check wiring."); + return; + } +} + +void loop() { +} diff --git a/examples/Time/BasicSend_v2_Heltec__Lora/BasicSend_v2_Heltec__Lora.ino b/examples/Time/BasicSend_v2_Heltec__Lora/BasicSend_v2_Heltec__Lora.ino new file mode 100644 index 0000000..06fe58a --- /dev/null +++ b/examples/Time/BasicSend_v2_Heltec__Lora/BasicSend_v2_Heltec__Lora.ino @@ -0,0 +1,78 @@ +#include + +/* + BasicSend + + This sketch sends a "Hello, world!" message from the satellite modem. + If you have activated your account and have credits, this message + should arrive at the endpoints you have configured (email address or + HTTP POST). + + Assumptions + + The sketch assumes an Arduino Mega or other Arduino-like device with + multiple HardwareSerial ports. It assumes the satellite modem is + connected to Serial3. Change this as needed. SoftwareSerial on an Uno + works fine as well. + + you can't use U0TXD and U0RXD becuase they are used for the programming of the board, quite why Heltec brought these pins + out to the edge connector I don't know, I suppose to allow an external programmer, who knows. + The pins that are free are as follows: + GPIO-17 + GPIO-2 + GPIO-22 + GPIO-23 + GPIO-0 + GPIO-12 + GPIO-13 + GPIO-25 + + All other spare pins are inputs only, best avoided. + + I've modified the code here accordingly to use (say) 12 and 13 + + Wiring: + Heltec Pin 12 (rxpin) --- Iridium txdata pin + Heltec Pin 13 (txpin) --- Iridium rxdata pin + +*/ + +#define IridiumSerial Serial2 +#define DIAGNOSTICS false// Change this to see diagnostics +#define RXD2 2 +#define TXD2 0 + +// Declare the IridiumSBD object +IridiumSBD modem(IridiumSerial); + + +void setup() +{ + Serial.begin(19200); + Serial.println("Starting setup..."); + + int signalQuality = -1; + int err; + + // Start the serial port connected to the satellite modem + Serial.println("Starting satellite serial connection (swSer)"); + Serial2.begin(19200, SERIAL_8N1, RXD2, TXD2); + + // Begin satellite modem operation + Serial.println("Starting modem..."); + err = modem.begin(); + Serial.print("modem: "); + Serial.println(err); + + if (err != ISBD_SUCCESS) + { + Serial.print("Begin failed: error "); + Serial.println(err); + if (err == ISBD_NO_MODEM_DETECTED) + Serial.println("No modem detected: check wiring."); + return; + } +} + +void loop() { +} From 7c60deafc8d4cd15fc2e452c003bdec347eb97c9 Mon Sep 17 00:00:00 2001 From: Evilgeniusnerd Date: Wed, 13 May 2020 19:16:47 -0400 Subject: [PATCH 2/3] Updated Working TTGo & Heltec Integration Signed-off-by: Evilgeniusnerd --- .../BasicSend_v2_Heltec_Lora.ino} | 11 +--- .../BasicSend_v2_TTGO_Boards.ino | 66 +++++++++++++++++++ 2 files changed, 68 insertions(+), 9 deletions(-) rename examples/{Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino => BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino} (85%) create mode 100644 examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino diff --git a/examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino b/examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino similarity index 85% rename from examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino rename to examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino index 06fe58a..58f4f75 100644 --- a/examples/Heltec Esp32_Lora/BasicSend_v2_Heltec__Lora.ino +++ b/examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino @@ -8,13 +8,6 @@ should arrive at the endpoints you have configured (email address or HTTP POST). - Assumptions - - The sketch assumes an Arduino Mega or other Arduino-like device with - multiple HardwareSerial ports. It assumes the satellite modem is - connected to Serial3. Change this as needed. SoftwareSerial on an Uno - works fine as well. - you can't use U0TXD and U0RXD becuase they are used for the programming of the board, quite why Heltec brought these pins out to the edge connector I don't know, I suppose to allow an external programmer, who knows. The pins that are free are as follows: @@ -39,8 +32,8 @@ #define IridiumSerial Serial2 #define DIAGNOSTICS false// Change this to see diagnostics -#define RXD2 2 -#define TXD2 0 +#define RXD2 12 +#define TXD2 13 // Declare the IridiumSBD object IridiumSBD modem(IridiumSerial); diff --git a/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino b/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino new file mode 100644 index 0000000..69f78c4 --- /dev/null +++ b/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino @@ -0,0 +1,66 @@ +#include + +/* + BasicSend + + This sketch sends a "Hello, world!" message from the satellite modem. + If you have activated your account and have credits, this message + should arrive at the endpoints you have configured (email address or + HTTP POST). + + The TTGO T Beam unit does not have many if any spare GPIO ports. Most of the + ports are already in use for Esp32, Lora and GPS. So this only leaves you + + Pins: + GPIO-13 + GPIO-25 + + All other spare pins are inputs only, best avoided. + + I've modified the code here accordingly to use (say) 12 and 13 + + Wiring: + TTGO Pin 13 (rxpin) --- Iridium txdata pin + TTGO Pin 25 (txpin) --- Iridium rxdata pin + +*/ + +#define IridiumSerial Serial2 +#define DIAGNOSTICS false// Change this to see diagnostics +#define RXD2 13 +#define TXD2 25 + +// Declare the IridiumSBD object +IridiumSBD modem(IridiumSerial); + + +void setup() +{ + Serial.begin(19200); + Serial.println("Starting setup..."); + + int signalQuality = -1; + int err; + + // Start the serial port connected to the satellite modem + Serial.println("Starting satellite serial connection (swSer)"); + Serial2.begin(19200, SERIAL_8N1, RXD2, TXD2); + + // Begin satellite modem operation + Serial.println("Starting modem..."); + err = modem.begin(); + Serial.print("modem: "); + Serial.println(err); + + if (err != ISBD_SUCCESS) + { + Serial.print("Begin failed: error "); + Serial.println(err); + if (err == ISBD_NO_MODEM_DETECTED) + Serial.println("No modem detected: check wiring."); + return; + } +} + +void loop() { +} From 6daf74937c9255a79fc6e5dfec39353b926347ca Mon Sep 17 00:00:00 2001 From: Evilgeniusnerd Date: Sat, 16 May 2020 10:40:05 -0400 Subject: [PATCH 3/3] Fixed Heltec & TTgo Code Signed-off-by: Evilgeniusnerd --- .../BasicSend_v2_Heltec_Lora.ino | 87 ++++++++++++++----- .../BasicSend_v2_TTGO_Boards.ino | 80 ++++++++++++++--- 2 files changed, 134 insertions(+), 33 deletions(-) diff --git a/examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino b/examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino index 58f4f75..5a6b32c 100644 --- a/examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino +++ b/examples/BasicSend_v2_Heltec_Lora/BasicSend_v2_Heltec_Lora.ino @@ -2,12 +2,6 @@ /* BasicSend - - This sketch sends a "Hello, world!" message from the satellite modem. - If you have activated your account and have credits, this message - should arrive at the endpoints you have configured (email address or - HTTP POST). - you can't use U0TXD and U0RXD becuase they are used for the programming of the board, quite why Heltec brought these pins out to the edge connector I don't know, I suppose to allow an external programmer, who knows. The pins that are free are as follows: @@ -32,40 +26,93 @@ #define IridiumSerial Serial2 #define DIAGNOSTICS false// Change this to see diagnostics -#define RXD2 12 -#define TXD2 13 +#define rxpin 12 +#define txpin 13 // Declare the IridiumSBD object IridiumSBD modem(IridiumSerial); - void setup() { - Serial.begin(19200); - Serial.println("Starting setup..."); - int signalQuality = -1; - int err; + int err; + + // Start the console serial port + Serial.begin(1500); + while (!Serial); // Start the serial port connected to the satellite modem - Serial.println("Starting satellite serial connection (swSer)"); - Serial2.begin(19200, SERIAL_8N1, RXD2, TXD2); + Serial2.begin(9600, SERIAL_8N1, rxpin, txpin, false); // false means normal data polarity so steady state of line = 0, true means staedy state = high. // Begin satellite modem operation Serial.println("Starting modem..."); err = modem.begin(); - Serial.print("modem: "); - Serial.println(err); - if (err != ISBD_SUCCESS) { - Serial.print("Begin failed: error "); + Serial.print("Modem begin failed: error "); Serial.println(err); if (err == ISBD_NO_MODEM_DETECTED) Serial.println("No modem detected: check wiring."); return; } + + // Example: Print the firmware revision + char version[12]; + err = modem.getFirmwareVersion(version, sizeof(version)); + if (err != ISBD_SUCCESS) + { + Serial.print("FirmwareVersion failed: error "); + Serial.println(err); + return; + } + Serial.print("Firmware Version is "); + Serial.print(version); + Serial.println("."); + + // Example: Test the signal quality. + // This returns a number between 0 and 5. + // 2 or better is preferred. + err = modem.getSignalQuality(signalQuality); + if (err != ISBD_SUCCESS) + { + Serial.print("SignalQuality failed: error "); + Serial.println(err); + return; + } + + Serial.print("On a scale of 0 to 5, signal quality is currently "); + Serial.print(signalQuality); + Serial.println("."); + + // Send the message + Serial.print("Trying to send the message. This might take several minutes.\r\n"); + err = modem.sendSBDText("Hello, world!"); + if (err != ISBD_SUCCESS) + { + Serial.print("sendSBDText failed: error "); + Serial.println(err); + if (err == ISBD_SENDRECEIVE_TIMEOUT) + Serial.println("Try again with a better view of the sky."); + } + + else + { + Serial.println("Hey, it worked!"); + } +} + +void loop() +{ } -void loop() { +#if DIAGNOSTICS +void ISBDConsoleCallback(IridiumSBD *device, char c) +{ + Serial.write(c); +} + +void ISBDDiagsCallback(IridiumSBD *device, char c) +{ + Serial.write(c); } +#endif diff --git a/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino b/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino index 69f78c4..c3f8149 100644 --- a/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino +++ b/examples/BasicSend_v2_TTGO_Boards/BasicSend_v2_TTGO_Boards.ino @@ -27,8 +27,8 @@ #define IridiumSerial Serial2 #define DIAGNOSTICS false// Change this to see diagnostics -#define RXD2 13 -#define TXD2 25 +#define rxpin 13 +#define txpin 25 // Declare the IridiumSBD object IridiumSBD modem(IridiumSerial); @@ -36,31 +36,85 @@ IridiumSBD modem(IridiumSerial); void setup() { - Serial.begin(19200); - Serial.println("Starting setup..."); - int signalQuality = -1; - int err; + int err; + + // Start the console serial port + Serial.begin(1500); + while (!Serial); // Start the serial port connected to the satellite modem - Serial.println("Starting satellite serial connection (swSer)"); - Serial2.begin(19200, SERIAL_8N1, RXD2, TXD2); + Serial2.begin(9600, SERIAL_8N1, rxpin, txpin, false); // false means normal data polarity so steady state of line = 0, true means staedy state = high. // Begin satellite modem operation Serial.println("Starting modem..."); err = modem.begin(); - Serial.print("modem: "); - Serial.println(err); - if (err != ISBD_SUCCESS) { - Serial.print("Begin failed: error "); + Serial.print("Modem begin failed: error "); Serial.println(err); if (err == ISBD_NO_MODEM_DETECTED) Serial.println("No modem detected: check wiring."); return; } + + // Example: Print the firmware revision + char version[12]; + err = modem.getFirmwareVersion(version, sizeof(version)); + if (err != ISBD_SUCCESS) + { + Serial.print("FirmwareVersion failed: error "); + Serial.println(err); + return; + } + Serial.print("Firmware Version is "); + Serial.print(version); + Serial.println("."); + + // Example: Test the signal quality. + // This returns a number between 0 and 5. + // 2 or better is preferred. + err = modem.getSignalQuality(signalQuality); + if (err != ISBD_SUCCESS) + { + Serial.print("SignalQuality failed: error "); + Serial.println(err); + return; + } + + Serial.print("On a scale of 0 to 5, signal quality is currently "); + Serial.print(signalQuality); + Serial.println("."); + + // Send the message + Serial.print("Trying to send the message. This might take several minutes.\r\n"); + err = modem.sendSBDText("Hello, world!"); + if (err != ISBD_SUCCESS) + { + Serial.print("sendSBDText failed: error "); + Serial.println(err); + if (err == ISBD_SENDRECEIVE_TIMEOUT) + Serial.println("Try again with a better view of the sky."); + } + + else + { + Serial.println("Hey, it worked!"); + } } -void loop() { +void loop() +{ +} + +#if DIAGNOSTICS +void ISBDConsoleCallback(IridiumSBD *device, char c) +{ + Serial.write(c); +} + +void ISBDDiagsCallback(IridiumSBD *device, char c) +{ + Serial.write(c); } +#endif