Home › Forums › Mayfly Data Logger › XBee and Hologram LTE: issues connecting to internet › Reply To: XBee and Hologram LTE: issues connecting to internet
2020-12-23 at 10:17 AM
#14969
And a new program to try to set it up in bypass to see if we can see what’s failing that way. I’ve also posted this on GitHub here: https://github.com/EnviroDIY/ModularSensors/blob/master/tools/LTExBee_FirstConnectionBypass/LTExBee_FirstConnectionBypass.ino
Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
#define TINY_GSM_MODEM_SARAR4 #define TINY_GSM_RX_BUFFER 64 #define TINY_GSM_YIELD_MS 2 #define TINY_GSM_DEBUG Serial #include <Arduino.h> #include <StreamDebugger.h> #include <TinyGsmClient.h> StreamDebugger debugger(Serial1, Serial); TinyGsm gsmModem(debugger); const char* apn = "m2m"; void setup() { // Set the reset pin HIGH to ensure the Bee does not continually reset pinMode(20, OUTPUT); digitalWrite(20, HIGH); // Set the sleep_rq pin LOW to wake the Bee pinMode(23, OUTPUT); digitalWrite(23, LOW); // Set the input pin mode pinMode(19, INPUT); // Set console baud rate Serial.begin(115200); delay(10); // Set XBee module baud rate Serial1.begin(9600); // Wait for warm-up, probably overkill delay(6000); } void loop() { bool success = false; DBG(F("Putting XBee into command mode...")); for (uint8_t i = 0; i < 5; i++) { /** First, wait the required guard time before entering command mode. */ delay(1010); /** Now, enter command mode to set all pin I/O functionality. */ gsmModem.streamWrite(GF("+++")); success = gsmModem.waitResponse(2000, GF("OK\r")) == 1; if (success) break; } if (success) { DBG(F("Setting I/O Pins...")); /** Enable pin sleep functionality on <code>DIO9</code>. * NOTE: Only the <code>DTR_N/SLEEP_RQ/DIO8</code> pin (9 on the bee socket) can be * used for this pin sleep/wake. */ gsmModem.sendAT(GF("D8"), 1); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Enable status indication on <code>DIO9</code> - it will be HIGH when the XBee * is awake. * NOTE: Only the <code>ON/SLEEP_N/DIO9</code> pin (13 on the bee socket) can be * used for direct status indication. */ gsmModem.sendAT(GF("D9"), 1); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Enable CTS on <code>DIO7</code> - it will be <code>LOW</code> when it is clear to send * data to the XBee. This can be used as proxy for status indication if * that pin is not readable. * NOTE: Only the <code>CTS_N/DIO7</code> pin (12 on the bee socket) can be used * for CTS. */ gsmModem.sendAT(GF("D7"), 1); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Enable association indication on <code>DIO5</code> - this is should be directly * attached to an LED if possible. * - Solid light indicates no connection * - Single blink indicates connection * - double blink indicates connection but failed TCP link on last * attempt * * NOTE: Only the <code>Associate/DIO5</code> pin (15 on the bee socket) can be * used for this function. */ gsmModem.sendAT(GF("D5"), 1); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Enable RSSI PWM output on <code>DIO10</code> - this should be directly attached * to an LED if possible. A higher PWM duty cycle (and thus brighter * LED) indicates better signal quality. * NOTE: Only the <code>DIO10/PWM0</code> pin (6 on the bee socket) can be used for * this function. */ gsmModem.sendAT(GF("P0"), 1); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Enable pin sleep on the XBee. */ DBG(F("Setting Sleep Options...")); gsmModem.sendAT(GF("SM"), 1); success &= gsmModem.waitResponse(GF("OK\r")) == 1; DBG(F("Setting Other Options...")); /** Disable remote manager, USB Direct, and LTE PSM. * NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no easy * way on the LTE-M Bee to wake the cell chip itself from PSM, so we'll * use the Digi pin sleep instead. */ gsmModem.sendAT(GF("DO"), 0); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /* Make sure USB direct is NOT enabled on the XBee3 units. */ gsmModem.sendAT(GF("P1"), 0); success &= gsmModem.waitResponse(GF("OK\r")) == 1; // DBG(F("Setting Cellular Carrier Options...")); // // Carrier Profile - 1 = No profile/SIM ICCID selected // gsmModem.sendAT(GF("CP"),1); // success &= gsmModem.waitResponse(GF("OK\r")) == 1; // // Cellular network technology - LTE-M/NB IoT // gsmModem.sendAT(GF("N#"),0); // success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Make sure airplane mode is off - bypass and airplane mode are // incompatible. DBG(F("Making sure airplane mode is off...")); gsmModem.sendAT(GF("AM"), 0); success &= gsmModem.waitResponse(GF("OK\r")) == 1; DBG(F("Turning on Bypass Mode...")); /** Enable bypass mode. */ gsmModem.sendAT(GF("AP5")); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Write changes to flash. */ gsmModem.sendAT(GF("WR")); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Apply changes. */ gsmModem.sendAT(GF("AC")); success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Finally, force a reset to actually enter bypass mode - this // effectively exits command mode. DBG(F("Resetting the module to reboot in bypass mode...")); gsmModem.sendAT(GF("FR")); success &= gsmModem.waitResponse(5000L, GF("OK\r")) == 1; // Allow 5s for the unit to reset. delay(500); // Re-initialize the TinyGSM SARA R4 instance. DBG(F("Attempting to reconnect to the u-blox SARA R410M module...")); success &= gsmModem.init(); gsmModem.getModemName(); } else { // wait a bit delay(30000L); // try again return; } DBG(F("Setting Cellular Carrier Options...")); // Turn off the cellular radio while making network changes gsmModem.sendAT(GF("+CFUN=0")); gsmModem.waitResponse(); // Mobile Network Operator Profile // - 0: SW default // - 1: SIM ICCID selected // - 2: ATT // - 3: Verizon // - 4: Telstra // - 5: T-Mobile US // - 6: China Telecom // - 8: Sprint // - 19: Vodafone // - 20: NTT DoCoMo // - 21: Telus // - 28: SoftBank // - 31: Deutsche Telekom // - 32: US Cellular // - 33: VIVO // - 39: SKT // - 44: Claro Brasil // - 45: TIM Brasil // - 46: Orange France // - 90: global // - 100: Standard Europe // - 101: Standard Europe No-ePCO (The factory-programmed configuration of // this profile is the same of the standard Europe profile (<MNO>=100), but // the ePCO is disabled.) // - 102: Standard Japan (global) // - 198: AT&T 2-4-12 (The factory programmed configuration of this profile // is the same of the AT&T profile (<MNO>=2), but the LTE band 5 is // disabled.) // - 201: GCF-PTCRB (This profile is meant only for conformance testing.) gsmModem.sendAT(GF("+UMNOPROF="), 1); gsmModem.waitResponse(); // Selected network technology - 7: LTE Cat.M1 // - 8: LTE Cat.NB1 // Fallback network technology - 7: LTE Cat.M1 // - 8: LTE Cat.NB1 // NOTE: As of 2020 in the USA, AT&T and Verizon only use LTE-M // T-Mobile uses NB-IOT gsmModem.sendAT(GF("+URAT="), 7, ',', 8); gsmModem.waitResponse(); // Set the band mask manually if needed // bit 0 = band 1; bit 127 = band 128 gsmModem.sendAT(GF("+UBANDMASK="), 0, ',', 134217732); gsmModem.waitResponse(); // Restart the module to apply changes and bring back to full functionality gsmModem.restart(); // Check again for the carrier profile (to ensure it took) // If 1/SIM select was used, this will show what the SIM picked gsmModem.sendAT(GF("+UMNOPROF?")); gsmModem.waitResponse(); // Scan for networks - this is probably really slow DBG(F("Scanning for networks. This may take up to 3 minutes")); gsmModem.sendAT(GF("+COPS=0")); gsmModem.waitResponse(); gsmModem.sendAT(GF("+COPS=?")); gsmModem.waitResponse(180000L); // Wait forever for a connection DBG(F("Waiting for network registration")); while (!gsmModem.isNetworkConnected()) { int csq = gsmModem.getSignalQuality(); DBG("Signal quality:", csq); delay(250); } // Print some stuff after connected String ccid = gsmModem.getSimCCID(); DBG("CCID:", ccid); String imei = gsmModem.getIMEI(); DBG("IMEI:", imei); String imsi = gsmModem.getIMSI(); DBG("IMSI:", imsi); String cop = gsmModem.getOperator(); DBG("Operator:", cop); IPAddress local = gsmModem.localIP(); DBG("Local IP:", local); // Shut down gsmModem.poweroff(); DBG("Powering down."); // And do nothing forever more. while (1) {} } |
You should set your end of line back to newline instead of carriage return when running this or you might get a lot of extra blank lines in the printout.