|
| 1 | +/* |
| 2 | + NEO-D9C QZSS-L6 receiver example |
| 3 | + By: SparkFun Electronics / Paul Clark |
| 4 | + Date: September 23rd, 2022 |
| 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 display a summary of the NEO-D9C's UBX-RXM-QZSSL6 data. |
| 9 | + It also enables UBX-RXM-QZSSL6 message output on both UART1 and UART2 at 38400 baud |
| 10 | + so you can feed the corrections directly to (e.g.) a ZED-F9P. |
| 11 | +
|
| 12 | + It is not clear if the NEO-D9C's default I2C address is 0x43 or 0x42. It may depend |
| 13 | + on what firmware version is installed. If the NEO-D9C is not detected at 0x43, please |
| 14 | + try 0x42. (Please note: the ZED-F9P's default address is also 0x42) |
| 15 | +
|
| 16 | + Feel like supporting open source hardware? |
| 17 | + Buy a board from SparkFun! |
| 18 | + ZED-F9P RTK2: https://www.sparkfun.com/products/16481 |
| 19 | + NEO-D9S L-Band Correction Data Receiver: https://www.sparkfun.com/products/19390 |
| 20 | +
|
| 21 | + Hardware Connections: |
| 22 | + Use a Qwiic cable to connect the NEO-D9C QZSS-L6 corection data receiver to your board |
| 23 | + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) |
| 24 | + Open the serial monitor at 115200 baud to see the output |
| 25 | +*/ |
| 26 | + |
| 27 | +#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS |
| 28 | +SFE_UBLOX_GNSS myQZSS; // NEO-D9C |
| 29 | + |
| 30 | +#define OK(ok) (ok ? F(" -> OK") : F(" -> ERROR!")) // Convert uint8_t into OK/ERROR |
| 31 | + |
| 32 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 33 | + |
| 34 | +// Callback: printRXMQZSSL6 will be called when new QZSS-L6 data arrives |
| 35 | +// See u-blox_structs.h for the full definition of UBX_RXM_QZSSL6_message_data_t |
| 36 | +// _____ You can use any name you like for the callback. Use the same name when you call setRXMPMPcallbackPtr |
| 37 | +// / _____ This _must_ be UBX_RXM_QZSSL6_message_data_t |
| 38 | +// | / _____ You can use any name you like for the struct |
| 39 | +// | | / |
| 40 | +// | | | |
| 41 | +void printRXMQZSSL6(UBX_RXM_QZSSL6_message_data_t *qzssL6Data) |
| 42 | +{ |
| 43 | + Serial.println(F("New QZSS-L6 data received:")); |
| 44 | + |
| 45 | + Serial.print(F("Message version: ")); |
| 46 | + Serial.println(qzssL6Data->payload[0]); |
| 47 | + |
| 48 | + Serial.print(F("Satellite Identifier: ")); |
| 49 | + Serial.println(qzssL6Data->payload[1]); |
| 50 | + |
| 51 | + Serial.print(F("Carrier / Noise: ")); |
| 52 | + double cno = (0.00390625 * ((double)qzssL6Data->payload[2])) + ((double)qzssL6Data->payload[3]); |
| 53 | + Serial.println(cno, 1); |
| 54 | + |
| 55 | + Serial.print(F("Bit Errors Corrected: ")); |
| 56 | + Serial.println(qzssL6Data->payload[9]); |
| 57 | + |
| 58 | + uint16_t chInfo = (((uint16_t)qzssL6Data->payload[11]) << 8) | qzssL6Data->payload[10]; |
| 59 | + uint16_t errStatus = ((chInfo >> 12) & 0x3); |
| 60 | + Serial.print(F("Receiver Channel: ")); |
| 61 | + Serial.println((chInfo >> 8) & 0x3); |
| 62 | + Serial.print(F("Message Name: L6")); |
| 63 | + Serial.println(((chInfo >> 10) & 0x1) == 0 ? F("D") : F("E")); |
| 64 | + Serial.print(F("Error Status: ")); |
| 65 | + if (errStatus == 1) |
| 66 | + Serial.println("error-free"); |
| 67 | + else if (errStatus == 2) |
| 68 | + Serial.println("erroneous"); |
| 69 | + else |
| 70 | + Serial.println("unknown"); |
| 71 | + Serial.print(F("Channel Name: ")); |
| 72 | + Serial.println(((chInfo >> 14) & 0x3) == 0 ? F("A") : F("B")); |
| 73 | + |
| 74 | + Serial.println(); |
| 75 | +} |
| 76 | + |
| 77 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 78 | + |
| 79 | +void setup() |
| 80 | +{ |
| 81 | + Serial.begin(115200); |
| 82 | + Serial.println(F("NEO-D9C Example")); |
| 83 | + |
| 84 | + Wire.begin(); //Start I2C |
| 85 | + |
| 86 | + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 87 | + // Begin and configure the NEO-D9C QZSS-L6 receiver |
| 88 | + |
| 89 | + //myQZSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial |
| 90 | + |
| 91 | + while (myQZSS.begin(Wire, 0x43) == false) //Connect to the u-blox NEO-D9C using Wire port. If 0x43 does not work, try 0x42 |
| 92 | + { |
| 93 | + Serial.println(F("u-blox NEO-D9C not detected at selected I2C address. Please check wiring and I2C address.")); |
| 94 | + delay(2000); |
| 95 | + } |
| 96 | + Serial.println(F("u-blox NEO-D9C connected")); |
| 97 | + |
| 98 | + uint8_t ok = myQZSS.setVal(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_I2C, 1); // Output QZSS-L6 message on the I2C port |
| 99 | + if (ok) ok = myQZSS.setVal(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_UART1, 1); // Output QZSS-L6 message on UART1 |
| 100 | + if (ok) ok = myQZSS.setVal32(UBLOX_CFG_UART1_BAUDRATE, 38400); // Match UART1 baudrate with ZED |
| 101 | + if (ok) ok = myQZSS.setVal(UBLOX_CFG_UART2OUTPROT_UBX, 1); // Enable UBX output on UART2 |
| 102 | + if (ok) ok = myQZSS.setVal(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_UART2, 1); // Output QZSS-L6 message on UART2 |
| 103 | + if (ok) ok = myQZSS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 38400); // Match UART2 baudrate with ZED |
| 104 | + |
| 105 | + Serial.print(F("QZSS-L6: configuration ")); |
| 106 | + Serial.println(OK(ok)); |
| 107 | + |
| 108 | + myQZSS.setRXMQZSSL6messageCallbackPtr(&printRXMQZSSL6); // Call printRXMQZSSL6 when new QZSS-L6 data arrives |
| 109 | +} |
| 110 | + |
| 111 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 112 | + |
| 113 | +void loop() |
| 114 | +{ |
| 115 | + myQZSS.checkUblox(); // Check for the arrival of new QZSS-L6 data and process it. |
| 116 | + myQZSS.checkCallbacks(); // Check if any QZSS-L6 callbacks are waiting to be processed. |
| 117 | +} |
0 commit comments