|
| 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 | + We believe the NEO-D9C's I2C address should be 0x43 (like the NEO-D9S). But, reported by users in Japan, |
| 13 | + the initial NEO-D9C's use address 0x42 - which is the same as the ZED-F9P. |
| 14 | +
|
| 15 | + If you have one of the initial NEO-D9C's, the address 0x42 should work for you. |
| 16 | + If you have a newer or upgraded NEO-D9C, then you may need to change to 0x43. See line 100. |
| 17 | +
|
| 18 | + Also, again reported by users in Japan, the initial NEO-D9C's do not support UBX-CFG-PRT. |
| 19 | + The library uses UBX-CFG-PRT inside .begin (.isConnected) to check if the module is connected. |
| 20 | + This then fails with the initial NEO-D9C's. |
| 21 | + The work-around is to set the .begin assumeSuccess parameter to true. |
| 22 | + With newer NEO-D9C's this work-around may not be necessary. Again see line 100. |
| 23 | + |
| 24 | + Feel like supporting open source hardware? |
| 25 | + Buy a board from SparkFun! |
| 26 | + ZED-F9P RTK2: https://www.sparkfun.com/products/16481 |
| 27 | + NEO-D9S L-Band Correction Data Receiver: https://www.sparkfun.com/products/19390 |
| 28 | +
|
| 29 | + Hardware Connections: |
| 30 | + Use a Qwiic cable to connect the NEO-D9C QZSS-L6 corection data receiver to your board |
| 31 | + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) |
| 32 | + Open the serial monitor at 115200 baud to see the output |
| 33 | +*/ |
| 34 | + |
| 35 | +#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS |
| 36 | +SFE_UBLOX_GNSS myQZSS; // NEO-D9C |
| 37 | + |
| 38 | +#define OK(ok) (ok ? F(" -> OK") : F(" -> ERROR!")) // Convert uint8_t into OK/ERROR |
| 39 | + |
| 40 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 41 | + |
| 42 | +// Callback: printRXMQZSSL6 will be called when new QZSS-L6 data arrives |
| 43 | +// See u-blox_structs.h for the full definition of UBX_RXM_QZSSL6_message_data_t |
| 44 | +// _____ You can use any name you like for the callback. Use the same name when you call setRXMQZSSL6messageCallbackPtr |
| 45 | +// / _____ This _must_ be UBX_RXM_QZSSL6_message_data_t |
| 46 | +// | / _____ You can use any name you like for the struct |
| 47 | +// | | / |
| 48 | +// | | | |
| 49 | +void printRXMQZSSL6(UBX_RXM_QZSSL6_message_data_t *qzssL6Data) |
| 50 | +{ |
| 51 | + Serial.println(F("New QZSS-L6 data received:")); |
| 52 | + |
| 53 | + Serial.print(F("Message version: ")); |
| 54 | + Serial.println(qzssL6Data->payload[0]); |
| 55 | + |
| 56 | + Serial.print(F("Satellite Identifier: ")); |
| 57 | + Serial.println(qzssL6Data->payload[1]); |
| 58 | + |
| 59 | + Serial.print(F("Carrier / Noise: ")); |
| 60 | + double cno = (0.00390625 * ((double)qzssL6Data->payload[2])) + ((double)qzssL6Data->payload[3]); |
| 61 | + Serial.println(cno, 1); |
| 62 | + |
| 63 | + Serial.print(F("Bit Errors Corrected: ")); |
| 64 | + Serial.println(qzssL6Data->payload[9]); |
| 65 | + |
| 66 | + uint16_t chInfo = (((uint16_t)qzssL6Data->payload[11]) << 8) | qzssL6Data->payload[10]; |
| 67 | + uint16_t errStatus = ((chInfo >> 12) & 0x3); |
| 68 | + Serial.print(F("Receiver Channel: ")); |
| 69 | + Serial.println((chInfo >> 8) & 0x3); |
| 70 | + Serial.print(F("Message Name: L6")); |
| 71 | + Serial.println(((chInfo >> 10) & 0x1) == 0 ? F("D") : F("E")); |
| 72 | + Serial.print(F("Error Status: ")); |
| 73 | + if (errStatus == 1) |
| 74 | + Serial.println("error-free"); |
| 75 | + else if (errStatus == 2) |
| 76 | + Serial.println("erroneous"); |
| 77 | + else |
| 78 | + Serial.println("unknown"); |
| 79 | + Serial.print(F("Channel Name: ")); |
| 80 | + Serial.println(((chInfo >> 14) & 0x3) == 0 ? F("A") : F("B")); |
| 81 | + |
| 82 | + Serial.println(); |
| 83 | +} |
| 84 | + |
| 85 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 86 | + |
| 87 | +void setup() |
| 88 | +{ |
| 89 | + Serial.begin(115200); |
| 90 | + Serial.println(F("NEO-D9C Example")); |
| 91 | + |
| 92 | + Wire.begin(); //Start I2C |
| 93 | + |
| 94 | + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 95 | + // Begin and configure the NEO-D9C QZSS-L6 receiver |
| 96 | + |
| 97 | + //myQZSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial |
| 98 | + |
| 99 | + // For the initial NEO-D9C's: connect using address 0x42; set the assumeSuccess parameter to true |
| 100 | + while (myQZSS.begin(Wire, 0x42, 1100, true) == false) |
| 101 | + // For newer NEO-D9C's: use address 0x43; leave assumeSuccess set to false (default) |
| 102 | + //while (myQZSS.begin(Wire, 0x43) == false) |
| 103 | + { |
| 104 | + Serial.println(F("u-blox NEO-D9C not detected at selected I2C address. Please check wiring and I2C address.")); |
| 105 | + delay(2000); |
| 106 | + } |
| 107 | + Serial.println(F("u-blox NEO-D9C connected")); |
| 108 | + |
| 109 | + uint8_t ok = myQZSS.setVal(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_I2C, 1); // Output QZSS-L6 message on the I2C port |
| 110 | + |
| 111 | + Serial.print(F("QZSS-L6: I2C configuration ")); |
| 112 | + Serial.println(OK(ok)); |
| 113 | + |
| 114 | + if (ok) ok = myQZSS.setVal(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_UART1, 1); // Output QZSS-L6 message on UART1 |
| 115 | + if (ok) ok = myQZSS.setVal32(UBLOX_CFG_UART1_BAUDRATE, 38400); // Match UART1 baudrate with ZED |
| 116 | + |
| 117 | + Serial.print(F("QZSS-L6: UART1 configuration ")); |
| 118 | + Serial.println(OK(ok)); |
| 119 | + |
| 120 | + if (ok) ok = myQZSS.setVal(UBLOX_CFG_UART2OUTPROT_UBX, 1); // Enable UBX output on UART2 |
| 121 | + if (ok) ok = myQZSS.setVal(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_UART2, 1); // Output QZSS-L6 message on UART2 |
| 122 | + if (ok) ok = myQZSS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 38400); // Match UART2 baudrate with ZED |
| 123 | + |
| 124 | + Serial.print(F("QZSS-L6: UART2 configuration ")); |
| 125 | + Serial.println(OK(ok)); |
| 126 | + |
| 127 | + myQZSS.setRXMQZSSL6messageCallbackPtr(&printRXMQZSSL6); // Call printRXMQZSSL6 when new QZSS-L6 data arrives |
| 128 | +} |
| 129 | + |
| 130 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 131 | + |
| 132 | +void loop() |
| 133 | +{ |
| 134 | + myQZSS.checkUblox(); // Check for the arrival of new QZSS-L6 data and process it. |
| 135 | + myQZSS.checkCallbacks(); // Check if any QZSS-L6 callbacks are waiting to be processed. |
| 136 | +} |
0 commit comments