Home › Forums › Mayfly Data Logger › Wifi Bee AT Firmware and Baud Rates › Reply To: Wifi Bee AT Firmware and Baud Rates
2026-03-18 at 1:50 PM
#19617
Use 3.3V to power the WiFi bee and make sure that you’re adapter uses 3.3V logic. The 0.5A most USB ports can provide should be enough for the WiFi bee without browning out. You are seeing the lights on the bee go on, right?
This script worked for me to force the baud rate on three different WiFi Bee’s. The script forces the baud rate and then factory resets the board and then forces the baud rate again – over and over, just to show it works. Don’t run it long; you could wear out the bee’s flash if you let it run forever.
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 |
#include <Arduino.h> #define TINY_GSM_MODEM_ESP32 // See all AT commands, if wanted // WARNING: At high baud rates, incoming data may be lost when dumping AT // commands #define DUMP_AT_COMMANDS // Define the serial console for debug prints, if needed #define TINY_GSM_DEBUG Serial // Range to attempt to autobaud // NOTE: DO NOT AUTOBAUD in production code. Once you've established // communication, set a fixed baud rate using modem.setBaud(#). #define GSM_AUTOBAUD_MIN 9600 #define GSM_AUTOBAUD_MAX 921600 #ifndef TARGET_BAUD #define TARGET_BAUD 9600 #endif #include <TinyGsmClient.h> #ifdef DUMP_AT_COMMANDS #include <StreamDebugger.h> StreamDebugger debugger(Serial1, Serial); TinyGsm modem(debugger); #else TinyGsm modem(SerialAT); #endif bool flip = true; void setup() { Serial.begin(115200); delay(100); Serial.println(F("Starting force baud test in 1s...")); digitalWrite(18, HIGH); digitalWrite(A5, HIGH); delay(1000); modem.streamClear(); // Clear any junk in the stream from startup } void loop() { // put your setup code here, to run once: uint32_t modemBaud = TARGET_BAUD; bool baudSet = false; Serial.println(F("\n\n\n==============================")); Serial.println(F("==============================")); if (flip) { Serial.print(F("Attempting to switch baud rate to ")); Serial.print(modemBaud); Serial.println(F(" using a fire-and-hope method...")); Serial.println(F("Assuming modem baud rate is 115200 (default)")); for (uint8_t i = 0; i < 10; i++) { Serial1.begin(115200); delay(50); modem.sendAT(GF("+UART_DEF="), modemBaud, F(",8,1,0,0")); modem.waitResponse(); Serial1.end(); delay(50); Serial1.begin(modemBaud); delay(50); if (!modem.testAT(1500L)) { Serial.print(F("Attempt ")); Serial.print(i + 1); Serial.println(F(" failed to switch baud rate")); } else { Serial.print(F("Attempt ")); Serial.print(i + 1); Serial.println(F(" successfully switched baud rate")); break; } } } else { Serial.println(F("Attempting to force baud rate using forceModemBaud...")); baudSet = modem.forceModemBaud(Serial1, TARGET_BAUD); baudSet &= modem.testAT(); } if (baudSet) { Serial.println(F("Getting modem info to confirm communication is working...")); modem.begin(); String modemInfo = modem.getModemInfo(); if (modemInfo.length() > 0) { Serial.println(F("\n================")); Serial.println(modemInfo); Serial.println(F("================\n\n")); } } if (baudSet) { Serial.println(F("Wait 5 seconds, then factory reset modem to restore default baud rate...")); delay(5000); bool resetSuccess = modem.factoryDefault(); Serial1.begin(115200); delay(350); if (resetSuccess) { Serial.println(F("Modem successfully reset to factory defaults.")); Serial.println(); Serial.println(F("Test AT commands to confirm modem is responding at default baud rate.")); Serial.println(F("On a 8MHz processor, THIS WILL FAIL! When dumping AT commands, you can see the modem is responding but the response will be garbled.")); modem.testAT(1500L); } else { Serial.println(F("Failed to reset modem to factory defaults.")); } } Serial.println(F("Wait 5 seconds before repeating the test...")); delay(5000); flip = !flip; } |
Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of