Xiao Nrf52840 Sense w/ GPS Air530 & Expansion Board

Got the AIr530 connected to the expansion board with Xiao Sense on board.
GPS library TinyGPS, basic example works well, Co-ordinates are Very accurate AFAIK less than a meter for sure. You get a Green Yellow flip of the LED’s when Connected to Sats, Green when powered on.
Here’s the basic code and pictures.
The last one is the connected to U-center from Ublox with a free Google maps API key inserted.
HTH
GL :slight_smile: PJ
Scary how accurate this is even indoors , one of those Ukrainian drones dropping a grenade would be close enough…WOW :laughing:

#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>

#include <TinyGPSPlus.h>
static const int RXPin = 6, TXPin = 7;          // 6, 7
static const uint32_t GPSBaud = 9600;
//TinyGPSPlus object
TinyGPSPlus gps;
//Display object
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ PIN_WIRE_SCL, /* data=*/ PIN_WIRE_SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display
const int pinLed = LED_BUILTIN;
float __longitude = 0;      
float __latitude  = 0;
const int ledPin = LED_BUILTIN;
int BuzzerPin = A3;                 //A3 , P0.29 PIN 4
int buzzer = BuzzerPin;

void setup(void) {
    u8x8.begin();
    u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
    Serial1.begin(GPSBaud);
    Serial.begin(9600);
    delay(2000);                       //relax...Get Ready for serial port
    Serial.println("Test program" __FILE__ " compiled on " __DATE__ " at " __TIME__);
    Serial.println();
    Serial.println("Processor came out of reset.");
    
   initdisplay();
   setupblink();  
}

void loop(void) {
    
    dispGPS();

    while (Serial1.available() > 0)
    if (gps.encode(Serial1.read()))
    {
        __latitude  = gps.location.lat();
        __longitude = gps.location.lng(); 
    }
}


void dispGPS()
{
       //Serial.println("getting gps");

    u8x8.setCursor(0, 0);
    u8x8.print("GPS LOCATION   ");
    u8x8.setCursor(0, 3);
    u8x8.print(__latitude, 6);
    u8x8.setCursor(0, 5);
    u8x8.print(__longitude, 6);  
}


void setupblink(){
  setLedRGB(false, false, true);  // set Blue LED 
    delay(1000);
    setLedRGB(false, true, false);  // Red
    delay(1000);
    setLedRGB(true, false, false);  // Green
    delay(1000);
    setLedRGB(false, false, false);  // OFF
}  

void initdisplay() {
 pinMode(LEDR, OUTPUT);         // initialize the LED pin as an output:
 pinMode(LEDG, OUTPUT);         // initialize the LED pin as an output:
 pinMode(LEDB, OUTPUT);
 pinMode(LED_BUILTIN, OUTPUT);      // initialize the LED pin as an output:
  u8x8.begin();
    u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
    u8x8.setFont(u8x8_font_8x13B_1x2_r);
    u8x8.clearDisplay();
    u8x8.setCursor(0, 0);
    u8x8.print("Power ON ");
}

void startsound() {
  tone (buzzer, 890);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 800);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 800);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 990);
    delay (420);
    noTone(buzzer);
    delay (20);
}

void setLedRGB(bool red, bool green, bool blue) {
   if (!red) { digitalWrite(LEDR, HIGH); } else { digitalWrite(LEDR, LOW); }
   if (!green) { digitalWrite(LEDG, HIGH); } else { digitalWrite(LEDG, LOW); }
   if (!blue) { digitalWrite(LEDB, HIGH); } else { digitalWrite(LEDB, LOW); }
}
// END





1 Like

Here is another basic example moded from original.
Alternates the GMT time, Location and Number of SATs acquired.
HTH
GL :slight_smile: PJ

#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>

#include <TinyGPSPlus.h>
static const int RXPin = 6, TXPin = 7;          // 6, 7
static const uint32_t GPSBaud = 9600;
//TinyGPSPlus object
TinyGPSPlus gps;
//Display object
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ PIN_WIRE_SCL, /* data=*/ PIN_WIRE_SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display
//const int pinLed = LED_BUILTIN;
float __longitude = 0;      
float __latitude  = 0;
const int ledPin = LED_BUILTIN;
int BuzzerPin = A3;                 //A3 , P0.29 PIN 4
int buzzer = BuzzerPin;

void setup(void) {
    u8x8.begin();
    u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
    Serial1.begin(GPSBaud);
    Serial.begin(9600);
    delay(2000);                       //relax...Get Ready for serial port
    Serial.println("Test program" __FILE__ " compiled on " __DATE__ " at " __TIME__);
    Serial.println();
    Serial.println("Processor came out of reset.");
   initdisplay(); // POWER ON
   startsound();  // Startup Sound
   setupblink();  // Test RGB LED
}

void loop(void) {
       
    while (Serial1.available() > 0)
    if (gps.encode(Serial1.read()))
    {
        __latitude  = gps.location.lat();
        __longitude = gps.location.lng(); 
    }
    u8x8.clearDisplay();
    dispSats();
    delay(2000);
    u8x8.clearDisplay();
    dispGPS();
    delay(2000);
    u8x8.clearDisplay();
    timeGps();
    delay(2000);
    //u8x8.clearDisplay();
}

void dispSats()
{
    u8x8.setCursor(0, 0);
    u8x8.print("Sats:");
    //u8x8.setFont(u8x8_font_profont29_2x3_n); //switch to big font
    u8x8.setFont(u8x8_font_inr33_3x6_n);      //switch to GIANT font
    u8x8.setCursor(5, 3);
    u8x8.print(gps.satellites.value());       // number of Satellites
    u8x8.setFont(u8x8_font_8x13B_1x2_r);      // reset font
}

void timeGps (){
if(gps.time.isUpdated()) 
  {
    Serial.println("Time has been updated");
    Serial.print("Satellites: ");
    Serial.println(gps.satellites.value());
    Serial.print("Time now [GMT]: ");
    u8x8.setCursor(0, 0);
    u8x8.print("Time now [GMT]: ");
    Serial.print(gps.time.hour());
    u8x8.setCursor(3, 3);
    u8x8.print(gps.time.hour());
    u8x8.print(":");
    Serial.print(":");
    Serial.print(gps.time.minute());
    u8x8.print(gps.time.minute());
    Serial.print(":");
    u8x8.print(":");
    Serial.print(gps.time.second());
    u8x8.print(gps.time.second());

    if (gps.date.isValid())
    {
      Serial.print("  Date:  ");
      Serial.print(gps.date.year());
      Serial.print("/");
      Serial.print(gps.date.month());
      Serial.print("/");
      Serial.println(gps.date.day());
    }
    //delay(5000); // This delay gives us exact time every 5s seconds
  }
}

void dispGPS()
{
       //Serial.println("getting gps");

    u8x8.setCursor(0, 0);
    u8x8.print("GPS LOCATION   ");
    u8x8.setCursor(2, 3);
    u8x8.print(__latitude, 6);
    u8x8.setCursor(2, 5);
    u8x8.print(__longitude, 6);  
}


void setupblink(){
  setLedRGB(false, false, true);  // set Blue LED 
    delay(1000);
    setLedRGB(false, true, false);  // Red
    delay(1000);
    setLedRGB(true, false, false);  // Green
    delay(1000);
    setLedRGB(false, false, false);  // OFF
}  

void initdisplay() {
 pinMode(LEDR, OUTPUT);         // initialize the LED pin as an output:
 pinMode(LEDG, OUTPUT);         // initialize the LED pin as an output:
 pinMode(LEDB, OUTPUT);
 pinMode(LED_BUILTIN, OUTPUT);      // initialize the LED pin as an output:
  u8x8.begin();
    u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
    u8x8.setFont(u8x8_font_8x13B_1x2_r);
    u8x8.clearDisplay();
    u8x8.setCursor(0, 0);
    u8x8.print("Power ON ");
}

void startsound() {
  tone (buzzer, 890);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 800);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 800);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 990);
    delay (420);
    noTone(buzzer);
    delay (20);
}

void setLedRGB(bool red, bool green, bool blue) {
   if (!red) { digitalWrite(LEDR, HIGH); } else { digitalWrite(LEDR, LOW); }
   if (!green) { digitalWrite(LEDG, HIGH); } else { digitalWrite(LEDG, LOW); }
   if (!blue) { digitalWrite(LEDB, HIGH); } else { digitalWrite(LEDB, LOW); }
}
// END