diff --git a/.arduino-ci.yml b/.arduino-ci.yml new file mode 100644 index 0000000..fe3d60a --- /dev/null +++ b/.arduino-ci.yml @@ -0,0 +1,26 @@ +packages: + arduino:megaavr: + url: https://downloads.arduino.cc/packages/package_index.json + +platforms: + + nano_every: + board: arduino:megaavr:nona4809 + package: arduino:megaavr + gcc: + features: + defines: + - MILLIS_USE_TIMERB3 + - NO_EXTERNAL_I2C_PULLUP + - AVR_NANO_4809_328MODE + warnings: + flags: + +compile: + # Choosing to run compilation tests on 2 different Arduino platforms + platforms: + - uno + - leonardo + - mega2560 + - cplayClassic + - nano_every diff --git a/.github/workflows/Arduino_CI.yml b/.github/workflows/Arduino_CI.yml new file mode 100644 index 0000000..eb53961 --- /dev/null +++ b/.github/workflows/Arduino_CI.yml @@ -0,0 +1,47 @@ +name: Arduino_CI + +on: [pull_request,push] + +jobs: + arduino_ci: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: Arduino-CI/action@stable-1.x # or latest, or a pinned version + env: + # Not all libraries are in the root directory of a repository. + # Specifying the path of the library here (relative to the root + # of the repository) will adjust that. + # + # The default is the current directory + # + USE_SUBDIR: . + + # Not all libraries include examples or unit tests. The default + # behavior of arduino_ci is to assume that "if the files don't + # exist, then they were not MEANT to exist". In other words, + # if you were to accidentally delete all your tests or example + # sketches, then the CI runner would by default assume that was + # intended and return a passing result. + # + # If you'd rather have the test runner fail the test in the + # absence of either tests or examples, uncommenting either of + # the following variables to 'true' (as appropriate) will + # enforce that. + # + EXPECT_EXAMPLES: true + + # Although dependencies will be installed automatically via the + # library manager, your library under test may require an + # unofficial version of a dependency. In those cases, the custom + # libraries must be insalled prior to the test execution; those + # installation commands should be placed in a shell script (that + # will be executed by /bin/sh) stored in your library. + # + # Then, set this variable to the path to that file (relative to + # the root of your repository). The script will be run from + # within the Arduino libraries directory; you should NOT attempt + # to find that directory nor change to it from within the script. + # + # CUSTOM_INIT_SCRIPT: install_dependencies.sh \ No newline at end of file diff --git a/README.md b/README.md index 5af0dfa..ace1d7e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ -# Whadda WPI430/VMA430 - GPS MODULE U-BLOX NEO-7M +# Whadda WPI430/VMA430 - GPS MODULE U-BLOX NEO-7M ![Arduino_CI](https://github.com/Whaddadraft/VMA430_GPS_Module/workflows/Arduino_CI/badge.svg) [![arduino-library-badge](https://www.ardu-badge.com/badge/WPI430-VMA430%20GPS.svg?)](https://www.ardu-badge.com/WPI430-VMA430%20GPS) + +![Whadda WPI430/VMA430 - GPS MODULE](https://www.velleman.eu/images/products/29/vma430.jpg) This repository contains the library and example code to work with our Whadda WPI430/VMA430 GPS MODULE with the U-BLOX NEO-7M chipset. It can configure the module to send out UBX data packets, and is able to decode the time and location data. +You can pick up a Whadda WPI430/VMA430 GPS module here: [whadda.com/product/gps-module-u-blox-neo-7m-for-arduino-vma430](https://whadda.com/product/gps-module-u-blox-neo-7m-for-arduino-vma430/) + ## Background info Most GPS modules output so called NMEA sentences that can be interpretted by a variety of programs. The Whadda WPI430 GPS module is also able to send data in the form of UBX packets, a custom protocol designed by U-Blox (the manufacturer of the GPS chipset on the module). @@ -9,16 +13,18 @@ UBX packets use a more compact data encoding algorithm which makes it faster to This library only uses the UBX packets to decode the data. +For more information, check the U-Blox Neo-7M datasheet [here](https://www.u-blox.com/sites/default/files/products/documents/NEO-7_DataSheet_%28UBX-13003830%29.pdf). + ## Installation 1. Download the most recent version of the Arduino library by clicking the ```Download ZIP``` option in the Code menu: -![](./images/download.jpg) +![](./extras/images/download.jpg) 2. Open the Arduino IDE, click on Sketch > Include Library > Add .ZIP Library... -![](./images/add_library.jpg) +![](./extras/images/add_library.jpg) 3. Open the .ZIP file you just downloaded, a message should appear in the Arduino IDE: "Library added to your libraries. Check "include library" menu." @@ -31,10 +37,16 @@ Wire up the GPS module to an Arduino compatible board as shown below: |----------|-------------| |VCC|5V| |GND|GND| -|TXD|D3| -|RXD|D2| +|TXD|D11| +|RXD|D10| + +![](./extras/images/wiring_diagram.png) + +**Note:** The library uses a SoftwareSerial port to communicate with the GPS module. The default pin layout should be compatible with Arduino Uno, Mega, Leonardo, and Micro compatible boards. Other Arduino models may have different restrictions on the pins that can be used for this purpose. Check the limitations section of the SoftwareSerial Arduino site page (https://www.arduino.cc/en/Reference/softwareSerial) to find out which pins can be used on your particular Arduino board model. You can change the pins that are used by the library by altering the following line of code: -![](./images/wiring_diagram.png) +```Cpp +SoftwareSerial ss(11, 10); // RX, TX +``` ### Programming @@ -45,4 +57,4 @@ Wire up the GPS module to an Arduino compatible board as shown below: The example program will first set-up the GPS-module by setting it's communication protocols. It will enable the module to send out UBX messages next to the standard NMEA messages that it normally outputs. The program will then decode these UBX messages, and show the parsed output. The data that is sent out includes location data (latitude & longitude) and UTC time (hours, minutes & seconds). -**NOTE**: The GPS module's built-in antenna is only designed to work **outdoors**. You will probably not get valid time and location data if you test this example indoors. You might be able to get reception after a few minutes if you put the GPS antenna close to a window, pointed towards the sky. \ No newline at end of file +**NOTE**: The GPS module's built-in antenna is only designed to work **outdoors**. You will probably not get valid time and location data if you test this example indoors. You might be able to get reception after a few minutes if you put the GPS antenna close to a window, pointed towards the sky. diff --git a/README.txt b/README.txt deleted file mode 100644 index fedfd5c..0000000 --- a/README.txt +++ /dev/null @@ -1 +0,0 @@ -This repository contains the library and example code to work with our VMA430 - gPS MODULE U-BLOX NEO-7M \ No newline at end of file diff --git a/examples/Show_time_location/Show_time_location.ino b/examples/Show_time_location/Show_time_location.ino index 46af708..c2f04c3 100644 --- a/examples/Show_time_location/Show_time_location.ino +++ b/examples/Show_time_location/Show_time_location.ino @@ -28,7 +28,7 @@ #include // Include the GPS module library #include // Include the software serial library -SoftwareSerial ss(3, 2); // RX, TX +SoftwareSerial ss(11, 10); // RX, TX VMA430_GPS gps(&ss); // Pass the softwareserial connection info the the GPS module library void setup() diff --git a/images/add_library.jpg b/extras/images/add_library.jpg similarity index 100% rename from images/add_library.jpg rename to extras/images/add_library.jpg diff --git a/images/download.jpg b/extras/images/download.jpg similarity index 100% rename from images/download.jpg rename to extras/images/download.jpg diff --git a/extras/images/wiring_diagram.png b/extras/images/wiring_diagram.png new file mode 100644 index 0000000..8217e1d Binary files /dev/null and b/extras/images/wiring_diagram.png differ diff --git a/images/wiring_diagram.png b/images/wiring_diagram.png deleted file mode 100644 index b0b82a9..0000000 Binary files a/images/wiring_diagram.png and /dev/null differ diff --git a/keywords.txt b/keywords.txt new file mode 100644 index 0000000..cb5fa12 --- /dev/null +++ b/keywords.txt @@ -0,0 +1,15 @@ +# Syntax Coloring Map For VMA430_GPS library + +# Datatypes (KEYWORD1) +VMA430_GPS KEYWORD1 + +# Methods and Functions (KEYWORD2) +begin KEYWORD2 +setUBXNav KEYWORD2 +getUBX_packet KEYWORD2 +parse_ubx_data KEYWORD2 + +# Instances (KEYWORD2) +utc_time KEYWORD3 + +# Constants (LITERAL1) \ No newline at end of file diff --git a/library.properties b/library.properties index d0893bc..73c1860 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,10 @@ -name=WPI430/VMA430 GPS +name=WPI430-VMA430 GPS version=2.0.0 -author=Velleman nv -maintainer=Velleman nv -sentence=Velleman WPI430/VMA430 GPS module library -paragraph=Velleman VMA430 GPS MODULE U-BLOX NEO-7M +author=Velleman nv +maintainer=Velleman nv +sentence=Velleman WPI430-VMA430 GPS module library +paragraph=decodes and parses location and time data category=Sensors url=https://github.com/Velleman/VMA430_GPS_Module architectures=* +includes=VMA430_GPS.h diff --git a/src/VMA430_GPS.cpp b/src/VMA430_GPS.cpp index cd2f08e..788d0eb 100644 --- a/src/VMA430_GPS.cpp +++ b/src/VMA430_GPS.cpp @@ -535,7 +535,7 @@ bool VMA430_GPS::parse_nav_pos(void) { bool successfull_parsing = false; - uint64_t temp_lon = 0, temp_lat = 0; + int32_t temp_lon = 0, temp_lat = 0; double longitude = 0.0; double latitude = 0.0; uint32_t temp_val = 0; @@ -547,20 +547,10 @@ bool VMA430_GPS::parse_nav_pos(void) return false; } - for(int j = 0; j<4; j++) - { - temp_val = msg_data[4+j]; - temp_lon |= (temp_val << 8*j); - } - //temp_lon = (msg_data[8]) | (msg_data[9] << 8) | (uint32_t)(msg_data[10] << 16) | (uint32_t)(msg_data[11] << 24); + temp_lon = extractSignedLong(4, msg_data); longitude = (double)temp_lon*0.0000001; - for(int j = 0; j<4; j++) - { - temp_val = msg_data[8+j]; - temp_lat |= (temp_val << 8*j); - } - //temp_lon = (msg_data[8]) | (msg_data[9] << 8) | (uint32_t)(msg_data[10] << 16) | (uint32_t)(msg_data[11] << 24); + temp_lat = extractSignedLong(8, msg_data); latitude = (double)temp_lat*0.0000001; location.latitude = latitude; @@ -626,6 +616,29 @@ byte VMA430_GPS::getUBX_ACK(byte *msgID) } } +uint32_t VMA430_GPS::extractLong(uint8_t spotToStart, byte* msg_data) +{ + uint32_t val = 0; + val |= (uint32_t)msg_data[spotToStart + 0] << 8 * 0; + val |= (uint32_t)msg_data[spotToStart + 1] << 8 * 1; + val |= (uint32_t)msg_data[spotToStart + 2] << 8 * 2; + val |= (uint32_t)msg_data[spotToStart + 3] << 8 * 3; + return (val); +} + +//Just so there is no ambiguity about whether a uint32_t will cast to a int32_t correctly... +int32_t VMA430_GPS::extractSignedLong(uint8_t spotToStart, byte* msg_data) +{ + union // Use a union to convert from uint32_t to int32_t + { + uint32_t unsignedLong; + int32_t signedLong; + } unsignedSigned; + + unsignedSigned.unsignedLong = extractLong(spotToStart, msg_data); + return (unsignedSigned.signedLong); +} + void VMA430_GPS::calcChecksum(byte *checksumPayload, byte payloadSize) { byte CK_A = 0, CK_B = 0; diff --git a/src/VMA430_GPS.h b/src/VMA430_GPS.h index 9565481..1b01893 100644 --- a/src/VMA430_GPS.h +++ b/src/VMA430_GPS.h @@ -114,6 +114,8 @@ class VMA430_GPS { bool parse_nav_pos(void); byte getUBX_ACK(byte *); + uint32_t extractLong(uint8_t, byte*); + int32_t extractSignedLong(uint8_t, byte*); long portRate; Stream *stream = NULL;