Skip to content

Commit 0b582d7

Browse files
committed
A few retries to set modem baud for esp
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
1 parent 3698b5d commit 0b582d7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

docs/FAQ/Developer-Setup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ build_flags =
106106
-D TINY_GSM_RX_BUFFER=64
107107
-D TINY_GSM_YIELD_MS=2
108108
extra_scripts = pre:pioScripts/generate_compile_commands.py
109+
targets = compiledb
109110

110111
[env:mayfly]
111112
; Find your COM port, enter it here, and remove the semicolon at the start of the line

examples/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,16 @@ void setup() {
348348
}
349349

350350
/** Start [setup_esp] */
351-
modem.modemWake(); // NOTE: This will also set up the modem
352-
modemSerial.begin(115200);
353-
modem.gsmModem.sendAT(GF("+UART_DEF=9600,8,1,0,0"));
354-
modem.gsmModem.waitResponse();
355-
modemSerial.end();
356-
modemSerial.begin(9600);
351+
for (int8_t ntries = 5; ntries; ntries--) {
352+
// This will also verify communication and set up the modem
353+
if (modem.modemWake()) break;
354+
// if that didn't work, try changing baud rate
355+
modemSerial.begin(115200);
356+
modem.gsmModem.sendAT(GF("+UART_DEF=9600,8,1,0,0"));
357+
modem.gsmModem.waitResponse();
358+
modemSerial.end();
359+
modemSerial.begin(9600);
360+
}
357361
/** End [setup_esp] */
358362

359363

@@ -365,10 +369,9 @@ void setup() {
365369
}
366370

367371
// Create the log file, adding the default header to it
368-
// Do this last so we have the best chance of getting the time correct and
369-
// all sensor names correct
370-
// Writing to the SD card can be power intensive, so if we're skipping
371-
// the sensor setup we'll skip this too.
372+
// Do this last so we have the best chance of getting the time correct
373+
// and all sensor names correct Writing to the SD card can be power
374+
// intensive, so if we're skipping the sensor setup we'll skip this too.
372375
if (getBatteryVoltage() > 3.4) {
373376
Serial.println(F("Setting up file on SD card"));
374377
dataLogger.turnOnSDcard(

0 commit comments

Comments
 (0)