smôl ZOE-M8Q Hookup Guide

Pages
Contributors: PaulZC
Favorited Favorite 0

Arduino Example: Get Position

If you are using the smôl ESP32 Processor Board, you are going to want to install the CP210x USB Driver and Arduino Boards Package for the ESP32 first. Please see the smôl ESP32 Hookup Guide for more details.

The smôl ZOE-M8Q GNSS peripheral board is fully compatible with the SparkFun u-blox GNSS Arduino Library. You can install the library through the Arduino IDE Library Manager by searching for SparkFun u-blox GNSS. Alternatively, you can grab the library from GitHub or can download it as a zip file by clicking the button below:

The following example is based on Example3_GetPosition from the u-blox GNSS library. The only difference is the two extra lines of code which pull GPIO0 low to enable power for the ZOE-M8Q. Upload the code onto your processor board and open the Serial Monitor or a terminal emulator at 115200 baud to see the output.

language:c
#include <Wire.h> //Needed for I2C to GNSS

#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;

void setup()
{
  delay(1000);

  Serial.begin(115200);
  Serial.println("SparkFun u-blox example for the smôl ZOE-M8Q");

  // GNSS power is disabled by default on the smôl ZOE-M8.
  // We need to pull GPIO0 low to enable the power.
  // On the smôl ESP32, GPIO0 is connected to digital pin 27.
  // smôl uses waterfalling:
  //  If you have an intermediate smôl board between the ESP32 and the ZOE-M8Q
  //  and that board also uses GPIO0, then the ZOE-M8Q's power enable will be connected
  //  to GPIO1 instead which is digital pin 26 on the smôl ESP32.
  pinMode(27, OUTPUT);
  digitalWrite(27, LOW); // Pull GPIO0 (digital pin 27) low to enable power for the ZOE-M8Q

  delay(1000); // Give the ZOE-M8Q some time to power up

  Wire.begin();

  //myGNSS.enableDebugging(); //Uncomment this line to enable helpful debug messages on Serial

  if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
  {
    Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
    while (1);
  }

  myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
  myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
}

void loop()
{
  //The module only responds when a new position is available

  Serial.print(myGNSS.getYear());
  Serial.print("/");
  Serial.print(myGNSS.getMonth());
  Serial.print("/");
  Serial.print(myGNSS.getDay());
  Serial.print(" ");
  Serial.print(myGNSS.getHour());
  Serial.print(":");
  Serial.print(myGNSS.getMinute());
  Serial.print(":");
  Serial.print(myGNSS.getSecond());

  Serial.print(F(" Lat: "));
  Serial.print(myGNSS.getLatitude());

  Serial.print(F(" Long: "));
  Serial.print(myGNSS.getLongitude());
  Serial.print(F(" (degrees * 10^-7)"));

  Serial.print(F(" Alt: "));
  Serial.print(myGNSS.getAltitudeMSL());
  Serial.print(F(" (mm)"));

  Serial.print(F(" SIV: "));
  Serial.print(myGNSS.getSIV());

  Serial.println();
}