|
| 1 | +/* |
| 2 | + Test baud rate changes on serial, factory reset, and hard reset. |
| 3 | + By: Thorsten von Eicken |
| 4 | + Date: January 29rd, 2019 |
| 5 | + License: MIT. See license file for more information but you can |
| 6 | + basically do whatever you want with this code. |
| 7 | +
|
| 8 | + This example shows how to reset the U-Blox module to factory defaults. |
| 9 | +
|
| 10 | + Feel like supporting open source hardware? |
| 11 | + Buy a board from SparkFun! |
| 12 | + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 |
| 13 | + NEO-M8P RTK: https://www.sparkfun.com/products/15005 |
| 14 | + SAM-M8Q: https://www.sparkfun.com/products/15106 |
| 15 | +
|
| 16 | + Hardware Connections: |
| 17 | + Connect the U-Blox serial port to Serial1 |
| 18 | + If you're using an Uno or don't have a 2nd serial port (Serial1), consider using software serial |
| 19 | + Open the serial monitor at 115200 baud to see the output |
| 20 | +*/ |
| 21 | + |
| 22 | +#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS |
| 23 | +SFE_UBLOX_GPS myGPS; |
| 24 | + |
| 25 | +int state = 0; // steps through auto-baud, reset, etc states |
| 26 | + |
| 27 | +void setup() |
| 28 | +{ |
| 29 | + Serial.begin(115200); |
| 30 | + while (!Serial); //Wait for user to open terminal |
| 31 | + Serial.println("SparkFun Ublox Example"); |
| 32 | + |
| 33 | + Wire.begin(); |
| 34 | + |
| 35 | + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port |
| 36 | + { |
| 37 | + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); |
| 38 | + while (1); |
| 39 | + } |
| 40 | + |
| 41 | + while (Serial.available()) Serial.read(); //Trash any incoming chars |
| 42 | + Serial.println("Press a key to reset module to factory defaults"); |
| 43 | + while (Serial.available() == false) ; //Wait for user to send character |
| 44 | + |
| 45 | + myGPS.factoryReset(); |
| 46 | + |
| 47 | + if (myGPS.begin() == false) //Attempt to re-connect |
| 48 | + { |
| 49 | + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); |
| 50 | + while (1); |
| 51 | + } |
| 52 | + |
| 53 | + Serial.println("Unit has now been factory reset. Freezing..."); |
| 54 | + while(1); |
| 55 | +} |
| 56 | + |
| 57 | +void loop() |
| 58 | +{ |
| 59 | + |
| 60 | +} |
0 commit comments