Here you have a snippet from the declaration and setup section of my GPS sketch. You can see I define the strings first and then use serial write to send them. GPS module is connected to the hardware serial port.
Note that I am turning off all NMEA sentences and then turn on only the UBLOX "PVT" sentence (PVT contains all the info I need), with increased refreshrate and set the GPS module to airborne mode.
//format hex command strings for sending to UBLOX
const static char PROGMEM airborne[] = {0xb5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xff, 0xff, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27,
0x00, 0x00, 0x05, 0x00, 0xfa, 0x00, 0xfa, 0x00, 0x64, 0x00, 0x2c, 0x01, 0x00, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x0b, 0xb5, 0x62, 0x06, 0x24,
0x00, 0x00, 0x2a, 0x84
};
const static char PROGMEM hnr[] = {0xB5, 0x62, 0x06, 0x5C, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6B, 0xE0}; // high nav rate to 5Hz
const static char PROGMEM rate[] = {0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xC8, 0x00, 0x01, 0x00, 0x01, 0x00, 0xDE, 0x6A}; // output at 5 Hz
const static char PROGMEM pvt[] = {0xb5, 0x62, 0x06, 0x01, 0x03, 0x00, 0x01, 0x07, 0x01, 0x13, 0x51}; // activate PVT sentence
#define GPS_INFO_BUFFER_SIZE 100 // enough for the strings (PVT is 100 long)
byte GPS_info_buffer[GPS_INFO_BUFFER_SIZE];
byte string_length = 98; //PVT is 100 Initialize with longest string.
unsigned int received_char;
int i = 0; // counter
bool message_started = false;
long velN;
long velE;
long velD;
unsigned long velocity_3d; // speed in centimeter / second
unsigned long spd_kts; //speed in knots
long longitude ;//longitude
long latitude ;//latitude
long height_above_sea_level;//height above main sea level
unsigned long ground_speed ;
unsigned long heading;
//CHECKSUM CALCULATION VARIABLE
unsigned char CK_A = 0;
unsigned char CK_B = 0;
byte sendlat = 0; // toggle to send either latitude or longitude in same field
byte fixok = 0; // flag to indicate a valid GPS fix was received.
byte fixcount = 0; // count how many OK GPS fixes we have in a row.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite (LED_BUILTIN, HIGH); // signal led on, to test
delay(2000); // wait for GPS to boot.
Serial.begin(9600);
delay(100);
// turn off all NMEA sentences first
Serial.println(F("$PUBX,40,RMC,0,0,0,0*47")); //RMC OFF
delay(100);
Serial.println(F("$PUBX,40,VTG,0,0,0,0*5E")); //VTG OFF
delay(100);
Serial.println(F("$PUBX,40,GGA,0,0,0,0*5A")); //GGA OFF
delay(100);
Serial.println(F("$PUBX,40,GSA,0,0,0,0*4E")); //GSA OFF
delay(100);
Serial.println(F("$PUBX,40,GSV,0,0,0,0*59")); //GSV OFF
delay(100);
Serial.println(F("$PUBX,40,GLL,0,0,0,0*5C")); //GLL OFF
delay(100);
Serial.write(airborne, sizeof(airborne)); //set GPS mode to airborne < 4g
delay(100);
Serial.write(hnr, sizeof(hnr)); //set GPS update rate to 4Hz (1st string)
delay(100);
Serial.write(rate, sizeof(rate)); //set GPS update rate to 4Hz (2nd string)
delay(100);
Serial.write(pvt, sizeof(pvt)); // PVT Navigation Position Velocity Time Solution message ON
delay(100);
digitalWrite (13, LOW); // signal led off, end setup
} // end setup