first commit
This commit is contained in:
46
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit BusIO/.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit BusIO/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
26
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit BusIO/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit BusIO/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
32
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit BusIO/.github/workflows/githubci.yml
vendored
Normal file
32
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit BusIO/.github/workflows/githubci.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms zero feather32u4
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit Bus IO Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
@ -0,0 +1 @@
|
||||
{"type": "library", "name": "Adafruit BusIO", "version": "1.11.4", "spec": {"owner": "adafruit", "id": 6214, "name": "Adafruit BusIO", "requirements": null, "url": null}}
|
@ -0,0 +1,365 @@
|
||||
#include <Adafruit_BusIO_Register.h>
|
||||
|
||||
#if !defined(SPI_INTERFACES_COUNT) || \
|
||||
(defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
|
||||
|
||||
/*!
|
||||
* @brief Create a register we access over an I2C Device (which defines the
|
||||
* bus and address)
|
||||
* @param i2cdevice The I2CDevice to use for underlying I2C access
|
||||
* @param reg_addr The address pointer value for the I2C/SMBus register, can
|
||||
* be 8 or 16 bits
|
||||
* @param width The width of the register data itself, defaults to 1 byte
|
||||
* @param byteorder The byte order of the register (used when width is > 1),
|
||||
* defaults to LSBFIRST
|
||||
* @param address_width The width of the register address itself, defaults
|
||||
* to 1 byte
|
||||
*/
|
||||
Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice,
|
||||
uint16_t reg_addr,
|
||||
uint8_t width,
|
||||
uint8_t byteorder,
|
||||
uint8_t address_width) {
|
||||
_i2cdevice = i2cdevice;
|
||||
_spidevice = nullptr;
|
||||
_addrwidth = address_width;
|
||||
_address = reg_addr;
|
||||
_byteorder = byteorder;
|
||||
_width = width;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Create a register we access over an SPI Device (which defines the
|
||||
* bus and CS pin)
|
||||
* @param spidevice The SPIDevice to use for underlying SPI access
|
||||
* @param reg_addr The address pointer value for the SPI register, can
|
||||
* be 8 or 16 bits
|
||||
* @param type The method we use to read/write data to SPI (which is not
|
||||
* as well defined as I2C)
|
||||
* @param width The width of the register data itself, defaults to 1 byte
|
||||
* @param byteorder The byte order of the register (used when width is > 1),
|
||||
* defaults to LSBFIRST
|
||||
* @param address_width The width of the register address itself, defaults
|
||||
* to 1 byte
|
||||
*/
|
||||
Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice,
|
||||
uint16_t reg_addr,
|
||||
Adafruit_BusIO_SPIRegType type,
|
||||
uint8_t width,
|
||||
uint8_t byteorder,
|
||||
uint8_t address_width) {
|
||||
_spidevice = spidevice;
|
||||
_spiregtype = type;
|
||||
_i2cdevice = nullptr;
|
||||
_addrwidth = address_width;
|
||||
_address = reg_addr;
|
||||
_byteorder = byteorder;
|
||||
_width = width;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Create a register we access over an I2C or SPI Device. This is a
|
||||
* handy function because we can pass in nullptr for the unused interface,
|
||||
* allowing libraries to mass-define all the registers
|
||||
* @param i2cdevice The I2CDevice to use for underlying I2C access, if
|
||||
* nullptr we use SPI
|
||||
* @param spidevice The SPIDevice to use for underlying SPI access, if
|
||||
* nullptr we use I2C
|
||||
* @param reg_addr The address pointer value for the I2C/SMBus/SPI register,
|
||||
* can be 8 or 16 bits
|
||||
* @param type The method we use to read/write data to SPI (which is not
|
||||
* as well defined as I2C)
|
||||
* @param width The width of the register data itself, defaults to 1 byte
|
||||
* @param byteorder The byte order of the register (used when width is > 1),
|
||||
* defaults to LSBFIRST
|
||||
* @param address_width The width of the register address itself, defaults
|
||||
* to 1 byte
|
||||
*/
|
||||
Adafruit_BusIO_Register::Adafruit_BusIO_Register(
|
||||
Adafruit_I2CDevice *i2cdevice, Adafruit_SPIDevice *spidevice,
|
||||
Adafruit_BusIO_SPIRegType type, uint16_t reg_addr, uint8_t width,
|
||||
uint8_t byteorder, uint8_t address_width) {
|
||||
_spidevice = spidevice;
|
||||
_i2cdevice = i2cdevice;
|
||||
_spiregtype = type;
|
||||
_addrwidth = address_width;
|
||||
_address = reg_addr;
|
||||
_byteorder = byteorder;
|
||||
_width = width;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write a buffer of data to the register location
|
||||
* @param buffer Pointer to data to write
|
||||
* @param len Number of bytes to write
|
||||
* @return True on successful write (only really useful for I2C as SPI is
|
||||
* uncheckable)
|
||||
*/
|
||||
bool Adafruit_BusIO_Register::write(uint8_t *buffer, uint8_t len) {
|
||||
|
||||
uint8_t addrbuffer[2] = {(uint8_t)(_address & 0xFF),
|
||||
(uint8_t)(_address >> 8)};
|
||||
|
||||
if (_i2cdevice) {
|
||||
return _i2cdevice->write(buffer, len, true, addrbuffer, _addrwidth);
|
||||
}
|
||||
if (_spidevice) {
|
||||
if (_spiregtype == ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE) {
|
||||
// very special case!
|
||||
|
||||
// pass the special opcode address which we set as the high byte of the
|
||||
// regaddr
|
||||
addrbuffer[0] =
|
||||
(uint8_t)(_address >> 8) & ~0x01; // set bottom bit low to write
|
||||
// the 'actual' reg addr is the second byte then
|
||||
addrbuffer[1] = (uint8_t)(_address & 0xFF);
|
||||
// the address appears to be a byte longer
|
||||
return _spidevice->write(buffer, len, addrbuffer, _addrwidth + 1);
|
||||
}
|
||||
|
||||
if (_spiregtype == ADDRBIT8_HIGH_TOREAD) {
|
||||
addrbuffer[0] &= ~0x80;
|
||||
}
|
||||
if (_spiregtype == ADDRBIT8_HIGH_TOWRITE) {
|
||||
addrbuffer[0] |= 0x80;
|
||||
}
|
||||
if (_spiregtype == AD8_HIGH_TOREAD_AD7_HIGH_TOINC) {
|
||||
addrbuffer[0] &= ~0x80;
|
||||
addrbuffer[0] |= 0x40;
|
||||
}
|
||||
return _spidevice->write(buffer, len, addrbuffer, _addrwidth);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write up to 4 bytes of data to the register location
|
||||
* @param value Data to write
|
||||
* @param numbytes How many bytes from 'value' to write
|
||||
* @return True on successful write (only really useful for I2C as SPI is
|
||||
* uncheckable)
|
||||
*/
|
||||
bool Adafruit_BusIO_Register::write(uint32_t value, uint8_t numbytes) {
|
||||
if (numbytes == 0) {
|
||||
numbytes = _width;
|
||||
}
|
||||
if (numbytes > 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// store a copy
|
||||
_cached = value;
|
||||
|
||||
for (int i = 0; i < numbytes; i++) {
|
||||
if (_byteorder == LSBFIRST) {
|
||||
_buffer[i] = value & 0xFF;
|
||||
} else {
|
||||
_buffer[numbytes - i - 1] = value & 0xFF;
|
||||
}
|
||||
value >>= 8;
|
||||
}
|
||||
return write(_buffer, numbytes);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read data from the register location. This does not do any error
|
||||
* checking!
|
||||
* @return Returns 0xFFFFFFFF on failure, value otherwise
|
||||
*/
|
||||
uint32_t Adafruit_BusIO_Register::read(void) {
|
||||
if (!read(_buffer, _width)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t value = 0;
|
||||
|
||||
for (int i = 0; i < _width; i++) {
|
||||
value <<= 8;
|
||||
if (_byteorder == LSBFIRST) {
|
||||
value |= _buffer[_width - i - 1];
|
||||
} else {
|
||||
value |= _buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read cached data from last time we wrote to this register
|
||||
* @return Returns 0xFFFFFFFF on failure, value otherwise
|
||||
*/
|
||||
uint32_t Adafruit_BusIO_Register::readCached(void) { return _cached; }
|
||||
|
||||
/*!
|
||||
* @brief Read a buffer of data from the register location
|
||||
* @param buffer Pointer to data to read into
|
||||
* @param len Number of bytes to read
|
||||
* @return True on successful write (only really useful for I2C as SPI is
|
||||
* uncheckable)
|
||||
*/
|
||||
bool Adafruit_BusIO_Register::read(uint8_t *buffer, uint8_t len) {
|
||||
uint8_t addrbuffer[2] = {(uint8_t)(_address & 0xFF),
|
||||
(uint8_t)(_address >> 8)};
|
||||
|
||||
if (_i2cdevice) {
|
||||
return _i2cdevice->write_then_read(addrbuffer, _addrwidth, buffer, len);
|
||||
}
|
||||
if (_spidevice) {
|
||||
if (_spiregtype == ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE) {
|
||||
// very special case!
|
||||
|
||||
// pass the special opcode address which we set as the high byte of the
|
||||
// regaddr
|
||||
addrbuffer[0] =
|
||||
(uint8_t)(_address >> 8) | 0x01; // set bottom bit high to read
|
||||
// the 'actual' reg addr is the second byte then
|
||||
addrbuffer[1] = (uint8_t)(_address & 0xFF);
|
||||
// the address appears to be a byte longer
|
||||
return _spidevice->write_then_read(addrbuffer, _addrwidth + 1, buffer,
|
||||
len);
|
||||
}
|
||||
if (_spiregtype == ADDRBIT8_HIGH_TOREAD) {
|
||||
addrbuffer[0] |= 0x80;
|
||||
}
|
||||
if (_spiregtype == ADDRBIT8_HIGH_TOWRITE) {
|
||||
addrbuffer[0] &= ~0x80;
|
||||
}
|
||||
if (_spiregtype == AD8_HIGH_TOREAD_AD7_HIGH_TOINC) {
|
||||
addrbuffer[0] |= 0x80 | 0x40;
|
||||
}
|
||||
return _spidevice->write_then_read(addrbuffer, _addrwidth, buffer, len);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read 2 bytes of data from the register location
|
||||
* @param value Pointer to uint16_t variable to read into
|
||||
* @return True on successful write (only really useful for I2C as SPI is
|
||||
* uncheckable)
|
||||
*/
|
||||
bool Adafruit_BusIO_Register::read(uint16_t *value) {
|
||||
if (!read(_buffer, 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_byteorder == LSBFIRST) {
|
||||
*value = _buffer[1];
|
||||
*value <<= 8;
|
||||
*value |= _buffer[0];
|
||||
} else {
|
||||
*value = _buffer[0];
|
||||
*value <<= 8;
|
||||
*value |= _buffer[1];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read 1 byte of data from the register location
|
||||
* @param value Pointer to uint8_t variable to read into
|
||||
* @return True on successful write (only really useful for I2C as SPI is
|
||||
* uncheckable)
|
||||
*/
|
||||
bool Adafruit_BusIO_Register::read(uint8_t *value) {
|
||||
if (!read(_buffer, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*value = _buffer[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Pretty printer for this register
|
||||
* @param s The Stream to print to, defaults to &Serial
|
||||
*/
|
||||
void Adafruit_BusIO_Register::print(Stream *s) {
|
||||
uint32_t val = read();
|
||||
s->print("0x");
|
||||
s->print(val, HEX);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Pretty printer for this register
|
||||
* @param s The Stream to print to, defaults to &Serial
|
||||
*/
|
||||
void Adafruit_BusIO_Register::println(Stream *s) {
|
||||
print(s);
|
||||
s->println();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Create a slice of the register that we can address without
|
||||
* touching other bits
|
||||
* @param reg The Adafruit_BusIO_Register which defines the bus/register
|
||||
* @param bits The number of bits wide we are slicing
|
||||
* @param shift The number of bits that our bit-slice is shifted from LSB
|
||||
*/
|
||||
Adafruit_BusIO_RegisterBits::Adafruit_BusIO_RegisterBits(
|
||||
Adafruit_BusIO_Register *reg, uint8_t bits, uint8_t shift) {
|
||||
_register = reg;
|
||||
_bits = bits;
|
||||
_shift = shift;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read 4 bytes of data from the register
|
||||
* @return data The 4 bytes to read
|
||||
*/
|
||||
uint32_t Adafruit_BusIO_RegisterBits::read(void) {
|
||||
uint32_t val = _register->read();
|
||||
val >>= _shift;
|
||||
return val & ((1 << (_bits)) - 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write 4 bytes of data to the register
|
||||
* @param data The 4 bytes to write
|
||||
* @return True on successful write (only really useful for I2C as SPI is
|
||||
* uncheckable)
|
||||
*/
|
||||
bool Adafruit_BusIO_RegisterBits::write(uint32_t data) {
|
||||
uint32_t val = _register->read();
|
||||
|
||||
// mask off the data before writing
|
||||
uint32_t mask = (1 << (_bits)) - 1;
|
||||
data &= mask;
|
||||
|
||||
mask <<= _shift;
|
||||
val &= ~mask; // remove the current data at that spot
|
||||
val |= data << _shift; // and add in the new data
|
||||
|
||||
return _register->write(val, _register->width());
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief The width of the register data, helpful for doing calculations
|
||||
* @returns The data width used when initializing the register
|
||||
*/
|
||||
uint8_t Adafruit_BusIO_Register::width(void) { return _width; }
|
||||
|
||||
/*!
|
||||
* @brief Set the default width of data
|
||||
* @param width the default width of data read from register
|
||||
*/
|
||||
void Adafruit_BusIO_Register::setWidth(uint8_t width) { _width = width; }
|
||||
|
||||
/*!
|
||||
* @brief Set register address
|
||||
* @param address the address from register
|
||||
*/
|
||||
void Adafruit_BusIO_Register::setAddress(uint16_t address) {
|
||||
_address = address;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set the width of register address
|
||||
* @param address_width the width for register address
|
||||
*/
|
||||
void Adafruit_BusIO_Register::setAddressWidth(uint16_t address_width) {
|
||||
_addrwidth = address_width;
|
||||
}
|
||||
|
||||
#endif // SPI exists
|
@ -0,0 +1,105 @@
|
||||
#ifndef Adafruit_BusIO_Register_h
|
||||
#define Adafruit_BusIO_Register_h
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(SPI_INTERFACES_COUNT) || \
|
||||
(defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
|
||||
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
typedef enum _Adafruit_BusIO_SPIRegType {
|
||||
ADDRBIT8_HIGH_TOREAD = 0,
|
||||
/*!<
|
||||
* ADDRBIT8_HIGH_TOREAD
|
||||
* When reading a register you must actually send the value 0x80 + register
|
||||
* address to the device. e.g. To read the register 0x0B the register value
|
||||
* 0x8B is sent and to write 0x0B is sent.
|
||||
*/
|
||||
AD8_HIGH_TOREAD_AD7_HIGH_TOINC = 1,
|
||||
|
||||
/*!<
|
||||
* ADDRBIT8_HIGH_TOWRITE
|
||||
* When writing to a register you must actually send the value 0x80 +
|
||||
* the register address to the device. e.g. To write to the register 0x19 the
|
||||
* register value 0x99 is sent and to read 0x19 is sent.
|
||||
*/
|
||||
ADDRBIT8_HIGH_TOWRITE = 2,
|
||||
|
||||
/*!<
|
||||
* ADDRESSED_OPCODE_LOWBIT_TO_WRITE
|
||||
* Used by the MCP23S series, we send 0x40 |'rd with the opcode
|
||||
* Then set the lowest bit to write
|
||||
*/
|
||||
ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE = 3,
|
||||
|
||||
} Adafruit_BusIO_SPIRegType;
|
||||
|
||||
/*!
|
||||
* @brief The class which defines a device register (a location to read/write
|
||||
* data from)
|
||||
*/
|
||||
class Adafruit_BusIO_Register {
|
||||
public:
|
||||
Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice, uint16_t reg_addr,
|
||||
uint8_t width = 1, uint8_t byteorder = LSBFIRST,
|
||||
uint8_t address_width = 1);
|
||||
|
||||
Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice, uint16_t reg_addr,
|
||||
Adafruit_BusIO_SPIRegType type, uint8_t width = 1,
|
||||
uint8_t byteorder = LSBFIRST,
|
||||
uint8_t address_width = 1);
|
||||
|
||||
Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice,
|
||||
Adafruit_SPIDevice *spidevice,
|
||||
Adafruit_BusIO_SPIRegType type, uint16_t reg_addr,
|
||||
uint8_t width = 1, uint8_t byteorder = LSBFIRST,
|
||||
uint8_t address_width = 1);
|
||||
|
||||
bool read(uint8_t *buffer, uint8_t len);
|
||||
bool read(uint8_t *value);
|
||||
bool read(uint16_t *value);
|
||||
uint32_t read(void);
|
||||
uint32_t readCached(void);
|
||||
bool write(uint8_t *buffer, uint8_t len);
|
||||
bool write(uint32_t value, uint8_t numbytes = 0);
|
||||
|
||||
uint8_t width(void);
|
||||
|
||||
void setWidth(uint8_t width);
|
||||
void setAddress(uint16_t address);
|
||||
void setAddressWidth(uint16_t address_width);
|
||||
|
||||
void print(Stream *s = &Serial);
|
||||
void println(Stream *s = &Serial);
|
||||
|
||||
private:
|
||||
Adafruit_I2CDevice *_i2cdevice;
|
||||
Adafruit_SPIDevice *_spidevice;
|
||||
Adafruit_BusIO_SPIRegType _spiregtype;
|
||||
uint16_t _address;
|
||||
uint8_t _width, _addrwidth, _byteorder;
|
||||
uint8_t _buffer[4]; // we won't support anything larger than uint32 for
|
||||
// non-buffered read
|
||||
uint32_t _cached = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief The class which defines a slice of bits from within a device register
|
||||
* (a location to read/write data from)
|
||||
*/
|
||||
class Adafruit_BusIO_RegisterBits {
|
||||
public:
|
||||
Adafruit_BusIO_RegisterBits(Adafruit_BusIO_Register *reg, uint8_t bits,
|
||||
uint8_t shift);
|
||||
bool write(uint32_t value);
|
||||
uint32_t read(void);
|
||||
|
||||
private:
|
||||
Adafruit_BusIO_Register *_register;
|
||||
uint8_t _bits, _shift;
|
||||
};
|
||||
|
||||
#endif // SPI exists
|
||||
#endif // BusIO_Register_h
|
@ -0,0 +1,270 @@
|
||||
#include "Adafruit_I2CDevice.h"
|
||||
|
||||
//#define DEBUG_SERIAL Serial
|
||||
|
||||
/*!
|
||||
* @brief Create an I2C device at a given address
|
||||
* @param addr The 7-bit I2C address for the device
|
||||
* @param theWire The I2C bus to use, defaults to &Wire
|
||||
*/
|
||||
Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire) {
|
||||
_addr = addr;
|
||||
_wire = theWire;
|
||||
_begun = false;
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
_maxBufferSize = 250; // as defined in Wire.h's RingBuffer
|
||||
#else
|
||||
_maxBufferSize = 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Initializes and does basic address detection
|
||||
* @param addr_detect Whether we should attempt to detect the I2C address
|
||||
* with a scan. 99% of sensors/devices don't mind but once in a while, they spaz
|
||||
* on a scan!
|
||||
* @return True if I2C initialized and a device with the addr found
|
||||
*/
|
||||
bool Adafruit_I2CDevice::begin(bool addr_detect) {
|
||||
_wire->begin();
|
||||
_begun = true;
|
||||
//Serial.println(addr_detect);
|
||||
if (addr_detect) {
|
||||
return detected();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief De-initialize device, turn off the Wire interface
|
||||
*/
|
||||
void Adafruit_I2CDevice::end(void) {
|
||||
// Not all port implement Wire::end(), such as
|
||||
// - ESP8266
|
||||
// - AVR core without WIRE_HAS_END
|
||||
// - ESP32: end() is implemented since 2.0.1 which is latest at the moment.
|
||||
// Temporarily disable for now to give time for user to update.
|
||||
#if !(defined(ESP8266) || \
|
||||
(defined(ARDUINO_ARCH_AVR) && !defined(WIRE_HAS_END)) || \
|
||||
defined(ARDUINO_ARCH_ESP32))
|
||||
_wire->end();
|
||||
_begun = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Scans I2C for the address - note will give a false-positive
|
||||
* if there's no pullups on I2C
|
||||
* @return True if I2C initialized and a device with the addr found
|
||||
*/
|
||||
bool Adafruit_I2CDevice::detected(void) {
|
||||
// Init I2C if not done yet
|
||||
// Serial.println("sadfasdfasdfsdf");
|
||||
if (!_begun && !begin()) {
|
||||
//Serial.println("sadfasdfasdfsdf");
|
||||
return false;
|
||||
}
|
||||
|
||||
// A basic scanner, see if it ACK's
|
||||
_wire->beginTransmission(_addr);
|
||||
if (_wire->endTransmission() == 0) {
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println(F("Detected"));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println(F("Not detected"));
|
||||
#endif
|
||||
Serial.println("22222222222222");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write a buffer or two to the I2C device. Cannot be more than
|
||||
* maxBufferSize() bytes.
|
||||
* @param buffer Pointer to buffer of data to write. This is const to
|
||||
* ensure the content of this buffer doesn't change.
|
||||
* @param len Number of bytes from buffer to write
|
||||
* @param prefix_buffer Pointer to optional array of data to write before
|
||||
* buffer. Cannot be more than maxBufferSize() bytes. This is const to
|
||||
* ensure the content of this buffer doesn't change.
|
||||
* @param prefix_len Number of bytes from prefix buffer to write
|
||||
* @param stop Whether to send an I2C STOP signal on write
|
||||
* @return True if write was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_I2CDevice::write(const uint8_t *buffer, size_t len, bool stop,
|
||||
const uint8_t *prefix_buffer,
|
||||
size_t prefix_len) {
|
||||
if ((len + prefix_len) > maxBufferSize()) {
|
||||
// currently not guaranteed to work if more than 32 bytes!
|
||||
// we will need to find out if some platforms have larger
|
||||
// I2C buffer sizes :/
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println(F("\tI2CDevice could not write such a large buffer"));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
_wire->beginTransmission(_addr);
|
||||
|
||||
// Write the prefix data (usually an address)
|
||||
if ((prefix_len != 0) && (prefix_buffer != nullptr)) {
|
||||
if (_wire->write(prefix_buffer, prefix_len) != prefix_len) {
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println(F("\tI2CDevice failed to write"));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the data itself
|
||||
if (_wire->write(buffer, len) != len) {
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println(F("\tI2CDevice failed to write"));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
|
||||
DEBUG_SERIAL.print(F("\tI2CWRITE @ 0x"));
|
||||
DEBUG_SERIAL.print(_addr, HEX);
|
||||
DEBUG_SERIAL.print(F(" :: "));
|
||||
if ((prefix_len != 0) && (prefix_buffer != nullptr)) {
|
||||
for (uint16_t i = 0; i < prefix_len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(prefix_buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
}
|
||||
}
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
if (i % 32 == 31) {
|
||||
DEBUG_SERIAL.println();
|
||||
}
|
||||
}
|
||||
|
||||
if (stop) {
|
||||
DEBUG_SERIAL.print("\tSTOP");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_wire->endTransmission(stop) == 0) {
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println();
|
||||
// DEBUG_SERIAL.println("Sent!");
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.println("\tFailed to send!");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read from I2C into a buffer from the I2C device.
|
||||
* Cannot be more than maxBufferSize() bytes.
|
||||
* @param buffer Pointer to buffer of data to read into
|
||||
* @param len Number of bytes from buffer to read.
|
||||
* @param stop Whether to send an I2C STOP signal on read
|
||||
* @return True if read was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_I2CDevice::read(uint8_t *buffer, size_t len, bool stop) {
|
||||
size_t pos = 0;
|
||||
while (pos < len) {
|
||||
size_t read_len =
|
||||
((len - pos) > maxBufferSize()) ? maxBufferSize() : (len - pos);
|
||||
bool read_stop = (pos < (len - read_len)) ? false : stop;
|
||||
if (!_read(buffer + pos, read_len, read_stop))
|
||||
return false;
|
||||
pos += read_len;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Adafruit_I2CDevice::_read(uint8_t *buffer, size_t len, bool stop) {
|
||||
#if defined(TinyWireM_h)
|
||||
size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len);
|
||||
#else
|
||||
size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);
|
||||
#endif
|
||||
|
||||
if (recv != len) {
|
||||
// Not enough data available to fulfill our obligation!
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.print(F("\tI2CDevice did not receive enough data: "));
|
||||
DEBUG_SERIAL.println(recv);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
buffer[i] = _wire->read();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.print(F("\tI2CREAD @ 0x"));
|
||||
DEBUG_SERIAL.print(_addr, HEX);
|
||||
DEBUG_SERIAL.print(F(" :: "));
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
if (len % 32 == 31) {
|
||||
DEBUG_SERIAL.println();
|
||||
}
|
||||
}
|
||||
DEBUG_SERIAL.println();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write some data, then read some data from I2C into another buffer.
|
||||
* Cannot be more than maxBufferSize() bytes. The buffers can point to
|
||||
* same/overlapping locations.
|
||||
* @param write_buffer Pointer to buffer of data to write from
|
||||
* @param write_len Number of bytes from buffer to write.
|
||||
* @param read_buffer Pointer to buffer of data to read into.
|
||||
* @param read_len Number of bytes from buffer to read.
|
||||
* @param stop Whether to send an I2C STOP signal between the write and read
|
||||
* @return True if write & read was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_I2CDevice::write_then_read(const uint8_t *write_buffer,
|
||||
size_t write_len, uint8_t *read_buffer,
|
||||
size_t read_len, bool stop) {
|
||||
if (!write(write_buffer, write_len, stop)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return read(read_buffer, read_len);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Returns the 7-bit address of this device
|
||||
* @return The 7-bit address of this device
|
||||
*/
|
||||
uint8_t Adafruit_I2CDevice::address(void) { return _addr; }
|
||||
|
||||
/*!
|
||||
* @brief Change the I2C clock speed to desired (relies on
|
||||
* underlying Wire support!
|
||||
* @param desiredclk The desired I2C SCL frequency
|
||||
* @return True if this platform supports changing I2C speed.
|
||||
* Not necessarily that the speed was achieved!
|
||||
*/
|
||||
bool Adafruit_I2CDevice::setSpeed(uint32_t desiredclk) {
|
||||
#if (ARDUINO >= 157) && !defined(ARDUINO_STM32_FEATHER) && !defined(TinyWireM_h)
|
||||
_wire->setClock(desiredclk);
|
||||
return true;
|
||||
#else
|
||||
(void)desiredclk;
|
||||
return false;
|
||||
#endif
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef Adafruit_I2CDevice_h
|
||||
#define Adafruit_I2CDevice_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
///< The class which defines how we will talk to this device over I2C
|
||||
class Adafruit_I2CDevice {
|
||||
public:
|
||||
Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
|
||||
uint8_t address(void);
|
||||
bool begin(bool addr_detect = true);
|
||||
void end(void);
|
||||
bool detected(void);
|
||||
|
||||
bool read(uint8_t *buffer, size_t len, bool stop = true);
|
||||
bool write(const uint8_t *buffer, size_t len, bool stop = true,
|
||||
const uint8_t *prefix_buffer = nullptr, size_t prefix_len = 0);
|
||||
bool write_then_read(const uint8_t *write_buffer, size_t write_len,
|
||||
uint8_t *read_buffer, size_t read_len,
|
||||
bool stop = false);
|
||||
bool setSpeed(uint32_t desiredclk);
|
||||
|
||||
/*! @brief How many bytes we can read in a transaction
|
||||
* @return The size of the Wire receive/transmit buffer */
|
||||
size_t maxBufferSize() { return _maxBufferSize; }
|
||||
|
||||
private:
|
||||
uint8_t _addr;
|
||||
TwoWire *_wire;
|
||||
bool _begun;
|
||||
size_t _maxBufferSize;
|
||||
bool _read(uint8_t *buffer, size_t len, bool stop);
|
||||
};
|
||||
|
||||
#endif // Adafruit_I2CDevice_h
|
@ -0,0 +1,10 @@
|
||||
#ifndef _ADAFRUIT_I2C_REGISTER_H_
|
||||
#define _ADAFRUIT_I2C_REGISTER_H_
|
||||
|
||||
#include <Adafruit_BusIO_Register.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
typedef Adafruit_BusIO_Register Adafruit_I2CRegister;
|
||||
typedef Adafruit_BusIO_RegisterBits Adafruit_I2CRegisterBits;
|
||||
|
||||
#endif
|
@ -0,0 +1,495 @@
|
||||
#include "Adafruit_SPIDevice.h"
|
||||
|
||||
#if !defined(SPI_INTERFACES_COUNT) || \
|
||||
(defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
|
||||
|
||||
//#define DEBUG_SERIAL Serial
|
||||
|
||||
/*!
|
||||
* @brief Create an SPI device with the given CS pin and settings
|
||||
* @param cspin The arduino pin number to use for chip select
|
||||
* @param freq The SPI clock frequency to use, defaults to 1MHz
|
||||
* @param dataOrder The SPI data order to use for bits within each byte,
|
||||
* defaults to SPI_BITORDER_MSBFIRST
|
||||
* @param dataMode The SPI mode to use, defaults to SPI_MODE0
|
||||
* @param theSPI The SPI bus to use, defaults to &theSPI
|
||||
*/
|
||||
Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, uint32_t freq,
|
||||
BusIOBitOrder dataOrder,
|
||||
uint8_t dataMode, SPIClass *theSPI) {
|
||||
_cs = cspin;
|
||||
_sck = _mosi = _miso = -1;
|
||||
_spi = theSPI;
|
||||
_begun = false;
|
||||
_spiSetting = new SPISettings(freq, dataOrder, dataMode);
|
||||
_freq = freq;
|
||||
_dataOrder = dataOrder;
|
||||
_dataMode = dataMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Create an SPI device with the given CS pin and settings
|
||||
* @param cspin The arduino pin number to use for chip select
|
||||
* @param sckpin The arduino pin number to use for SCK
|
||||
* @param misopin The arduino pin number to use for MISO, set to -1 if not
|
||||
* used
|
||||
* @param mosipin The arduino pin number to use for MOSI, set to -1 if not
|
||||
* used
|
||||
* @param freq The SPI clock frequency to use, defaults to 1MHz
|
||||
* @param dataOrder The SPI data order to use for bits within each byte,
|
||||
* defaults to SPI_BITORDER_MSBFIRST
|
||||
* @param dataMode The SPI mode to use, defaults to SPI_MODE0
|
||||
*/
|
||||
Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin,
|
||||
int8_t misopin, int8_t mosipin,
|
||||
uint32_t freq, BusIOBitOrder dataOrder,
|
||||
uint8_t dataMode) {
|
||||
_cs = cspin;
|
||||
_sck = sckpin;
|
||||
_miso = misopin;
|
||||
_mosi = mosipin;
|
||||
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
csPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(cspin));
|
||||
csPinMask = digitalPinToBitMask(cspin);
|
||||
if (mosipin != -1) {
|
||||
mosiPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(mosipin));
|
||||
mosiPinMask = digitalPinToBitMask(mosipin);
|
||||
}
|
||||
if (misopin != -1) {
|
||||
misoPort = (BusIO_PortReg *)portInputRegister(digitalPinToPort(misopin));
|
||||
misoPinMask = digitalPinToBitMask(misopin);
|
||||
}
|
||||
clkPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(sckpin));
|
||||
clkPinMask = digitalPinToBitMask(sckpin);
|
||||
#endif
|
||||
|
||||
_freq = freq;
|
||||
_dataOrder = dataOrder;
|
||||
_dataMode = dataMode;
|
||||
_begun = false;
|
||||
_spiSetting = new SPISettings(freq, dataOrder, dataMode);
|
||||
_spi = nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Release memory allocated in constructors
|
||||
*/
|
||||
Adafruit_SPIDevice::~Adafruit_SPIDevice() { delete _spiSetting; }
|
||||
|
||||
/*!
|
||||
* @brief Initializes SPI bus and sets CS pin high
|
||||
* @return Always returns true because there's no way to test success of SPI
|
||||
* init
|
||||
*/
|
||||
bool Adafruit_SPIDevice::begin(void) {
|
||||
if (_cs != -1) {
|
||||
pinMode(_cs, OUTPUT);
|
||||
digitalWrite(_cs, HIGH);
|
||||
}
|
||||
|
||||
if (_spi) { // hardware SPI
|
||||
_spi->begin();
|
||||
} else {
|
||||
pinMode(_sck, OUTPUT);
|
||||
|
||||
if ((_dataMode == SPI_MODE0) || (_dataMode == SPI_MODE1)) {
|
||||
// idle low on mode 0 and 1
|
||||
digitalWrite(_sck, LOW);
|
||||
} else {
|
||||
// idle high on mode 2 or 3
|
||||
digitalWrite(_sck, HIGH);
|
||||
}
|
||||
if (_mosi != -1) {
|
||||
pinMode(_mosi, OUTPUT);
|
||||
digitalWrite(_mosi, HIGH);
|
||||
}
|
||||
if (_miso != -1) {
|
||||
pinMode(_miso, INPUT);
|
||||
}
|
||||
}
|
||||
|
||||
_begun = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Transfer (send/receive) one byte over hard/soft SPI
|
||||
* @param buffer The buffer to send and receive at the same time
|
||||
* @param len The number of bytes to transfer
|
||||
*/
|
||||
void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) {
|
||||
if (_spi) {
|
||||
// hardware SPI is easy
|
||||
|
||||
#if defined(SPARK)
|
||||
_spi->transfer(buffer, buffer, len, nullptr);
|
||||
#elif defined(STM32)
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
_spi->transfer(buffer[i]);
|
||||
}
|
||||
#else
|
||||
_spi->transfer(buffer, len);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t startbit;
|
||||
if (_dataOrder == SPI_BITORDER_LSBFIRST) {
|
||||
startbit = 0x1;
|
||||
} else {
|
||||
startbit = 0x80;
|
||||
}
|
||||
|
||||
bool towrite, lastmosi = !(buffer[0] & startbit);
|
||||
uint8_t bitdelay_us = (1000000 / _freq) / 2;
|
||||
|
||||
// for softSPI we'll do it by hand
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
// software SPI
|
||||
uint8_t reply = 0;
|
||||
uint8_t send = buffer[i];
|
||||
|
||||
/*
|
||||
Serial.print("\tSending software SPI byte 0x");
|
||||
Serial.print(send, HEX);
|
||||
Serial.print(" -> 0x");
|
||||
*/
|
||||
|
||||
// Serial.print(send, HEX);
|
||||
for (uint8_t b = startbit; b != 0;
|
||||
b = (_dataOrder == SPI_BITORDER_LSBFIRST) ? b << 1 : b >> 1) {
|
||||
|
||||
if (bitdelay_us) {
|
||||
delayMicroseconds(bitdelay_us);
|
||||
}
|
||||
|
||||
if (_dataMode == SPI_MODE0 || _dataMode == SPI_MODE2) {
|
||||
towrite = send & b;
|
||||
if ((_mosi != -1) && (lastmosi != towrite)) {
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
if (towrite)
|
||||
*mosiPort |= mosiPinMask;
|
||||
else
|
||||
*mosiPort &= ~mosiPinMask;
|
||||
#else
|
||||
digitalWrite(_mosi, towrite);
|
||||
#endif
|
||||
lastmosi = towrite;
|
||||
}
|
||||
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
*clkPort |= clkPinMask; // Clock high
|
||||
#else
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
|
||||
if (bitdelay_us) {
|
||||
delayMicroseconds(bitdelay_us);
|
||||
}
|
||||
|
||||
if (_miso != -1) {
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
if (*misoPort & misoPinMask) {
|
||||
#else
|
||||
if (digitalRead(_miso)) {
|
||||
#endif
|
||||
reply |= b;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
*clkPort &= ~clkPinMask; // Clock low
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
#endif
|
||||
} else { // if (_dataMode == SPI_MODE1 || _dataMode == SPI_MODE3)
|
||||
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
*clkPort |= clkPinMask; // Clock high
|
||||
#else
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
|
||||
if (bitdelay_us) {
|
||||
delayMicroseconds(bitdelay_us);
|
||||
}
|
||||
|
||||
if (_mosi != -1) {
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
if (send & b)
|
||||
*mosiPort |= mosiPinMask;
|
||||
else
|
||||
*mosiPort &= ~mosiPinMask;
|
||||
#else
|
||||
digitalWrite(_mosi, send & b);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
*clkPort &= ~clkPinMask; // Clock low
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
#endif
|
||||
|
||||
if (_miso != -1) {
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
if (*misoPort & misoPinMask) {
|
||||
#else
|
||||
if (digitalRead(_miso)) {
|
||||
#endif
|
||||
reply |= b;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_miso != -1) {
|
||||
buffer[i] = reply;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Transfer (send/receive) one byte over hard/soft SPI
|
||||
* @param send The byte to send
|
||||
* @return The byte received while transmitting
|
||||
*/
|
||||
uint8_t Adafruit_SPIDevice::transfer(uint8_t send) {
|
||||
uint8_t data = send;
|
||||
transfer(&data, 1);
|
||||
return data;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Manually begin a transaction (calls beginTransaction if hardware
|
||||
* SPI)
|
||||
*/
|
||||
void Adafruit_SPIDevice::beginTransaction(void) {
|
||||
if (_spi) {
|
||||
_spi->beginTransaction(*_spiSetting);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Manually end a transaction (calls endTransaction if hardware SPI)
|
||||
*/
|
||||
void Adafruit_SPIDevice::endTransaction(void) {
|
||||
if (_spi) {
|
||||
_spi->endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write a buffer or two to the SPI device.
|
||||
* @param buffer Pointer to buffer of data to write
|
||||
* @param len Number of bytes from buffer to write
|
||||
* @param prefix_buffer Pointer to optional array of data to write before
|
||||
* buffer.
|
||||
* @param prefix_len Number of bytes from prefix buffer to write
|
||||
* @return Always returns true because there's no way to test success of SPI
|
||||
* writes
|
||||
*/
|
||||
bool Adafruit_SPIDevice::write(const uint8_t *buffer, size_t len,
|
||||
const uint8_t *prefix_buffer,
|
||||
size_t prefix_len) {
|
||||
if (_spi) {
|
||||
_spi->beginTransaction(*_spiSetting);
|
||||
}
|
||||
|
||||
setChipSelect(LOW);
|
||||
// do the writing
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
if (_spi) {
|
||||
if (prefix_len > 0) {
|
||||
_spi->transferBytes(prefix_buffer, nullptr, prefix_len);
|
||||
}
|
||||
if (len > 0) {
|
||||
_spi->transferBytes(buffer, nullptr, len);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (size_t i = 0; i < prefix_len; i++) {
|
||||
transfer(prefix_buffer[i]);
|
||||
}
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
transfer(buffer[i]);
|
||||
}
|
||||
}
|
||||
setChipSelect(HIGH);
|
||||
|
||||
if (_spi) {
|
||||
_spi->endTransaction();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.print(F("\tSPIDevice Wrote: "));
|
||||
if ((prefix_len != 0) && (prefix_buffer != nullptr)) {
|
||||
for (uint16_t i = 0; i < prefix_len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(prefix_buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
}
|
||||
}
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
if (i % 32 == 31) {
|
||||
DEBUG_SERIAL.println();
|
||||
}
|
||||
}
|
||||
DEBUG_SERIAL.println();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Read from SPI into a buffer from the SPI device.
|
||||
* @param buffer Pointer to buffer of data to read into
|
||||
* @param len Number of bytes from buffer to read.
|
||||
* @param sendvalue The 8-bits of data to write when doing the data read,
|
||||
* defaults to 0xFF
|
||||
* @return Always returns true because there's no way to test success of SPI
|
||||
* writes
|
||||
*/
|
||||
bool Adafruit_SPIDevice::read(uint8_t *buffer, size_t len, uint8_t sendvalue) {
|
||||
memset(buffer, sendvalue, len); // clear out existing buffer
|
||||
if (_spi) {
|
||||
_spi->beginTransaction(*_spiSetting);
|
||||
}
|
||||
|
||||
setChipSelect(LOW);
|
||||
transfer(buffer, len);
|
||||
setChipSelect(HIGH);
|
||||
|
||||
if (_spi) {
|
||||
_spi->endTransaction();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.print(F("\tSPIDevice Read: "));
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
if (len % 32 == 31) {
|
||||
DEBUG_SERIAL.println();
|
||||
}
|
||||
}
|
||||
DEBUG_SERIAL.println();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write some data, then read some data from SPI into another buffer.
|
||||
* The buffers can point to same/overlapping locations. This does not
|
||||
* transmit-receive at the same time!
|
||||
* @param write_buffer Pointer to buffer of data to write from
|
||||
* @param write_len Number of bytes from buffer to write.
|
||||
* @param read_buffer Pointer to buffer of data to read into.
|
||||
* @param read_len Number of bytes from buffer to read.
|
||||
* @param sendvalue The 8-bits of data to write when doing the data read,
|
||||
* defaults to 0xFF
|
||||
* @return Always returns true because there's no way to test success of SPI
|
||||
* writes
|
||||
*/
|
||||
bool Adafruit_SPIDevice::write_then_read(const uint8_t *write_buffer,
|
||||
size_t write_len, uint8_t *read_buffer,
|
||||
size_t read_len, uint8_t sendvalue) {
|
||||
if (_spi) {
|
||||
_spi->beginTransaction(*_spiSetting);
|
||||
}
|
||||
|
||||
setChipSelect(LOW);
|
||||
// do the writing
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
if (_spi) {
|
||||
if (write_len > 0) {
|
||||
_spi->transferBytes(write_buffer, nullptr, write_len);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (size_t i = 0; i < write_len; i++) {
|
||||
transfer(write_buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.print(F("\tSPIDevice Wrote: "));
|
||||
for (uint16_t i = 0; i < write_len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(write_buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
if (write_len % 32 == 31) {
|
||||
DEBUG_SERIAL.println();
|
||||
}
|
||||
}
|
||||
DEBUG_SERIAL.println();
|
||||
#endif
|
||||
|
||||
// do the reading
|
||||
for (size_t i = 0; i < read_len; i++) {
|
||||
read_buffer[i] = transfer(sendvalue);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
DEBUG_SERIAL.print(F("\tSPIDevice Read: "));
|
||||
for (uint16_t i = 0; i < read_len; i++) {
|
||||
DEBUG_SERIAL.print(F("0x"));
|
||||
DEBUG_SERIAL.print(read_buffer[i], HEX);
|
||||
DEBUG_SERIAL.print(F(", "));
|
||||
if (read_len % 32 == 31) {
|
||||
DEBUG_SERIAL.println();
|
||||
}
|
||||
}
|
||||
DEBUG_SERIAL.println();
|
||||
#endif
|
||||
|
||||
setChipSelect(HIGH);
|
||||
|
||||
if (_spi) {
|
||||
_spi->endTransaction();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Write some data and read some data at the same time from SPI
|
||||
* into the same buffer. This is basicaly a wrapper for transfer() with
|
||||
* CS-pin and transaction management.
|
||||
* This /does/ transmit-receive at the same time!
|
||||
* @param buffer Pointer to buffer of data to write/read to/from
|
||||
* @param len Number of bytes from buffer to write/read.
|
||||
* @return Always returns true because there's no way to test success of SPI
|
||||
* writes
|
||||
*/
|
||||
bool Adafruit_SPIDevice::write_and_read(uint8_t *buffer, size_t len) {
|
||||
if (_spi) {
|
||||
_spi->beginTransaction(*_spiSetting);
|
||||
}
|
||||
|
||||
setChipSelect(LOW);
|
||||
transfer(buffer, len);
|
||||
setChipSelect(HIGH);
|
||||
|
||||
if (_spi) {
|
||||
_spi->endTransaction();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Adafruit_SPIDevice::setChipSelect(int value) {
|
||||
if (_cs == -1)
|
||||
return;
|
||||
digitalWrite(_cs, value);
|
||||
}
|
||||
|
||||
#endif // SPI exists
|
@ -0,0 +1,109 @@
|
||||
#ifndef Adafruit_SPIDevice_h
|
||||
#define Adafruit_SPIDevice_h
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#if !defined(SPI_INTERFACES_COUNT) || \
|
||||
(defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
// some modern SPI definitions don't have BitOrder enum
|
||||
#if (defined(__AVR__) && !defined(ARDUINO_ARCH_MEGAAVR)) || \
|
||||
defined(ESP8266) || defined(TEENSYDUINO) || defined(SPARK) || \
|
||||
defined(ARDUINO_ARCH_SPRESENSE) || defined(MEGATINYCORE) || \
|
||||
defined(DXCORE) || defined(ARDUINO_AVR_ATmega4809) || \
|
||||
defined(ARDUINO_AVR_ATmega4808) || defined(ARDUINO_AVR_ATmega3209) || \
|
||||
defined(ARDUINO_AVR_ATmega3208) || defined(ARDUINO_AVR_ATmega1609) || \
|
||||
defined(ARDUINO_AVR_ATmega1608) || defined(ARDUINO_AVR_ATmega809) || \
|
||||
defined(ARDUINO_AVR_ATmega808) || defined(ARDUINO_ARCH_ARC32)
|
||||
|
||||
typedef enum _BitOrder {
|
||||
SPI_BITORDER_MSBFIRST = MSBFIRST,
|
||||
SPI_BITORDER_LSBFIRST = LSBFIRST,
|
||||
} BusIOBitOrder;
|
||||
|
||||
#elif defined(ESP32) || defined(__ASR6501__) || defined(__ASR6502__)
|
||||
|
||||
// some modern SPI definitions don't have BitOrder enum and have different SPI
|
||||
// mode defines
|
||||
typedef enum _BitOrder {
|
||||
SPI_BITORDER_MSBFIRST = SPI_MSBFIRST,
|
||||
SPI_BITORDER_LSBFIRST = SPI_LSBFIRST,
|
||||
} BusIOBitOrder;
|
||||
|
||||
#else
|
||||
// Some platforms have a BitOrder enum but its named MSBFIRST/LSBFIRST
|
||||
#define SPI_BITORDER_MSBFIRST MSBFIRST
|
||||
#define SPI_BITORDER_LSBFIRST LSBFIRST
|
||||
typedef BitOrder BusIOBitOrder;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__) || defined(TEENSYDUINO)
|
||||
typedef volatile uint8_t BusIO_PortReg;
|
||||
typedef uint8_t BusIO_PortMask;
|
||||
#define BUSIO_USE_FAST_PINIO
|
||||
|
||||
#elif defined(ESP8266) || defined(ESP32) || defined(__SAM3X8E__) || \
|
||||
defined(ARDUINO_ARCH_SAMD)
|
||||
typedef volatile uint32_t BusIO_PortReg;
|
||||
typedef uint32_t BusIO_PortMask;
|
||||
#define BUSIO_USE_FAST_PINIO
|
||||
|
||||
#elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && \
|
||||
!defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_RP2040)
|
||||
typedef volatile uint32_t BusIO_PortReg;
|
||||
typedef uint32_t BusIO_PortMask;
|
||||
#if !defined(__ASR6501__) && !defined(__ASR6502__)
|
||||
#define BUSIO_USE_FAST_PINIO
|
||||
#endif
|
||||
|
||||
#else
|
||||
#undef BUSIO_USE_FAST_PINIO
|
||||
#endif
|
||||
|
||||
/**! The class which defines how we will talk to this device over SPI **/
|
||||
class Adafruit_SPIDevice {
|
||||
public:
|
||||
Adafruit_SPIDevice(int8_t cspin, uint32_t freq = 1000000,
|
||||
BusIOBitOrder dataOrder = SPI_BITORDER_MSBFIRST,
|
||||
uint8_t dataMode = SPI_MODE0, SPIClass *theSPI = &SPI);
|
||||
|
||||
Adafruit_SPIDevice(int8_t cspin, int8_t sck, int8_t miso, int8_t mosi,
|
||||
uint32_t freq = 1000000,
|
||||
BusIOBitOrder dataOrder = SPI_BITORDER_MSBFIRST,
|
||||
uint8_t dataMode = SPI_MODE0);
|
||||
~Adafruit_SPIDevice();
|
||||
|
||||
bool begin(void);
|
||||
bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF);
|
||||
bool write(const uint8_t *buffer, size_t len,
|
||||
const uint8_t *prefix_buffer = nullptr, size_t prefix_len = 0);
|
||||
bool write_then_read(const uint8_t *write_buffer, size_t write_len,
|
||||
uint8_t *read_buffer, size_t read_len,
|
||||
uint8_t sendvalue = 0xFF);
|
||||
bool write_and_read(uint8_t *buffer, size_t len);
|
||||
|
||||
uint8_t transfer(uint8_t send);
|
||||
void transfer(uint8_t *buffer, size_t len);
|
||||
void beginTransaction(void);
|
||||
void endTransaction(void);
|
||||
|
||||
private:
|
||||
SPIClass *_spi;
|
||||
SPISettings *_spiSetting;
|
||||
uint32_t _freq;
|
||||
BusIOBitOrder _dataOrder;
|
||||
uint8_t _dataMode;
|
||||
void setChipSelect(int value);
|
||||
|
||||
int8_t _cs, _sck, _mosi, _miso;
|
||||
#ifdef BUSIO_USE_FAST_PINIO
|
||||
BusIO_PortReg *mosiPort, *clkPort, *misoPort, *csPort;
|
||||
BusIO_PortMask mosiPinMask, misoPinMask, clkPinMask, csPinMask;
|
||||
#endif
|
||||
bool _begun;
|
||||
};
|
||||
|
||||
#endif // has SPI defined
|
||||
#endif // Adafruit_SPIDevice_h
|
@ -0,0 +1,11 @@
|
||||
# Adafruit Bus IO Library
|
||||
# https://github.com/adafruit/Adafruit_BusIO
|
||||
# MIT License
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
idf_component_register(SRCS "Adafruit_I2CDevice.cpp" "Adafruit_BusIO_Register.cpp" "Adafruit_SPIDevice.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES arduino)
|
||||
|
||||
project(Adafruit_BusIO)
|
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Adafruit Industries
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,8 @@
|
||||
# Adafruit Bus IO Library [](https://github.com/adafruit/Adafruit_BusIO/actions)
|
||||
|
||||
|
||||
This is a helper library to abstract away I2C & SPI transactions and registers
|
||||
|
||||
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
MIT license, all text above must be included in any redistribution
|
@ -0,0 +1 @@
|
||||
COMPONENT_ADD_INCLUDEDIRS = .
|
@ -0,0 +1,21 @@
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
|
||||
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(0x10);
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("I2C address detection test");
|
||||
|
||||
if (!i2c_dev.begin()) {
|
||||
Serial.print("Did not find device at 0x");
|
||||
Serial.println(i2c_dev.address(), HEX);
|
||||
while (1);
|
||||
}
|
||||
Serial.print("Device found on address 0x");
|
||||
Serial.println(i2c_dev.address(), HEX);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
|
||||
#define I2C_ADDRESS 0x60
|
||||
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(I2C_ADDRESS);
|
||||
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("I2C device read and write test");
|
||||
|
||||
if (!i2c_dev.begin()) {
|
||||
Serial.print("Did not find device at 0x");
|
||||
Serial.println(i2c_dev.address(), HEX);
|
||||
while (1);
|
||||
}
|
||||
Serial.print("Device found on address 0x");
|
||||
Serial.println(i2c_dev.address(), HEX);
|
||||
|
||||
uint8_t buffer[32];
|
||||
// Try to read 32 bytes
|
||||
i2c_dev.read(buffer, 32);
|
||||
Serial.print("Read: ");
|
||||
for (uint8_t i=0; i<32; i++) {
|
||||
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// read a register by writing first, then reading
|
||||
buffer[0] = 0x0C; // we'll reuse the same buffer
|
||||
i2c_dev.write_then_read(buffer, 1, buffer, 2, false);
|
||||
Serial.print("Write then Read: ");
|
||||
for (uint8_t i=0; i<2; i++) {
|
||||
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
#include <Adafruit_BusIO_Register.h>
|
||||
|
||||
#define I2C_ADDRESS 0x60
|
||||
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(I2C_ADDRESS);
|
||||
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("I2C device register test");
|
||||
|
||||
if (!i2c_dev.begin()) {
|
||||
Serial.print("Did not find device at 0x");
|
||||
Serial.println(i2c_dev.address(), HEX);
|
||||
while (1);
|
||||
}
|
||||
Serial.print("Device found on address 0x");
|
||||
Serial.println(i2c_dev.address(), HEX);
|
||||
|
||||
Adafruit_BusIO_Register id_reg = Adafruit_BusIO_Register(&i2c_dev, 0x0C, 2, LSBFIRST);
|
||||
uint16_t id;
|
||||
id_reg.read(&id);
|
||||
Serial.print("ID register = 0x"); Serial.println(id, HEX);
|
||||
|
||||
Adafruit_BusIO_Register thresh_reg = Adafruit_BusIO_Register(&i2c_dev, 0x01, 2, LSBFIRST);
|
||||
uint16_t thresh;
|
||||
thresh_reg.read(&thresh);
|
||||
Serial.print("Initial threshold register = 0x"); Serial.println(thresh, HEX);
|
||||
|
||||
thresh_reg.write(~thresh);
|
||||
|
||||
Serial.print("Post threshold register = 0x"); Serial.println(thresh_reg.read(), HEX);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#include <Adafruit_BusIO_Register.h>
|
||||
|
||||
// Define which interface to use by setting the unused interface to NULL!
|
||||
|
||||
#define SPIDEVICE_CS 10
|
||||
Adafruit_SPIDevice *spi_dev = NULL; // new Adafruit_SPIDevice(SPIDEVICE_CS);
|
||||
|
||||
#define I2C_ADDRESS 0x5D
|
||||
Adafruit_I2CDevice *i2c_dev = new Adafruit_I2CDevice(I2C_ADDRESS);
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("I2C or SPI device register test");
|
||||
|
||||
if (spi_dev && !spi_dev->begin()) {
|
||||
Serial.println("Could not initialize SPI device");
|
||||
}
|
||||
|
||||
if (i2c_dev) {
|
||||
if (i2c_dev->begin()) {
|
||||
Serial.print("Device found on I2C address 0x");
|
||||
Serial.println(i2c_dev->address(), HEX);
|
||||
} else {
|
||||
Serial.print("Did not find I2C device at 0x");
|
||||
Serial.println(i2c_dev->address(), HEX);
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_BusIO_Register id_reg = Adafruit_BusIO_Register(i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, 0x0F);
|
||||
uint8_t id=0;
|
||||
id_reg.read(&id);
|
||||
Serial.print("ID register = 0x"); Serial.println(id, HEX);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
#define SPIDEVICE_CS 10
|
||||
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS, 100000, SPI_BITORDER_MSBFIRST, SPI_MODE1);
|
||||
//Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS, 13, 12, 11, 100000, SPI_BITORDER_MSBFIRST, SPI_MODE1);
|
||||
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI device mode test");
|
||||
|
||||
if (!spi_dev.begin()) {
|
||||
Serial.println("Could not initialize SPI device");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("\n\nTransfer test");
|
||||
for (uint16_t x=0; x<=0xFF; x++) {
|
||||
uint8_t i = x;
|
||||
Serial.print("0x"); Serial.print(i, HEX);
|
||||
spi_dev.read(&i, 1, i);
|
||||
Serial.print("/"); Serial.print(i, HEX);
|
||||
Serial.print(", ");
|
||||
delay(25);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
#define SPIDEVICE_CS 10
|
||||
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS);
|
||||
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI device read and write test");
|
||||
|
||||
if (!spi_dev.begin()) {
|
||||
Serial.println("Could not initialize SPI device");
|
||||
while (1);
|
||||
}
|
||||
|
||||
uint8_t buffer[32];
|
||||
|
||||
// Try to read 32 bytes
|
||||
spi_dev.read(buffer, 32);
|
||||
Serial.print("Read: ");
|
||||
for (uint8_t i=0; i<32; i++) {
|
||||
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// read a register by writing first, then reading
|
||||
buffer[0] = 0x8F; // we'll reuse the same buffer
|
||||
spi_dev.write_then_read(buffer, 1, buffer, 2, false);
|
||||
Serial.print("Write then Read: ");
|
||||
for (uint8_t i=0; i<2; i++) {
|
||||
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
/***************************************************
|
||||
|
||||
This is an example for how to use Adafruit_BusIO_RegisterBits from Adafruit_BusIO library.
|
||||
|
||||
Designed specifically to work with the Adafruit RTD Sensor
|
||||
----> https://www.adafruit.com/products/3328
|
||||
uisng a MAX31865 RTD-to-Digital Converter
|
||||
----> https://datasheets.maximintegrated.com/en/ds/MAX31865.pdf
|
||||
|
||||
This sensor uses SPI to communicate, 4 pins are required to
|
||||
interface.
|
||||
A fifth pin helps to detect when a new conversion is ready.
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Example written (2020/3) by Andreas Hardtung/AnHard.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_BusIO_Register.h>
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
#define MAX31865_SPI_SPEED (5000000)
|
||||
#define MAX31865_SPI_BITORDER (SPI_BITORDER_MSBFIRST)
|
||||
#define MAX31865_SPI_MODE (SPI_MODE1)
|
||||
|
||||
#define MAX31865_SPI_CS (10)
|
||||
#define MAX31865_READY_PIN (2)
|
||||
|
||||
|
||||
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice( MAX31865_SPI_CS, MAX31865_SPI_SPEED, MAX31865_SPI_BITORDER, MAX31865_SPI_MODE, &SPI); // Hardware SPI
|
||||
// Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice( MAX31865_SPI_CS, 13, 12, 11, MAX31865_SPI_SPEED, MAX31865_SPI_BITORDER, MAX31865_SPI_MODE); // Software SPI
|
||||
|
||||
// MAX31865 chip related *********************************************************************************************
|
||||
Adafruit_BusIO_Register config_reg = Adafruit_BusIO_Register(&spi_dev, 0x00, ADDRBIT8_HIGH_TOWRITE, 1, MSBFIRST);
|
||||
Adafruit_BusIO_RegisterBits bias_bit = Adafruit_BusIO_RegisterBits(&config_reg, 1, 7);
|
||||
Adafruit_BusIO_RegisterBits auto_bit = Adafruit_BusIO_RegisterBits(&config_reg, 1, 6);
|
||||
Adafruit_BusIO_RegisterBits oneS_bit = Adafruit_BusIO_RegisterBits(&config_reg, 1, 5);
|
||||
Adafruit_BusIO_RegisterBits wire_bit = Adafruit_BusIO_RegisterBits(&config_reg, 1, 4);
|
||||
Adafruit_BusIO_RegisterBits faultT_bits = Adafruit_BusIO_RegisterBits(&config_reg, 2, 2);
|
||||
Adafruit_BusIO_RegisterBits faultR_bit = Adafruit_BusIO_RegisterBits(&config_reg, 1, 1);
|
||||
Adafruit_BusIO_RegisterBits fi50hz_bit = Adafruit_BusIO_RegisterBits(&config_reg, 1, 0);
|
||||
|
||||
Adafruit_BusIO_Register rRatio_reg = Adafruit_BusIO_Register(&spi_dev, 0x01, ADDRBIT8_HIGH_TOWRITE, 2, MSBFIRST);
|
||||
Adafruit_BusIO_RegisterBits rRatio_bits = Adafruit_BusIO_RegisterBits(&rRatio_reg, 15, 1);
|
||||
Adafruit_BusIO_RegisterBits fault_bit = Adafruit_BusIO_RegisterBits(&rRatio_reg, 1, 0);
|
||||
|
||||
Adafruit_BusIO_Register maxRratio_reg = Adafruit_BusIO_Register(&spi_dev, 0x03, ADDRBIT8_HIGH_TOWRITE, 2, MSBFIRST);
|
||||
Adafruit_BusIO_RegisterBits maxRratio_bits = Adafruit_BusIO_RegisterBits(&maxRratio_reg, 15, 1);
|
||||
|
||||
Adafruit_BusIO_Register minRratio_reg = Adafruit_BusIO_Register(&spi_dev, 0x05, ADDRBIT8_HIGH_TOWRITE, 2, MSBFIRST);
|
||||
Adafruit_BusIO_RegisterBits minRratio_bits = Adafruit_BusIO_RegisterBits(&minRratio_reg, 15, 1);
|
||||
|
||||
Adafruit_BusIO_Register fault_reg = Adafruit_BusIO_Register(&spi_dev, 0x07, ADDRBIT8_HIGH_TOWRITE, 1, MSBFIRST);
|
||||
Adafruit_BusIO_RegisterBits range_high_fault_bit = Adafruit_BusIO_RegisterBits(&fault_reg, 1, 7);
|
||||
Adafruit_BusIO_RegisterBits range_low_fault_bit = Adafruit_BusIO_RegisterBits(&fault_reg, 1, 6);
|
||||
Adafruit_BusIO_RegisterBits refin_high_fault_bit = Adafruit_BusIO_RegisterBits(&fault_reg, 1, 5);
|
||||
Adafruit_BusIO_RegisterBits refin_low_fault_bit = Adafruit_BusIO_RegisterBits(&fault_reg, 1, 4);
|
||||
Adafruit_BusIO_RegisterBits rtdin_low_fault_bit = Adafruit_BusIO_RegisterBits(&fault_reg, 1, 3);
|
||||
Adafruit_BusIO_RegisterBits voltage_fault_bit = Adafruit_BusIO_RegisterBits(&fault_reg, 1, 2);
|
||||
|
||||
// Print the details of the configuration register.
|
||||
void printConfig( void ) {
|
||||
Serial.print("BIAS: "); if (bias_bit.read() ) Serial.print("ON"); else Serial.print("OFF");
|
||||
Serial.print(", AUTO: "); if (auto_bit.read() ) Serial.print("ON"); else Serial.print("OFF");
|
||||
Serial.print(", ONES: "); if (oneS_bit.read() ) Serial.print("ON"); else Serial.print("OFF");
|
||||
Serial.print(", WIRE: "); if (wire_bit.read() ) Serial.print("3"); else Serial.print("2/4");
|
||||
Serial.print(", FAULTCLEAR: "); if (faultR_bit.read() ) Serial.print("ON"); else Serial.print("OFF");
|
||||
Serial.print(", "); if (fi50hz_bit.read() ) Serial.print("50HZ"); else Serial.print("60HZ");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
// Check and print faults. Then clear them.
|
||||
void checkFaults( void ) {
|
||||
if (fault_bit.read()) {
|
||||
Serial.print("MAX: "); Serial.println(maxRratio_bits.read());
|
||||
Serial.print("VAL: "); Serial.println( rRatio_bits.read());
|
||||
Serial.print("MIN: "); Serial.println(minRratio_bits.read());
|
||||
|
||||
if (range_high_fault_bit.read() ) Serial.println("Range high fault");
|
||||
if ( range_low_fault_bit.read() ) Serial.println("Range low fault");
|
||||
if (refin_high_fault_bit.read() ) Serial.println("REFIN high fault");
|
||||
if ( refin_low_fault_bit.read() ) Serial.println("REFIN low fault");
|
||||
if ( rtdin_low_fault_bit.read() ) Serial.println("RTDIN low fault");
|
||||
if ( voltage_fault_bit.read() ) Serial.println("Voltage fault");
|
||||
|
||||
faultR_bit.write(1); // clear fault
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
#if (MAX31865_1_READY_PIN != -1)
|
||||
pinMode(MAX31865_READY_PIN ,INPUT_PULLUP);
|
||||
#endif
|
||||
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI Adafruit_BusIO_RegisterBits test on MAX31865");
|
||||
|
||||
if (!spi_dev.begin()) {
|
||||
Serial.println("Could not initialize SPI device");
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Set up for automode 50Hz. We don't care about selfheating. We want the highest possible sampling rate.
|
||||
auto_bit.write(0); // Don't switch filtermode while auto_mode is on.
|
||||
fi50hz_bit.write(1); // Set filter to 50Hz mode.
|
||||
faultR_bit.write(1); // Clear faults.
|
||||
bias_bit.write(1); // In automode we want to have the bias current always on.
|
||||
delay(5); // Wait until bias current settles down.
|
||||
// 10.5 time constants of the input RC network is required.
|
||||
// 10ms worst case for 10kω reference resistor and a 0.1µF capacitor across the RTD inputs.
|
||||
// Adafruit Module has 0.1µF and only 430/4300ω So here 0.43/4.3ms
|
||||
auto_bit.write(1); // Now we can set automode. Automatically starting first conversion.
|
||||
|
||||
// Test the READY_PIN
|
||||
#if (defined( MAX31865_READY_PIN ) && (MAX31865_READY_PIN != -1))
|
||||
int i = 0;
|
||||
while (digitalRead(MAX31865_READY_PIN) && i++ <= 100) { delay(1); }
|
||||
if (i >= 100) {
|
||||
Serial.print("ERROR: Max31865 Pin detection does not work. PIN:");
|
||||
Serial.println(MAX31865_READY_PIN);
|
||||
}
|
||||
#else
|
||||
delay(100);
|
||||
#endif
|
||||
|
||||
// Set ratio range.
|
||||
// Setting the temperatures would need some more calculation - not related to Adafruit_BusIO_RegisterBits.
|
||||
uint16_t ratio = rRatio_bits.read();
|
||||
maxRratio_bits.write( (ratio < 0x8fffu-1000u) ? ratio + 1000u : 0x8fffu );
|
||||
minRratio_bits.write( (ratio > 1000u) ? ratio - 1000u : 0u );
|
||||
|
||||
printConfig();
|
||||
checkFaults();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
#if (defined( MAX31865_READY_PIN ) && (MAX31865_1_READY_PIN != -1))
|
||||
// Is conversion ready?
|
||||
if (!digitalRead(MAX31865_READY_PIN))
|
||||
#else
|
||||
// Warant conversion is ready.
|
||||
delay(21); // 21ms for 50Hz-mode. 19ms in 60Hz-mode.
|
||||
#endif
|
||||
{
|
||||
// Read ratio, calculate temperature, scale, filter and print.
|
||||
Serial.println( rRatio2C( rRatio_bits.read() ) * 100.0f, 0); // Temperature scaled by 100
|
||||
// Check, print, clear faults.
|
||||
checkFaults();
|
||||
}
|
||||
|
||||
// Do something else.
|
||||
//delay(15000);
|
||||
}
|
||||
|
||||
|
||||
// Module/Sensor related. Here Adafruit PT100 module with a 2_Wire PT100 Class C *****************************
|
||||
float rRatio2C(uint16_t ratio) {
|
||||
// A simple linear conversion.
|
||||
const float R0 = 100.0f;
|
||||
const float Rref = 430.0f;
|
||||
const float alphaPT = 0.003850f;
|
||||
const float ADCmax = (1u << 15) - 1.0f;
|
||||
const float rscale = Rref / ADCmax;
|
||||
// Measured temperature in boiling water 101.08°C with factor a = 1 and b = 0. Rref and MAX at about 22±2°C.
|
||||
// Measured temperature in ice/water bath 0.76°C with factor a = 1 and b = 0. Rref and MAX at about 22±2°C.
|
||||
//const float a = 1.0f / (alphaPT * R0);
|
||||
const float a = (100.0f/101.08f) / (alphaPT * R0);
|
||||
//const float b = 0.0f; // 101.08
|
||||
const float b = -0.76f; // 100.32 > 101.08
|
||||
|
||||
return filterRing( ((ratio * rscale) - R0) * a + b );
|
||||
}
|
||||
|
||||
// General purpose *********************************************************************************************
|
||||
#define RINGLENGTH 250
|
||||
float filterRing( float newVal ) {
|
||||
static float ring[RINGLENGTH] = { 0.0 };
|
||||
static uint8_t ringIndex = 0;
|
||||
static bool ringFull = false;
|
||||
|
||||
if ( ringIndex == RINGLENGTH ) { ringFull = true; ringIndex = 0; }
|
||||
ring[ringIndex] = newVal;
|
||||
uint8_t loopEnd = (ringFull) ? RINGLENGTH : ringIndex + 1;
|
||||
float ringSum = 0.0f;
|
||||
for (uint8_t i = 0; i < loopEnd; i++) ringSum += ring[i];
|
||||
ringIndex++;
|
||||
return ringSum / loopEnd;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#include <Adafruit_BusIO_Register.h>
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
#define SPIDEVICE_CS 10
|
||||
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS);
|
||||
|
||||
void setup() {
|
||||
while (!Serial) { delay(10); }
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI device register test");
|
||||
|
||||
if (!spi_dev.begin()) {
|
||||
Serial.println("Could not initialize SPI device");
|
||||
while (1);
|
||||
}
|
||||
|
||||
Adafruit_BusIO_Register id_reg = Adafruit_BusIO_Register(&spi_dev, 0x0F, ADDRBIT8_HIGH_TOREAD);
|
||||
uint8_t id = 0;
|
||||
id_reg.read(&id);
|
||||
Serial.print("ID register = 0x"); Serial.println(id, HEX);
|
||||
|
||||
Adafruit_BusIO_Register thresh_reg = Adafruit_BusIO_Register(&spi_dev, 0x0C, ADDRBIT8_HIGH_TOREAD, 2, LSBFIRST);
|
||||
uint16_t thresh = 0;
|
||||
thresh_reg.read(&thresh);
|
||||
Serial.print("Initial threshold register = 0x"); Serial.println(thresh, HEX);
|
||||
|
||||
thresh_reg.write(~thresh);
|
||||
|
||||
Serial.print("Post threshold register = 0x"); Serial.println(thresh_reg.read(), HEX);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
name=Adafruit BusIO
|
||||
version=1.11.4
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=This is a library for abstracting away UART, I2C and SPI interfacing
|
||||
paragraph=This is a library for abstracting away UART, I2C and SPI interfacing
|
||||
category=Signal Input/Output
|
||||
url=https://github.com/adafruit/Adafruit_BusIO
|
||||
architectures=*
|
46
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit MLX90614 Library/.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit MLX90614 Library/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
@ -0,0 +1,26 @@
|
||||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
32
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit MLX90614 Library/.github/workflows/githubci.yml
vendored
Normal file
32
weatherslave/.pio/libdeps/esp_wroom_02/Adafruit MLX90614 Library/.github/workflows/githubci.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit MLX90614 Arduino Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
@ -0,0 +1 @@
|
||||
{"type": "library", "name": "Adafruit MLX90614 Library", "version": "2.1.3", "spec": {"owner": "adafruit", "id": 782, "name": "Adafruit MLX90614 Library", "requirements": null, "url": null}}
|
@ -0,0 +1,175 @@
|
||||
/***************************************************
|
||||
This is a library for the MLX90614 Temp Sensor
|
||||
|
||||
Designed specifically to work with the MLX90614 sensors in the
|
||||
adafruit shop
|
||||
----> https://www.adafruit.com/products/1747 (3V)
|
||||
----> https://www.adafruit.com/products/1748 (5V)
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include "Adafruit_MLX90614.h"
|
||||
|
||||
Adafruit_MLX90614::~Adafruit_MLX90614() {
|
||||
if (i2c_dev)
|
||||
delete i2c_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Begin the I2C connection
|
||||
* @param addr I2C address for the device.
|
||||
* @param wire Pointer to Wire instance
|
||||
* @return True if the device was successfully initialized, otherwise false.
|
||||
*/
|
||||
bool Adafruit_MLX90614::begin(uint8_t addr, TwoWire *wire) {
|
||||
_addr = addr; // needed for CRC
|
||||
if (i2c_dev)
|
||||
delete i2c_dev;
|
||||
i2c_dev = new Adafruit_I2CDevice(addr, wire);
|
||||
return i2c_dev->begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the raw value from the emissivity register
|
||||
*
|
||||
* @return uint16_t The unscaled emissivity value or '0' if reading failed
|
||||
*/
|
||||
uint16_t Adafruit_MLX90614::readEmissivityReg(void) {
|
||||
return read16(MLX90614_EMISS);
|
||||
}
|
||||
/**
|
||||
* @brief Write the raw unscaled emissivity value to the emissivity register
|
||||
*
|
||||
* @param ereg The unscaled emissivity value
|
||||
*/
|
||||
void Adafruit_MLX90614::writeEmissivityReg(uint16_t ereg) {
|
||||
write16(MLX90614_EMISS, 0); // erase
|
||||
delay(10);
|
||||
write16(MLX90614_EMISS, ereg);
|
||||
delay(10);
|
||||
}
|
||||
/**
|
||||
* @brief Read the emissivity value from the sensor's register and scale
|
||||
*
|
||||
* @return double The emissivity value, ranging from 0.1 - 1.0 or NAN if reading
|
||||
* failed
|
||||
*/
|
||||
double Adafruit_MLX90614::readEmissivity(void) {
|
||||
uint16_t ereg = read16(MLX90614_EMISS);
|
||||
if (ereg == 0)
|
||||
return NAN;
|
||||
return ((double)ereg) / 65535.0;
|
||||
}
|
||||
/**
|
||||
* @brief Set the emissivity value
|
||||
*
|
||||
* @param emissivity The emissivity value to use, between 0.1 and 1.0
|
||||
*/
|
||||
void Adafruit_MLX90614::writeEmissivity(double emissivity) {
|
||||
uint16_t ereg = (uint16_t)(0xffff * emissivity);
|
||||
|
||||
writeEmissivityReg(ereg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current temperature of an object in degrees Farenheit
|
||||
*
|
||||
* @return double The temperature in degrees Farenheit or NAN if reading failed
|
||||
*/
|
||||
double Adafruit_MLX90614::readObjectTempF(void) {
|
||||
return (readTemp(MLX90614_TOBJ1) * 9 / 5) + 32;
|
||||
}
|
||||
/**
|
||||
* @brief Get the current ambient temperature in degrees Farenheit
|
||||
*
|
||||
* @return double The temperature in degrees Farenheit or NAN if reading failed
|
||||
*/
|
||||
double Adafruit_MLX90614::readAmbientTempF(void) {
|
||||
return (readTemp(MLX90614_TA) * 9 / 5) + 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current temperature of an object in degrees Celcius
|
||||
*
|
||||
* @return double The temperature in degrees Celcius or NAN if reading failed
|
||||
*/
|
||||
double Adafruit_MLX90614::readObjectTempC(void) {
|
||||
return readTemp(MLX90614_TOBJ1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current ambient temperature in degrees Celcius
|
||||
*
|
||||
* @return double The temperature in degrees Celcius or NAN if reading failed
|
||||
*/
|
||||
double Adafruit_MLX90614::readAmbientTempC(void) {
|
||||
return readTemp(MLX90614_TA);
|
||||
}
|
||||
|
||||
float Adafruit_MLX90614::readTemp(uint8_t reg) {
|
||||
float temp;
|
||||
|
||||
temp = read16(reg);
|
||||
if (temp == 0)
|
||||
return NAN;
|
||||
temp *= .02;
|
||||
temp -= 273.15;
|
||||
return temp;
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
uint16_t Adafruit_MLX90614::read16(uint8_t a) {
|
||||
uint8_t buffer[3];
|
||||
buffer[0] = a;
|
||||
// read two bytes of data + pec
|
||||
bool status = i2c_dev->write_then_read(buffer, 1, buffer, 3);
|
||||
if (!status)
|
||||
return 0;
|
||||
// return data, ignore pec
|
||||
return uint16_t(buffer[0]) | (uint16_t(buffer[1]) << 8);
|
||||
}
|
||||
|
||||
byte Adafruit_MLX90614::crc8(byte *addr, byte len)
|
||||
// The PEC calculation includes all bits except the START, REPEATED START, STOP,
|
||||
// ACK, and NACK bits. The PEC is a CRC-8 with polynomial X8+X2+X1+1.
|
||||
{
|
||||
byte crc = 0;
|
||||
while (len--) {
|
||||
byte inbyte = *addr++;
|
||||
for (byte i = 8; i; i--) {
|
||||
byte carry = (crc ^ inbyte) & 0x80;
|
||||
crc <<= 1;
|
||||
if (carry)
|
||||
crc ^= 0x7;
|
||||
inbyte <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
void Adafruit_MLX90614::write16(uint8_t a, uint16_t v) {
|
||||
uint8_t buffer[4];
|
||||
|
||||
buffer[0] = _addr << 1;
|
||||
buffer[1] = a;
|
||||
buffer[2] = v & 0xff;
|
||||
buffer[3] = v >> 8;
|
||||
|
||||
uint8_t pec = crc8(buffer, 4);
|
||||
|
||||
buffer[0] = buffer[1];
|
||||
buffer[1] = buffer[2];
|
||||
buffer[2] = buffer[3];
|
||||
buffer[3] = pec;
|
||||
|
||||
i2c_dev->write(buffer, 4);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/***************************************************
|
||||
This is a library for the MLX90614 Temp Sensor
|
||||
|
||||
Designed specifically to work with the MLX90614 sensors in the
|
||||
adafruit shop
|
||||
----> https://www.adafruit.com/products/1747 (3V)
|
||||
----> https://www.adafruit.com/products/1748 (5V)
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
#define MLX90614_I2CADDR 0x5A
|
||||
|
||||
// RAM
|
||||
#define MLX90614_RAWIR1 0x04
|
||||
#define MLX90614_RAWIR2 0x05
|
||||
#define MLX90614_TA 0x06
|
||||
#define MLX90614_TOBJ1 0x07
|
||||
#define MLX90614_TOBJ2 0x08
|
||||
// EEPROM
|
||||
#define MLX90614_TOMAX 0x20
|
||||
#define MLX90614_TOMIN 0x21
|
||||
#define MLX90614_PWMCTRL 0x22
|
||||
#define MLX90614_TARANGE 0x23
|
||||
#define MLX90614_EMISS 0x24
|
||||
#define MLX90614_CONFIG 0x25
|
||||
#define MLX90614_ADDR 0x2E
|
||||
#define MLX90614_ID1 0x3C
|
||||
#define MLX90614_ID2 0x3D
|
||||
#define MLX90614_ID3 0x3E
|
||||
#define MLX90614_ID4 0x3F
|
||||
|
||||
/**
|
||||
* @brief Class to read from and control a MLX90614 Temp Sensor
|
||||
*
|
||||
*/
|
||||
class Adafruit_MLX90614 {
|
||||
public:
|
||||
~Adafruit_MLX90614();
|
||||
bool begin(uint8_t addr = MLX90614_I2CADDR, TwoWire *wire = &Wire);
|
||||
|
||||
double readObjectTempC(void);
|
||||
double readAmbientTempC(void);
|
||||
double readObjectTempF(void);
|
||||
double readAmbientTempF(void);
|
||||
uint16_t readEmissivityReg(void);
|
||||
void writeEmissivityReg(uint16_t ereg);
|
||||
double readEmissivity(void);
|
||||
void writeEmissivity(double emissivity);
|
||||
|
||||
private:
|
||||
Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface
|
||||
float readTemp(uint8_t reg);
|
||||
|
||||
uint16_t read16(uint8_t addr);
|
||||
void write16(uint8_t addr, uint16_t data);
|
||||
byte crc8(byte *addr, byte len);
|
||||
uint8_t _addr;
|
||||
};
|
@ -0,0 +1,51 @@
|
||||
# Adafruit-MLX90614-Library [](https://github.com/adafruit/Adafruit-MLX90614-Library/actions)[](http://adafruit.github.io/Adafruit-MLX90614-Library/html/index.html)
|
||||
|
||||
This is a library for the MLX90614 temperature sensor
|
||||
|
||||
<a href="https://www.adafruit.com/products/1747"><img src="https://cdn-shop.adafruit.com/970x728/1747-00.jpg" width="500px"></a>
|
||||
|
||||
Designed and tested to work with the MLX90614 sensors in the adafruit shop
|
||||
* https://www.adafruit.com/products/1747 3V version
|
||||
* https://www.adafruit.com/products/1748 5V version
|
||||
|
||||
Check out the links above for our tutorials and wiring diagrams
|
||||
|
||||
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
# Installation
|
||||
To install, use the Arduino Library Manager and search for "Adafruit-MLX90614-Library" and install the library.
|
||||
|
||||
# Contributing
|
||||
|
||||
Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit-MLX90614-Library/blob/master/CODE_OF_CONDUCT.md>)
|
||||
before contributing to help this project stay welcoming.
|
||||
|
||||
## Documentation and doxygen
|
||||
Documentation is produced by doxygen. Contributions should include documentation for any new code added.
|
||||
|
||||
Some examples of how to use doxygen can be found in these guide pages:
|
||||
|
||||
https://learn.adafruit.com/the-well-automated-arduino-library/doxygen
|
||||
|
||||
https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips
|
||||
|
||||
## Formatting and clang-format
|
||||
This library uses [`clang-format`](https://releases.llvm.org/download.html) to standardize the formatting of `.cpp` and `.h` files.
|
||||
Contributions should be formatted using `clang-format`:
|
||||
|
||||
The `-i` flag will make the changes to the file.
|
||||
```bash
|
||||
clang-format -i *.cpp *.h
|
||||
```
|
||||
If you prefer to make the changes yourself, running `clang-format` without the `-i` flag will print out a formatted version of the file. You can save this to a file and diff it against the original to see the changes.
|
||||
|
||||
Note that the formatting output by `clang-format` is what the automated formatting checker will expect. Any diffs from this formatting will result in a failed build until they are addressed. Using the `-i` flag is highly recommended.
|
||||
|
||||
### clang-format resources
|
||||
* [Binary builds and source available on the LLVM downloads page](https://releases.llvm.org/download.html)
|
||||
* [Documentation and IDE integration](https://clang.llvm.org/docs/ClangFormat.html)
|
||||
|
||||
## About this Driver
|
||||
Written by Limor Fried for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
@ -0,0 +1,127 @@
|
||||
# Adafruit Community Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for
|
||||
all.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Be kind and courteous to others
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Collaborating with other community members
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and sexual attention or advances
|
||||
* The use of inappropriate images, including in a community member's avatar
|
||||
* The use of inappropriate language, including in a community member's nickname
|
||||
* Any spamming, flaming, baiting or other attention-stealing behavior
|
||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||
asked
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate
|
||||
|
||||
The goal of the standards and moderation guidelines outlined here is to build
|
||||
and maintain a respectful community. We ask that you don’t just aim to be
|
||||
"technically unimpeachable", but rather try to be your best self.
|
||||
|
||||
We value many things beyond technical expertise, including collaboration and
|
||||
supporting others within our community. Providing a positive experience for
|
||||
other community members can have a much more significant impact than simply
|
||||
providing the correct answer.
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
Instances of behaviors that violate the Adafruit Community Code of Conduct
|
||||
may be reported by any member of the community. Community members are
|
||||
encouraged to report these situations, including situations they witness
|
||||
involving other community members.
|
||||
|
||||
You may report in the following ways:
|
||||
|
||||
In any situation, you may send an email to <support@adafruit.com>.
|
||||
|
||||
On the Adafruit Discord, you may send an open message from any channel
|
||||
to all Community Helpers by tagging @community helpers. You may also send an
|
||||
open message from any channel, or a direct message to @kattni#1507,
|
||||
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
|
||||
@Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct and the enforcement policies listed above apply to all
|
||||
Adafruit Community venues. This includes but is not limited to any community
|
||||
spaces (both public and private), the entire Adafruit Discord server, and
|
||||
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
|
||||
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
|
||||
interaction at a conference.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.4, available at
|
||||
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
|
||||
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
|
||||
|
||||
For other projects adopting the Adafruit Community Code of
|
||||
Conduct, please contact the maintainers of those projects for enforcement.
|
||||
If you wish to use this code of conduct for your own project, consider
|
||||
explicitly mentioning your moderation policy or making a copy with your
|
||||
own moderation policy so as to avoid confusion.
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* See app note:
|
||||
* https://www.melexis.com/en/documents/documentation/application-notes/application-note-mlx90614-changing-emissivity-setting
|
||||
*
|
||||
* 1. Write 0x0000 to address 0x04 (erase the EEPROM cell)
|
||||
* 2. Write the new value to address 0x04
|
||||
* 3. Read the value in address 0x04 in order to check that the correct value is stored
|
||||
* 4. Restart the module
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Adafruit_MLX90614.h>
|
||||
|
||||
//== CHANGE THIS ============
|
||||
double new_emissivity = 0.95;
|
||||
//===========================
|
||||
|
||||
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("Adafruit MLX90614 Emissivity Setter.\n");
|
||||
|
||||
// init sensor
|
||||
if (!mlx.begin()) {
|
||||
Serial.println("Error connecting to MLX sensor. Check wiring.");
|
||||
while (1);
|
||||
};
|
||||
|
||||
// read current emissivity
|
||||
Serial.print("Current emissivity = "); Serial.println(mlx.readEmissivity());
|
||||
|
||||
// set new emissivity
|
||||
Serial.print("Setting emissivity = "); Serial.println(new_emissivity);
|
||||
mlx.writeEmissivity(new_emissivity); // this does the 0x0000 erase write
|
||||
|
||||
// read back
|
||||
Serial.print("New emissivity = "); Serial.println(mlx.readEmissivity());
|
||||
|
||||
// done
|
||||
Serial.print("DONE. Restart the module.");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/***************************************************
|
||||
This is a library example for the MLX90614 Temp Sensor
|
||||
|
||||
Designed specifically to work with the MLX90614 sensors in the
|
||||
adafruit shop
|
||||
----> https://www.adafruit.com/products/1747 3V version
|
||||
----> https://www.adafruit.com/products/1748 5V version
|
||||
|
||||
These sensors use I2C to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_MLX90614.h>
|
||||
|
||||
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("Adafruit MLX90614 test");
|
||||
|
||||
if (!mlx.begin()) {
|
||||
Serial.println("Error connecting to MLX sensor. Check wiring.");
|
||||
while (1);
|
||||
};
|
||||
|
||||
Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
|
||||
Serial.println("================================================");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
|
||||
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
|
||||
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
|
||||
Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
|
||||
|
||||
Serial.println();
|
||||
delay(500);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
name=Adafruit MLX90614 Library
|
||||
version=2.1.3
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for the MLX90614 sensors in the Adafruit shop
|
||||
paragraph=Arduino library for the MLX90614 sensors in the Adafruit shop
|
||||
category=Sensors
|
||||
url=https://github.com/adafruit/Adafruit-MLX90614-Library
|
||||
architectures=*
|
||||
depends=Adafruit BusIO
|
@ -0,0 +1,26 @@
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2020 Limor Fried for Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2
weatherslave/.pio/libdeps/esp_wroom_02/SparkFun u-blox Arduino Library/.gitattributes
vendored
Normal file
2
weatherslave/.pio/libdeps/esp_wroom_02/SparkFun u-blox Arduino Library/.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
58
weatherslave/.pio/libdeps/esp_wroom_02/SparkFun u-blox Arduino Library/.gitignore
vendored
Normal file
58
weatherslave/.pio/libdeps/esp_wroom_02/SparkFun u-blox Arduino Library/.gitignore
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
# Visual Studio Code files
|
||||
.vscode
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# =========================
|
||||
# Operating System Files
|
||||
# =========================
|
||||
|
||||
# OSX
|
||||
# =========================
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# VIM backup files
|
||||
*~
|
||||
[._]*.un~
|
||||
*.swp
|
||||
|
||||
# Zephyr build files
|
||||
examples/Zephyr/*/build/*
|
@ -0,0 +1 @@
|
||||
{"type": "library", "name": "SparkFun u-blox Arduino Library", "version": "1.8.11", "spec": {"owner": "sparkfun", "id": 5746, "name": "SparkFun u-blox Arduino Library", "requirements": null, "uri": null}}
|
@ -0,0 +1,20 @@
|
||||
# How to Contribute
|
||||
|
||||
Thank you so *much* for offering to help out. We truly appreciate it.
|
||||
|
||||
If you'd like to contribute, start by searching through the [issues](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/issues) and [pull requests](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/pulls) to see whether someone else has raised a similar idea or question.
|
||||
Please check the [closed issues](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/issues?q=is%3Aissue+is%3Aclosed)
|
||||
and [closed pull requests](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/pulls?q=is%3Apr+is%3Aclosed) too - you may find that your issue or feature has already been discussed.
|
||||
|
||||
If you decide to add a feature to this library, please create a PR and follow these best practices:
|
||||
|
||||
* Change as little as possible. Do not submit a PR that changes 100 lines of whitespace. Break up into multiple PRs if necessary.
|
||||
* If you've added a new feature document it with a simple example sketch. This serves both as a test of your PR and as a quick way for users to quickly learn how to use your new feature.
|
||||
* If you add new functions also add them to _keywords.txt_ so that they are properly highlighted in Arduino. [Read more](https://www.arduino.cc/en/Hacking/libraryTutorial).
|
||||
* **Important:** Please submit your PR using the [release_candidate branch](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/tree/release_candidate). That way, we can merge and test your PR quickly without changing the _master_ branch
|
||||
|
||||

|
||||
|
||||
## Style guide
|
||||
|
||||
Please read and follow the [Arduino API style guide](https://www.arduino.cc/en/Reference/APIStyleGuide). Also read and consider the [Arduino style guide](https://www.arduino.cc/en/Reference/StyleGuide).
|
@ -0,0 +1,18 @@
|
||||
### Subject of the issue
|
||||
Describe your issue here. If you reference a datasheet please specify which one and in which section (ie, the protocol manual, section 5.1.2). Additionally, screenshots are easy to paste into github.
|
||||
|
||||
### Your workbench
|
||||
* What development board or microcontroller are you using?
|
||||
* What version of hardware or breakout board are you using?
|
||||
* How is the breakout board wired to your microcontroller?
|
||||
* How is everything being powered?
|
||||
* Are there any additional details that may help us help you?
|
||||
|
||||
### Steps to reproduce
|
||||
Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue.
|
||||
|
||||
### Expected behavior
|
||||
Tell us what should happen
|
||||
|
||||
### Actual behavior
|
||||
Tell us what happens instead
|
@ -0,0 +1,55 @@
|
||||
SparkFun License Information
|
||||
============================
|
||||
|
||||
SparkFun uses two different licenses for our files — one for hardware and one for code.
|
||||
|
||||
Hardware
|
||||
---------
|
||||
|
||||
**SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).**
|
||||
|
||||
Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode).
|
||||
|
||||
You are free to:
|
||||
|
||||
Share — copy and redistribute the material in any medium or format
|
||||
Adapt — remix, transform, and build upon the material
|
||||
for any purpose, even commercially.
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
|
||||
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
|
||||
|
||||
|
||||
Code
|
||||
--------
|
||||
|
||||
**SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).**
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 SparkFun Electronics
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,163 @@
|
||||
SparkFun u-blox Arduino Library
|
||||
===========================================================
|
||||
|
||||
**Please note: this library is now deprecated. Please migrate to the new [SparkFun u-blox GNSS Arduino Library](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library).**
|
||||
|
||||
**You can find details on how to migrate to v2.0 [here](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library#migrating-to-v20).**
|
||||
|
||||
You can install v2.0 via the Arduino Library Manager. Search for **SparkFun u-blox GNSS**.
|
||||
|
||||
<table class="table table-hover table-striped table-bordered">
|
||||
<tr align="center">
|
||||
<td><a href="https://www.sparkfun.com/products/15136"><img src="https://cdn.sparkfun.com//assets/parts/1/3/5/1/4/15136-SparkFun_GPS-RTK2_Board_-_ZED-F9P__Qwiic_-03.jpg"></a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15005"><img src="https://cdn.sparkfun.com//assets/parts/1/3/3/2/0/15005-SparkFun_GPS-RTK__Qwiic__-_NEO-M8P-2-00.jpg"></a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15193"><img src="https://cdn.sparkfun.com//assets/parts/1/3/6/1/4/15193-SparkFun_GPS_Breakout_-_U.FL__ZOE-M8__Qwiic_-01.jpg"></a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15210"><img src="https://cdn.sparkfun.com//assets/parts/1/3/6/4/8/15210-SparkFun_GPS_Breakout_-_Chip_Antenna__SAM-M8Q__Qwiic_-01.jpg"></a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15733"><img src="https://cdn.sparkfun.com//assets/parts/1/4/3/2/2/15733-SparkFun_GPS_Breakout_-_NEO-M9N__Chip_Antenna__Qwiic_-01.jpg"></a></td>
|
||||
</tr>
|
||||
<tr align="center">
|
||||
<td><a href="https://www.sparkfun.com/products/15136">SparkFun GPS-RTK2 - ZED-F9P (GPS-15136)</a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15005">SparkFun GPS-RTK - NEO-M8P-2 (GPS-15005)</a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15193">SparkFun ZOE-M8Q Breakout (GPS-15193)</a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15210">SparkFun SAM-M8Q Breakout (GPS-15210)</a></td>
|
||||
<td><a href="https://www.sparkfun.com/products/15733">SparkFun NEO-M9N Breakout (GPS-15733)</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
U-blox makes some incredible GPS receivers covering everything from low-cost, highly configurable modules such as the SAM-M8Q all the way up to the surveyor grade ZED-F9P with precision of the diameter of a dime. This library focuses on configuration and control of u-blox devices over I2C (called DDC by u-blox) and Serial. The UBX protocol is supported over both I2C and serial, and is a much easier and lighterweight interface to a GPS module. Stop parsing NMEA data! And simply ask for the datums you need.
|
||||
|
||||
This library can be installed via the Arduino Library manager. Search for **SparkFun u-blox GNSS**.
|
||||
|
||||
Although not an integrated part of the library, you will find an example of how to communicate with the older series 6 and 7 modules in the [examples folder](./examples/Series_6_7).
|
||||
|
||||
Max (400kHz) I2C Support
|
||||
-------------------
|
||||
|
||||
To achieve 400kHz I2C speed please be sure to remove all pull-ups on the I2C bus. Most, if not all, u-blox modules include pull ups on the I2C lines (sometimes called DDC in their manuals). Cut all I2C pull up jumpers and/or remove them from peripheral boards. Otherwise, various data glitches can occur. See issues [38](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/issues/38) and [40](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/issues/40) for more information. If possible, run the I2C bus at 100kHz.
|
||||
|
||||
-------------------
|
||||
|
||||
Want to help? Please do! We are always looking for ways to improve and build out features of this library.
|
||||
|
||||
* We are always interested in adding SPI support with a checkUbloxSPI() function
|
||||
|
||||
Thanks to:
|
||||
|
||||
* [trycoon](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/pull/7) for fixing the lack of I2C buffer length defines.
|
||||
* [tve](https://github.com/tve) for building out serial additions and examples.
|
||||
* [Redstoned](https://github.com/Redstoned) and [davidallenmann](https://github.com/davidallenmann) for adding PVT date and time.
|
||||
* [wittend](https://forum.sparkfun.com/viewtopic.php?t=49874) for pointing out the RTCM print bug.
|
||||
* Big thanks to [PaulZC](https://github.com/PaulZC) for implementing the combined key ValSet method, geofence functions, better saveConfig handling, as well as a bunch of small fixes.
|
||||
* [RollieRowland](https://github.com/RollieRowland) for adding HPPOSLLH (High Precision Geodetic Position).
|
||||
* [tedder](https://github.com/tedder) for moving iTOW to PVT instead of HPPOS and comment cleanup.
|
||||
* [grexjmo](https://github.com/grexjmo) for pushing for a better NMEA sentence configuration method.
|
||||
* [averywallis](https://github.com/averywallis) for adding good comments to the various constants.
|
||||
* [blazczak](https://github.com/blazczak) and [geeksville](https://github.com/geeksville) for adding support for the series 6 and 7 modules.
|
||||
* [bjorn@unsurv](https://github.com/unsurv) for adding powerOff and powerOffWithInterrupt.
|
||||
* [dotMorten](https://github.com/dotMorten) for the MSGOUT keys, autoHPPOSLLH, autoDOP and upgrades to autoPVT.
|
||||
* [markuckermann](https://github.com/markuckermann) for spotting the config layer gremlins
|
||||
* [vid553](https://github.com/vid553) for the Zephyr port
|
||||
* [balamuruganky](https://github.com/balamuruganky) for the NAV-PVT velocity parameters, getSpeedAccEst, getHeadingAccEst, getInvalidLlh, getHeadVeh, getMagDec and getMagAcc
|
||||
* [nelarsen](https://github.com/nelarsen) for the buffer overrun improvements
|
||||
* [mstranne](https://github.com/mstranne) and [shaneperera](https://github.com/shaneperera) for the pushRawData suggestion
|
||||
* [rubienr](https://github.com/rubienr) for spotting the logical AND issues
|
||||
|
||||
Need a Python version for Raspberry Pi? Checkout the [Qwiic Ublox GPS Py module](https://github.com/sparkfun/Qwiic_Ublox_Gps_Py).
|
||||
|
||||
Need a library for the u-blox and Particle? Checkout the [Particle library](https://github.com/aseelye/SparkFun_Ublox_Particle_Library) fork.
|
||||
|
||||
Need a C++ version which runs on Linux? Checkout the [Ublox_Linux_Library](https://github.com/balamuruganky/Ublox_Linux_Library).
|
||||
|
||||
Contributing
|
||||
--------------
|
||||
|
||||
If you would like to contribute to this library: please do, we truly appreciate it, but please follow [these guidelines](./CONTRIBUTING.md). Thanks!
|
||||
|
||||
Repository Contents
|
||||
-------------------
|
||||
|
||||
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
|
||||
* **/src** - Source files for the library (.cpp, .h).
|
||||
* **[keywords.txt](./keywords.txt)** - Keywords from this library that will be highlighted in the Arduino IDE.
|
||||
* **[library.properties](./library.properties)** - General library properties for the Arduino package manager.
|
||||
* **[CONTRIBUTING.md](./CONTRIBUTING.md)** - Guidelines on how to contribute to this library.
|
||||
* **[Theory.md](./Theory.md)** - provides detail on how data is processed by the library.
|
||||
|
||||
Documentation
|
||||
--------------
|
||||
|
||||
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
|
||||
|
||||
Polling vs. Auto-Reporting
|
||||
--------------------------
|
||||
|
||||
This library supports two modes of operation for getting navigation information with the `getPVT`
|
||||
function (based on the `UBX_NAV_PVT` protocol packet): polling and auto-reporting.
|
||||
|
||||
The standard method is for the sketch to call `getPVT` (or one of the `getLatitude`, `getLongitude`,
|
||||
etc. methods) when it needs a fresh navigation solution. At that point the library sends a request
|
||||
to the GPS to produce a fresh solution. The GPS then waits until the next measurement occurs (e.g.
|
||||
once per second or as set using `setNavigationFrequency`) and then sends the fresh data.
|
||||
The advantage of this method is that the data received is always fresh, the downside is that getPVT
|
||||
can block until the next measurement is made by the GPS, e.g. up to 1 second if the nav frequency is
|
||||
set to one second.
|
||||
|
||||
An alternate method can be chosen using `setAutoPVT(true)` which instructs the GPS to send the
|
||||
navigation information (`UBX_NAV_PVT` packet) as soon as it is produced. This is the way the older
|
||||
NMEA navigation data has been used for years. The sketch continues to call `getPVT` as before but
|
||||
under the hood the library returns the data of the last solution received from the GPS, which may be
|
||||
a bit out of date (how much depends on the `setNavigationFrequency` value).
|
||||
|
||||
The advantage of this method is that getPVT does not block: it returns true if new data is available
|
||||
and false otherwise. The disadvantages are that the data may be a bit old and that buffering for
|
||||
these spontaneus `UBX_NAV_PVT` packets is required (100 bytes each). When using Serial the buffering
|
||||
is an issue because the std serial buffer is 32 or 64 bytes long depending on Arduino version. When
|
||||
using I2C the buffering is not an issue because the GPS device has at least 1KB of internal buffering
|
||||
(possibly as large as 4KB).
|
||||
|
||||
As an example, assume that the GPS is set to produce 5 navigation
|
||||
solutions per second and that the sketch only calls getPVT once a second, then the GPS will queue 5
|
||||
packets in its internal buffer (about 500 bytes) and the library will read those when getPVT is
|
||||
called, update its internal copy of the nav data 5 times, and return `true` to the sketch. The
|
||||
sketch calls `getLatitude`, etc. and retrieve the data of the most recent of those 5 packets.
|
||||
|
||||
The library also supports:
|
||||
* `autoHPPOSLLH`
|
||||
* `autoDOP`
|
||||
* `autoHNRAtt`
|
||||
* `autoHNRDyn`
|
||||
* `autoHNRPVT`
|
||||
|
||||
Memory Usage
|
||||
---------------------------------
|
||||
|
||||
Version 1.8.9 introduced support for `autoHNR` on the NEO-M8U, and that tipped the balance in terms of RAM use on the ATmega328.
|
||||
The library does still run on the ATmega328 but you will see _**Low memory available, stability problems may occur**_ warnings
|
||||
as the global variables now occupy 1540 bytes of RAM. If you do want to run this library on the ATmega328, you may need to regress
|
||||
to Version 1.8.8 via the Library Manager.
|
||||
|
||||
Products That Use This Library
|
||||
---------------------------------
|
||||
* [GPS-16481](https://www.sparkfun.com/products/16481) - SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic)
|
||||
* [GPS-15136](https://www.sparkfun.com/products/15136) - SparkFun GPS-RTK2 Board - ZED-F9P (Qwiic)
|
||||
* [GPS-15005](https://www.sparkfun.com/products/15005) - SparkFun GPS-RTK Board - NEO-M8P-2 (Qwiic)
|
||||
* [GPS-15210](https://www.sparkfun.com/products/15210) - SparkFun GPS Breakout - Chip Antenna, SAM-M8Q (Qwiic)
|
||||
* [GPS-15193](https://www.sparkfun.com/products/15193) - SparkFun GPS Breakout - Chip Antenna, ZOE-M8Q (Qwiic)
|
||||
* [GPS-15733](https://www.sparkfun.com/products/15733) - SparkFun GPS Breakout - NEO-M9N, Chip Antenna (Qwiic)
|
||||
* [GPS-15712](https://www.sparkfun.com/products/15712) - SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)
|
||||
* [GPS-16329](https://www.sparkfun.com/products/16329) - SparkFun GPS Dead Reckoning Breakout - NEO-M8U (Qwiic)
|
||||
* [SPX-14980](https://www.sparkfun.com/products/14980) - SparkX GPS-RTK Black
|
||||
* [SPX-15106](https://www.sparkfun.com/products/15106) - SparkX SAM-M8Q
|
||||
|
||||
License Information
|
||||
-------------------
|
||||
|
||||
This product is _**open source**_!
|
||||
|
||||
Various bits of the code have different licenses applied. Anything SparkFun wrote is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!
|
||||
|
||||
Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.
|
||||
|
||||
Distributed as-is; no warranty is given.
|
||||
|
||||
- Your friends at SparkFun.
|
@ -0,0 +1,39 @@
|
||||
How I2C (aka DDC) communication works with a u-blox module
|
||||
===========================================================
|
||||
|
||||
When the user calls one of the methods the library will poll the u-blox module for new data.
|
||||
|
||||
* Wait for a minimum of 25 ms between polls (configured dynamically when update rate is set)
|
||||
* Write 0xFD to module
|
||||
* Read two bytes (0xFD and 0xFE) for bytes available
|
||||
* If 0x7F or 0xFF then no bytes are available
|
||||
* Otherwise, read number of bytes and process into NMEA, UBX, or RTCM frame.
|
||||
* If checksum is valid, flag frame as complete.
|
||||
|
||||
This library was originally written to use the I2C interface but Serial has been implemented as well.
|
||||
|
||||
How data is processed by this library
|
||||
===========================================================
|
||||
|
||||
A method will call **sendCommand()**. This will begin waiting for a response with either **waitForACKResponse()** or **waitForNoACKResponse()** depending on the command we have sent (CFG commands generate an ACK where others like PVT do not).
|
||||
|
||||
Once **waitForACKResponse()** or **waitForNoACKResponse()** is called the library will start checking the u-blox module for new bytes. These bytes may be part of a NMEA sentence, an RTCM sentence, or a UBX packet. The library will file each byte into the appropriate container. Once a given sentence or packet is complete, the appropriate processUBX(), processNMEA() will be called. These functions deal with specific processing for each type.
|
||||
|
||||
Note: When interfacing to a u-blox module over I2C **checkUbloxI2C()** will read all bytes currently sitting in the I2C buffer. This may pick up multiple UBX packets. For example, an ACK for a VALSET may be mixed in with an **AutoPVT** response. We cannot tell **checkUbloxI2C()** to stop once a given ACK is found because we run the risk of leaving unprocessed bytes in the I2C buffer and losing them. We don't have this issue with **checkUbloxSerial()**.
|
||||
|
||||
**processUBX()** will check the CRC of the UBX packet. If validated, the packet will be marked as valid. Once a packet is marked as valid then **processUBXpacket()** is called to extract the contents. This is most commonly used to get the position, velocity, and time (PVT) out of the packet but is also used to check the nature of an ACK packet.
|
||||
|
||||
Once a packet has been processed, **waitForACKResponse()/waitForNoACKResponse()** makes the appropriate decision what to do with it. If a packet satisfies the CLS/ID and characteristics of what **waitForACKResponse()/waitForNoACKResponse()** is waiting for, then it returns back to **sendCommand()**. If the packet didn't match or was invalid then **waitForACKResponse()/waitForNoACKResponse()** will continue to wait until the correct packet is received or we time out. **sendCommand()** then returns with a value from the **sfe_ublox_status_e** enum depending on the success of **waitForACKResponse()/waitForNoACKResponse()**.
|
||||
|
||||
If we are getting / polling data from the module, **sendCommand()** will return **SFE_UBLOX_STATUS_DATA_RECEIVED** if the get was successful.
|
||||
|
||||
If we are setting / writing data to the module, **sendCommand()** will return **SFE_UBLOX_STATUS_DATA_SENT** if the set was successful.
|
||||
|
||||
We are proud that this library still compiles and runs on the original RedBoard (ATmega328P). We achieve that by being very careful about how much RAM we allocate to packet storage. We use only three buffers or containers to store the incoming data:
|
||||
- **packetBuf** (packetBuffer) - is small and is used to store only the head (and tail) of incoming UBX packets until we know they are. If the packet is _expected_ (i.e. it matches the Class and ID in the packet passed in **sendCommand()**) then the incoming bytes are diverted into **packetCfg** or **packetAck**. Unexpected packets are ignored.
|
||||
- **packetCfg** (packetConfiguration) - is used to store an _expected_ incoming UBX packet of up to 256 bytes. E.g. **getProtocolVersion()** returns about 220 bytes. Message data requested by a higher function is returned in packetCfg.
|
||||
- **packetAck** (packetAcknowledge) - is small and is used to store the ACK or NACK accompanying any _expected_ packetCfg.
|
||||
|
||||
**AutoPVT**, **AutoHPPOSLLH** and **AutoDOP** packets can arrive at any time. They too _have_ to be stored and processed in **packetCfg**. This means there are circumstances where the library can get the data it is expecting from the module, but it is overwritten (e.g. by an **AutoPVT** packet) before **sendCommand()** is able to return. In this case, **sendCommand()** will return the error **SFE_UBLOX_STATUS_DATA_OVERWRITTEN**. We should simply call the library function again, but we will need to reset the packet contents first as they will indeed have been overwritten as the error implies.
|
||||
|
||||
Need a command that is not currently "built-in" to the library? You can do that using a Custom Command. Check out [Example20_SendCustomCommand](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/blob/master/examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino) for further details. Note: this will of course increase your RAM use.
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
By: Elias Santistevan
|
||||
SparkFun Electronics
|
||||
Date: May, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
NEO-M8U: https://www.sparkfun.com/products/16329
|
||||
ZED-F9R: https://www.sparkfun.com/products/16344
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a Redboard Qwiic
|
||||
If you don't have a platform with a Qwiic connection use the
|
||||
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
|
||||
To take advantage of the internal IMU of either the Dead Reckoning GPS
|
||||
boards (ZED-F9R, NEO-M8U), you must first calibrate it. This includes securing the GPS module
|
||||
to your vehicle so that it is stable within 2 degrees and that the frame of
|
||||
reference of the board is consistent with the picture outlined in the
|
||||
Receiver-Description-Prot-Spec Datasheet under Automotive/Untethered Dead
|
||||
Reckoning. You may also check either the ZED-F9R or NEO-M8U Hookup Guide for
|
||||
more information. After the board is secure, you'll need to put the module
|
||||
through certain conditions for proper calibration: acceleration, turning,
|
||||
stopping for a few minutes, getting to a speed over 30km/h all under a clear sky
|
||||
with good GNSS signal. This example simply looks at the
|
||||
"fusionMode" status which indicates whether the SparkFun Dead Reckoning is
|
||||
not-calibrated - 0, or calibrated - 1.
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun Ublox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if (myGPS.getEsfInfo()){
|
||||
Serial.print(F("Fusion Mode: "));
|
||||
Serial.println(myGPS.imuMeas.fusionMode);
|
||||
if (myGPS.imuMeas.fusionMode == 1)
|
||||
Serial.println(F("Sensor is calibrated!"));
|
||||
}
|
||||
|
||||
delay(250);
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
By: Elias Santistevan
|
||||
SparkFun Electronics
|
||||
Date: May, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
NEO-M8U: https://www.sparkfun.com/products/16329
|
||||
ZED-F9R: https://www.sparkfun.com/products/16344
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a Redboard Qwiic
|
||||
If you don't have a platform with a Qwiic connection use the
|
||||
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
|
||||
After calibrating the module, also known as "Fusion Mode", you can get
|
||||
data directly from the IMU. This data is integrated directly into the GNSS
|
||||
output, but is provided by the module as well.
|
||||
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun Ublox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
if (myGPS.getEsfInfo()){
|
||||
|
||||
Serial.print(F("Fusion Mode: "));
|
||||
Serial.println(myGPS.imuMeas.fusionMode);
|
||||
|
||||
if (myGPS.imuMeas.fusionMode == 1){
|
||||
Serial.println(F("Fusion Mode is Initialized!"));
|
||||
}
|
||||
else {
|
||||
Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!"));
|
||||
Serial.println(F("Please see Example 1 description at top for more information."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if (myGPS.getEsfIns())
|
||||
{
|
||||
Serial.print(F("X: "));
|
||||
Serial.println(myGPS.imuMeas.xAngRate);
|
||||
Serial.print(F("Y: "));
|
||||
Serial.println(myGPS.imuMeas.yAngRate);
|
||||
Serial.print(F("Z: "));
|
||||
Serial.println(myGPS.imuMeas.zAngRate);
|
||||
Serial.print(F("X Acceleration: "));
|
||||
Serial.println(myGPS.imuMeas.xAccel);
|
||||
Serial.print(F("Y Acceleration: "));
|
||||
Serial.println(myGPS.imuMeas.yAccel);
|
||||
Serial.print(F("Z Acceleration: "));
|
||||
Serial.println(myGPS.imuMeas.zAccel);
|
||||
// These values also have "validity checks" that can be provided by the
|
||||
// ublox library, add "Vald" to values: e.g. xAngRateVald or xAccelVald.
|
||||
}
|
||||
|
||||
delay(250);
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
By: Elias Santistevan
|
||||
SparkFun Electronics
|
||||
Date: May, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
NEO-M8U: https://www.sparkfun.com/products/16329
|
||||
ZED-F9R: https://www.sparkfun.com/products/16344
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a Redboard Qwiic
|
||||
If you don't have a platform with a Qwiic connection use the
|
||||
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
|
||||
After calibrating the module, also known as "Fusion Mode", you can get
|
||||
data directly from the IMU. This example code walks you through trouble
|
||||
shooting or identifying the different states of any individual
|
||||
"external" (which include internal) sensors you've hooked up (vehicle speed
|
||||
sensor) or the internal IMU used by the modules. You can see if the sensor is
|
||||
being used, if it's calibrated, ready, what data type it returns, the state
|
||||
of the measurement etc.
|
||||
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun Ublox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
// GetEsfInfo also gets the number of sensors used by the ublox module, this
|
||||
// includes (in the case of the ZED-F9R) wheel tick input from the vehicle
|
||||
// speed sensor attached to the module.
|
||||
if (myGPS.getEsfInfo()){
|
||||
|
||||
Serial.print(F("Fusion Mode: "));
|
||||
Serial.println(myGPS.imuMeas.fusionMode);
|
||||
|
||||
if (myGPS.imuMeas.fusionMode == 1){
|
||||
Serial.println(F("Fusion Mode is Initialized!"));
|
||||
}
|
||||
else {
|
||||
Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!"));
|
||||
Serial.println(F("Please see Example 1 description at top for more information."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
for(int i=1; i<=myGPS.ubloxSen.numSens; i++){
|
||||
myGPS.getSensState(i); // Give the sensor you want to check on.
|
||||
Serial.print(F("Sensor Data Type: ")); //See ublox receiver description
|
||||
//or our hookup guide for information on the
|
||||
//return value.
|
||||
Serial.println(myGPS.ubloxSen.senType);
|
||||
Serial.print(F("Being Used: "));
|
||||
Serial.println(myGPS.ubloxSen.isUsed);
|
||||
Serial.print(F("Is Ready: "));
|
||||
Serial.println(myGPS.ubloxSen.isReady);
|
||||
Serial.print(F("Calibration Status: "));
|
||||
Serial.println(myGPS.ubloxSen.calibStatus);
|
||||
Serial.print(F("Time Status: "));
|
||||
Serial.println(myGPS.ubloxSen.timeStatus);
|
||||
Serial.print(F("Bad Measure: "));
|
||||
Serial.println(myGPS.ubloxSen.timeStatus);
|
||||
Serial.print(F("Bad Time Tag: "));
|
||||
Serial.println(myGPS.ubloxSen.badTag);
|
||||
Serial.print(F("Missed Measure : "));
|
||||
Serial.println(myGPS.ubloxSen.missMeas);
|
||||
Serial.print(F("Noisy Measure: "));
|
||||
Serial.println(myGPS.ubloxSen.noisyMeas);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
By: Elias Santistevan
|
||||
SparkFun Electronics
|
||||
Date: May, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
NEO-M8U: https://www.sparkfun.com/products/16329
|
||||
ZED-F9R: https://www.sparkfun.com/products/16344
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a Redboard Qwiic
|
||||
If you don't have a platform with a Qwiic connection use the
|
||||
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
|
||||
After calibrating the module and securing it to your vehicle such that it's
|
||||
stable within 2 degrees, and the board is oriented correctly with regards to
|
||||
the vehicle's frame, you can now read the vehicle's "attitude". The attitude
|
||||
includes the vehicle's heading, pitch, and roll. You can also check the
|
||||
accuracy of those readings.
|
||||
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun Ublox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
if (myGPS.getEsfInfo()){
|
||||
|
||||
Serial.print(F("Fusion Mode: "));
|
||||
Serial.println(myGPS.imuMeas.fusionMode);
|
||||
|
||||
if (myGPS.imuMeas.fusionMode == 1){
|
||||
Serial.println(F("Fusion Mode is Initialized!"));
|
||||
}
|
||||
else {
|
||||
Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!"));
|
||||
Serial.println(F("Please see Example 1 description at top for more information."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.getVehAtt(); // Give the sensor you want to check on.
|
||||
Serial.print(F("Roll: "));
|
||||
Serial.println(myGPS.vehAtt.roll);
|
||||
Serial.print(F("Pitch: "));
|
||||
Serial.println(myGPS.vehAtt.pitch);
|
||||
Serial.print(F("Heading: "));
|
||||
Serial.println(myGPS.vehAtt.heading);
|
||||
Serial.print(F("Roll Accuracy: "));
|
||||
Serial.println(myGPS.vehAtt.accRoll);
|
||||
Serial.print(F("Pitch Accuracy: "));
|
||||
Serial.println(myGPS.vehAtt.accPitch);
|
||||
Serial.print(F("Heading Accuracy: "));
|
||||
Serial.println(myGPS.vehAtt.accHeading);
|
||||
|
||||
delay(250);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
By: Paul Clark
|
||||
SparkFun Electronics
|
||||
Date: December, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example configures the High Navigation Rate on the NEO-M8U and then
|
||||
polls and displays the attitude solution, vehicle dynamics information
|
||||
and high rate position, velocity and time.
|
||||
|
||||
This example polls the high rate data.
|
||||
(The next example uses "autoHNR" to receive the HNR data automatically.)
|
||||
|
||||
Please make sure your NEO-M8U is running UDR firmware >= 1.31. Please update using u-center if necessary:
|
||||
https://www.u-blox.com/en/product/neo-m8u-module#tab-documentation-resources
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
NEO-M8U: https://www.sparkfun.com/products/16329
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a Redboard Qwiic
|
||||
If you don't have a platform with a Qwiic connection use the
|
||||
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun u-blox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Warning! u-blox GPS did not begin correctly."));
|
||||
Serial.println(F("(This may be because the I2C port is busy with HNR messages.)"));
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
|
||||
|
||||
if (myGPS.setHNRNavigationRate(10) == true) //Set the High Navigation Rate to 10Hz
|
||||
Serial.println(F("setHNRNavigationRate was successful"));
|
||||
else
|
||||
Serial.println(F("setHNRNavigationRate was NOT successful"));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Poll and print selected HNR data
|
||||
if (myGPS.getHNRAtt(125) == true) // Request HNR Att data using a 125ms timeout
|
||||
{
|
||||
Serial.print(F("Roll: "));
|
||||
Serial.print(myGPS.hnrAtt.roll);
|
||||
Serial.print(F(" Pitch: "));
|
||||
Serial.print(myGPS.hnrAtt.pitch);
|
||||
Serial.print(F(" Heading: "));
|
||||
Serial.println(myGPS.hnrAtt.heading);
|
||||
}
|
||||
if (myGPS.getHNRDyn(125) == true) // Request HNR Dyn data using a 125ms timeout
|
||||
{
|
||||
Serial.print(F("xAccel: "));
|
||||
Serial.print(myGPS.hnrVehDyn.xAccel);
|
||||
Serial.print(F(" yAccel: "));
|
||||
Serial.print(myGPS.hnrVehDyn.yAccel);
|
||||
Serial.print(F(" zAccel: "));
|
||||
Serial.println(myGPS.hnrVehDyn.zAccel);
|
||||
}
|
||||
if (myGPS.getHNRPVT(125) == true) // Request HNR PVT data using a 125ms timeout
|
||||
{
|
||||
Serial.print(F("ns: "));
|
||||
Serial.print(myGPS.hnrPVT.nano);
|
||||
Serial.print(F(" Lat: "));
|
||||
Serial.print(myGPS.hnrPVT.lat);
|
||||
Serial.print(F(" Lon: "));
|
||||
Serial.println(myGPS.hnrPVT.lon);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
By: Paul Clark
|
||||
SparkFun Electronics
|
||||
Date: December, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example configures the High Navigation Rate on the NEO-M8U and then
|
||||
reads and displays the attitude solution, vehicle dynamics information
|
||||
and high rate position, velocity and time.
|
||||
|
||||
This example uses "autoHNR" to receive the HNR data automatically.
|
||||
|
||||
Please make sure your NEO-M8U is running UDR firmware >= 1.31. Please update using u-center if necessary:
|
||||
https://www.u-blox.com/en/product/neo-m8u-module#tab-documentation-resources
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
NEO-M8U: https://www.sparkfun.com/products/16329
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a Redboard Qwiic
|
||||
If you don't have a platform with a Qwiic connection use the
|
||||
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
boolean usingAutoHNRAtt = false;
|
||||
boolean usingAutoHNRDyn = false;
|
||||
boolean usingAutoHNRPVT = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun u-blox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Warning! u-blox GPS did not begin correctly."));
|
||||
Serial.println(F("(This may be because the I2C port is busy with HNR messages.)"));
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
|
||||
|
||||
if (myGPS.setHNRNavigationRate(10) == true) //Set the High Navigation Rate to 10Hz
|
||||
Serial.println(F("setHNRNavigationRate was successful"));
|
||||
else
|
||||
Serial.println(F("setHNRNavigationRate was NOT successful"));
|
||||
|
||||
usingAutoHNRAtt = myGPS.setAutoHNRAtt(true); //Attempt to enable auto HNR attitude messages
|
||||
usingAutoHNRDyn = myGPS.setAutoHNRDyn(true); //Attempt to enable auto HNR vehicle dynamics messages
|
||||
usingAutoHNRPVT = myGPS.setAutoHNRPVT(true); //Attempt to enable auto HNR PVT messages
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (usingAutoHNRAtt && (myGPS.getHNRAtt() == true)) // If setAutoHNRAtt was successful and new data is available
|
||||
{
|
||||
Serial.print(F("Roll: ")); // Print selected data
|
||||
Serial.print(myGPS.hnrAtt.roll);
|
||||
Serial.print(F(" Pitch: "));
|
||||
Serial.print(myGPS.hnrAtt.pitch);
|
||||
Serial.print(F(" Heading: "));
|
||||
Serial.println(myGPS.hnrAtt.heading);
|
||||
}
|
||||
if (usingAutoHNRDyn && (myGPS.getHNRDyn() == true)) // If setAutoHNRDyn was successful and new data is available
|
||||
{
|
||||
Serial.print(F("xAccel: ")); // Print selected data
|
||||
Serial.print(myGPS.hnrVehDyn.xAccel);
|
||||
Serial.print(F(" yAccel: "));
|
||||
Serial.print(myGPS.hnrVehDyn.yAccel);
|
||||
Serial.print(F(" zAccel: "));
|
||||
Serial.println(myGPS.hnrVehDyn.zAccel);
|
||||
}
|
||||
if (usingAutoHNRPVT && (myGPS.getHNRPVT() == true)) // If setAutoHNRPVT was successful and new data is available
|
||||
{
|
||||
Serial.print(F("ns: ")); // Print selected data
|
||||
Serial.print(myGPS.hnrPVT.nano);
|
||||
Serial.print(F(" Lat: "));
|
||||
Serial.print(myGPS.hnrPVT.lat);
|
||||
Serial.print(F(" Lon: "));
|
||||
Serial.println(myGPS.hnrPVT.lon);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
Reading two altitudes - Mean Sea Level and Ellipsode
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for its lat/long/altitude.
|
||||
|
||||
getAltitude() reports mm above ellipsode model of the globe. There are some
|
||||
instances where altitude above Mean Sea Level is better. This example shows how
|
||||
to use getAltitudeMSL(). The difference varies but is ~20m.
|
||||
Ellipsoid model: https://www.esri.com/news/arcuser/0703/geoid1of3.html
|
||||
Difference between Ellipsoid Model and Mean Sea Level: https://eos-gnss.com/elevation-for-beginners/
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Tracks the passing of 2000ms (2 seconds)
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
long altitudeMSL = myGPS.getAltitudeMSL();
|
||||
Serial.print(F(" AltMSL: "));
|
||||
Serial.print(altitudeMSL);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
Send command to reset module over I2C
|
||||
By: Nathan Seidle
|
||||
Date: January 29rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to reset the U-Blox module to factory defaults over I2C.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GNSS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
while (Serial.available()) Serial.read(); //Trash any incoming chars
|
||||
Serial.println("Press a key to reset module to factory defaults");
|
||||
while (Serial.available() == false) ; //Wait for user to send character
|
||||
|
||||
myGPS.factoryReset(); //Reset everything: baud rate, I2C address, update rate, everything.
|
||||
|
||||
if (myGPS.begin() == false) //Attempt to re-connect
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
Serial.println("Unit has now been factory reset. Freezing...");
|
||||
while(1);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Test baud rate changes on serial, factory reset, and hard reset.
|
||||
By: Thorsten von Eicken
|
||||
Date: January 29rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to reset the U-Blox module to factory defaults over serial.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Connect the U-Blox serial port to Serial1
|
||||
If you're using an Uno or don't have a 2nd serial port (Serial1), consider using software serial
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
int state = 0; // steps through auto-baud, reset, etc states
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print("===== STATE ");
|
||||
Serial.println(state);
|
||||
switch (state) {
|
||||
case 0: // auto-baud connection, then switch to 38400 and save config
|
||||
do {
|
||||
Serial.println("GPS: trying 38400 baud");
|
||||
Serial1.begin(38400);
|
||||
if (myGPS.begin(Serial1)) break;
|
||||
|
||||
delay(100);
|
||||
Serial.println("GPS: trying 9600 baud");
|
||||
Serial1.begin(9600);
|
||||
if (myGPS.begin(Serial1)) {
|
||||
Serial.println("GPS: connected at 9600 baud, switching to 38400");
|
||||
myGPS.setSerialRate(38400);
|
||||
delay(100);
|
||||
} else {
|
||||
delay(2000); //Wait a bit before trying again to limit the Serial output flood
|
||||
}
|
||||
} while(1);
|
||||
myGPS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
Serial.println("GPS serial connected, saved config");
|
||||
state++;
|
||||
break;
|
||||
case 1: // hardReset, expect to see GPS back at 38400 baud
|
||||
Serial.println("Issuing hardReset (cold start)");
|
||||
myGPS.hardReset();
|
||||
delay(1000);
|
||||
Serial1.begin(38400);
|
||||
if (myGPS.begin(Serial1)) {
|
||||
Serial.println("Success.");
|
||||
state++;
|
||||
} else {
|
||||
Serial.println("*** GPS did not respond at 38400 baud, starting over.");
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
case 2: // factoryReset, expect to see GPS back at 9600 baud
|
||||
Serial.println("Issuing factoryReset");
|
||||
myGPS.factoryReset();
|
||||
delay(2000); // takes more than one second... a loop to resync would be best
|
||||
Serial1.begin(9600);
|
||||
if (myGPS.begin(Serial1)) {
|
||||
Serial.println("Success.");
|
||||
state++;
|
||||
} else {
|
||||
Serial.println("*** GPS did not come back at 9600 baud, starting over.");
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
case 3: // print version info
|
||||
Serial.print("GPS protocol version: ");
|
||||
Serial.print(myGPS.getProtocolVersionHigh());
|
||||
Serial.print('.');
|
||||
Serial.print(myGPS.getProtocolVersionLow());
|
||||
state = 0;
|
||||
}
|
||||
delay(1000);
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
Reading lat and long via UBX binary commands using UART @38400 baud - free from I2C
|
||||
By: Nathan Seidle, Adapted from Example3_GetPosition by Thorsten von Eicken
|
||||
SparkFun Electronics
|
||||
Date: January 28rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to configure the library and U-Blox for serial port use as well as
|
||||
switching the module from the default 9600 baud to 38400.
|
||||
|
||||
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
|
||||
to something google maps understands simply divide the numbers by 10,000,000. We
|
||||
do this so that we don't have to use floating point numbers.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Connect the U-Blox serial TX pin to Uno pin 10
|
||||
Connect the U-Blox serial RX pin to Uno pin 11
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
SoftwareSerial mySerial(10, 11); // RX, TX. Pin 10 on Uno goes to TX pin on GPS module.
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount of I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
//Assume that the U-Blox GPS is running at 9600 baud (the default) or at 38400 baud.
|
||||
//Loop until we're in sync and then ensure it's at 38400 baud.
|
||||
do {
|
||||
Serial.println("GPS: trying 38400 baud");
|
||||
mySerial.begin(38400);
|
||||
if (myGPS.begin(mySerial) == true) break;
|
||||
|
||||
delay(100);
|
||||
Serial.println("GPS: trying 9600 baud");
|
||||
mySerial.begin(9600);
|
||||
if (myGPS.begin(mySerial) == true) {
|
||||
Serial.println("GPS: connected at 9600 baud, switching to 38400");
|
||||
myGPS.setSerialRate(38400);
|
||||
delay(100);
|
||||
} else {
|
||||
//myGPS.factoryReset();
|
||||
delay(2000); //Wait a bit before trying again to limit the Serial output
|
||||
}
|
||||
} while(1);
|
||||
Serial.println("GPS serial connected");
|
||||
|
||||
myGPS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
Configuring the GPS to automatically send position reports over I2C
|
||||
By: Nathan Seidle and Thorsten von Eicken
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to configure the U-Blox GPS the send navigation reports automatically
|
||||
and retrieving the latest one via getPVT. This eliminates the blocking in getPVT while the GPS
|
||||
produces a fresh navigation solution at the expense of returning a slighly old solution.
|
||||
|
||||
This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS
|
||||
simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in
|
||||
size?) where it can be retrieved in the next I2C poll.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.setNavigationFrequency(2); //Produce two solutions per second
|
||||
myGPS.setAutoPVT(true); //Tell the GPS to "send" each solution
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Calling getPVT returns true if there actually is a fresh navigation solution available.
|
||||
// Start the reading only when valid LLH is available
|
||||
if (myGPS.getPVT() && (myGPS.getInvalidLlh() == false))
|
||||
{
|
||||
Serial.println();
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
int PDOP = myGPS.getPDOP();
|
||||
Serial.print(F(" PDOP: "));
|
||||
Serial.print(PDOP);
|
||||
Serial.print(F(" (10^-2)"));
|
||||
|
||||
int nedNorthVel = myGPS.getNedNorthVel();
|
||||
Serial.print(F(" VelN: "));
|
||||
Serial.print(nedNorthVel);
|
||||
Serial.print(F(" (mm/s)"));
|
||||
|
||||
int nedEastVel = myGPS.getNedEastVel();
|
||||
Serial.print(F(" VelE: "));
|
||||
Serial.print(nedEastVel);
|
||||
Serial.print(F(" (mm/s)"));
|
||||
|
||||
int nedDownVel = myGPS.getNedDownVel();
|
||||
Serial.print(F(" VelD: "));
|
||||
Serial.print(nedDownVel);
|
||||
Serial.print(F(" (mm/s)"));
|
||||
|
||||
int verticalAccEst = myGPS.getVerticalAccEst();
|
||||
Serial.print(F(" VAccEst: "));
|
||||
Serial.print(verticalAccEst);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
int horizontalAccEst = myGPS.getHorizontalAccEst();
|
||||
Serial.print(F(" HAccEst: "));
|
||||
Serial.print(horizontalAccEst);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
int speedAccEst = myGPS.getSpeedAccEst();
|
||||
Serial.print(F(" SpeedAccEst: "));
|
||||
Serial.print(speedAccEst);
|
||||
Serial.print(F(" (mm/s)"));
|
||||
|
||||
int headAccEst = myGPS.getHeadingAccEst();
|
||||
Serial.print(F(" HeadAccEst: "));
|
||||
Serial.print(headAccEst);
|
||||
Serial.print(F(" (degrees * 10^-5)"));
|
||||
|
||||
if (myGPS.getHeadVehValid() == true) {
|
||||
int headVeh = myGPS.getHeadVeh();
|
||||
Serial.print(F(" HeadVeh: "));
|
||||
Serial.print(headVeh);
|
||||
Serial.print(F(" (degrees * 10^-5)"));
|
||||
|
||||
int magDec = myGPS.getMagDec();
|
||||
Serial.print(F(" MagDec: "));
|
||||
Serial.print(magDec);
|
||||
Serial.print(F(" (degrees * 10^-2)"));
|
||||
|
||||
int magAcc = myGPS.getMagAcc();
|
||||
Serial.print(F(" MagAcc: "));
|
||||
Serial.print(magAcc);
|
||||
Serial.print(F(" (degrees * 10^-2)"));
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
} else {
|
||||
Serial.print(".");
|
||||
delay(50);
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
Configuring the GPS to automatically send position reports over I2C, with explicit data parsing calls
|
||||
By: Nathan Seidle Thorsten von Eicken and Felix Jirka
|
||||
SparkFun Electronics
|
||||
Date: July 1st, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to configure the U-Blox GPS the send navigation reports automatically
|
||||
and retrieving the latest one via checkUblox when available.
|
||||
This eliminates the implicit update in getPVT when accessing data fields twice.
|
||||
Also this reduces the memory overhead of a separate buffer while introducing a slight error by inconsistencies because of the unsynchronized updates (on a multi core system).
|
||||
|
||||
This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS
|
||||
simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in
|
||||
size?) where it can be retrieved in the next I2C poll.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.setNavigationFrequency(2); //Produce two solutions per second
|
||||
myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
/*
|
||||
Calling getPVT would return false now (compare to previous example where it would return true), so we just use the data provided
|
||||
If you are using a threaded OS eg. FreeRTOS on an ESP32, the explicit mode of autoPVT allows you to use the data provided on both cores and inside multiple threads
|
||||
The data update in background creates an inconsistent state, but that should not cause issues for most applications as they usually won't change the GPS location significantly within a 2Hz - 5Hz update rate.
|
||||
Also you could oversample (10Hz - 20Hz) the data to smooth out such issues...
|
||||
*/
|
||||
void loop()
|
||||
{
|
||||
static uint16_t counter = 0;
|
||||
|
||||
if (counter % 10 == 0)
|
||||
{
|
||||
// update your AHRS filter here for a ~100Hz update rate
|
||||
// GPS data will be quasi static but data from your IMU will be changing
|
||||
}
|
||||
// debug output each half second
|
||||
if (counter % 500 == 0)
|
||||
{
|
||||
Serial.println();
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
// call checkUblox all 50ms to capture the gps data
|
||||
if (counter % 50 == 0)
|
||||
{
|
||||
myGPS.checkUblox();
|
||||
}
|
||||
delay(1);
|
||||
counter++;
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
Reading lat and long via UBX binary commands using an RX-only UART
|
||||
By: Nathan Seidle, Adapted from Example11 by Felix Jirka
|
||||
SparkFun Electronics
|
||||
Date: July 2nd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to configure the library for serial port use with a single wire connection using the assumeAutoPVT method.
|
||||
Saving your pins for other stuff :-)
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Preconditions:
|
||||
U-Blox module is configured to send cyclical PVT message
|
||||
Hardware Connections:
|
||||
Connect the U-Blox serial TX pin to Rx of Serial2 (default: GPIO16) on your ESP32
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example 17");
|
||||
|
||||
//Use any Serial port with at least a Rx Pin connected or a receive only version of SoftwareSerial here
|
||||
//Assume that the U-Blox GPS is running at 9600 baud (the default)
|
||||
Serial2.begin(9600);
|
||||
// no need to check return value as internal call to isConnected() will not succeed
|
||||
myGPS.begin(Serial2);
|
||||
|
||||
// tell lib, we are expecting the module to send PVT messages by itself to our Rx pin
|
||||
// you can set second parameter to "false" if you want to control the parsing and eviction of the data (need to call checkUblox cyclically)
|
||||
myGPS.assumeAutoPVT(true, true);
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if implicit updates are allowed, this will trigger parsing the incoming messages
|
||||
// and be true once a PVT message has been parsed
|
||||
// In case you want to use explicit updates, wrap this in a timer and call checkUblox as often as needed, not to overflow your UART buffers
|
||||
if (myGPS.getPVT())
|
||||
{
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
else {
|
||||
Serial.println(F("Wait for GPS data"));
|
||||
delay(500);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
Reading lat and long via UBX binary commands using UART @38400 baud - free from I2C
|
||||
By: Nathan Seidle, Adapted from Example3_GetPosition by Thorsten von Eicken
|
||||
SparkFun Electronics
|
||||
Date: January 28rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to configure the debug output from the library.
|
||||
Debug shows various packet and status outputs. These prints can be directed
|
||||
towards Serial (as in Serial.print) or any other port (Serial1, SerialUSB, etc).
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Connect the U-Blox serial TX pin to Uno pin 10
|
||||
Connect the U-Blox serial RX pin to Uno pin 11
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
|
||||
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
Serial.print(myGPS.getYear());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getMonth());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getDay());
|
||||
Serial.print(" ");
|
||||
Serial.print(myGPS.getHour());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getMinute());
|
||||
Serial.print(":");
|
||||
Serial.println(myGPS.getSecond());
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
Getting time and date using Ublox commands
|
||||
By: davidallenmann
|
||||
SparkFun Electronics
|
||||
Date: April 16th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for the current time and date. We also
|
||||
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
|
||||
dramatically.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
Serial.print(myGPS.getYear());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getMonth());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getDay());
|
||||
Serial.print(" ");
|
||||
Serial.print(myGPS.getHour());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getMinute());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getSecond());
|
||||
|
||||
Serial.print(" Time is ");
|
||||
if (myGPS.getTimeValid() == false)
|
||||
{
|
||||
Serial.print("not ");
|
||||
}
|
||||
Serial.print("valid Date is ");
|
||||
if (myGPS.getDateValid() == false)
|
||||
{
|
||||
Serial.print("not ");
|
||||
}
|
||||
Serial.print("valid");
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
Getting time and date using Ublox commands
|
||||
By: davidallenmann
|
||||
SparkFun Electronics
|
||||
Date: April 16th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for the current time and date. We also
|
||||
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
|
||||
dramatically.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(500000); //Increase serial speed to maximize
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
//myGPS.enableDebugging(); //Enable debug messages over Serial (default)
|
||||
|
||||
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
|
||||
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
|
||||
Serial.print("Current update rate:");
|
||||
Serial.println(rate);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Calling getPVT returns true if there actually is a fresh navigation solution available.
|
||||
if (myGPS.getPVT())
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.print(" ");
|
||||
Serial.print(myGPS.getYear());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getMonth());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getDay());
|
||||
Serial.print(" ");
|
||||
Serial.print(myGPS.getHour());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getMinute());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getSecond());
|
||||
Serial.print(".");
|
||||
Serial.print(myGPS.getNanosecond());
|
||||
|
||||
myGPS.flushPVT();
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
Getting time and date using Ublox commands
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: April 16th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to use the Millisecond and Nanosecond output as well as increase the
|
||||
I2C speed (100 to 400kHz), and serial output (115200 to 500kbps).
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(500000); //Increase serial speed to maximize
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
//myGPS.enableDebugging(); //Enable debug messages over Serial (default)
|
||||
|
||||
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
|
||||
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
|
||||
Serial.print("Current update rate:");
|
||||
Serial.println(rate);
|
||||
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
pinMode(2, OUTPUT); //For debug capture
|
||||
digitalWrite(2, HIGH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Calling getPVT returns true if there actually is a fresh navigation solution available.
|
||||
if (myGPS.getPVT())
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.print(" ");
|
||||
Serial.print(myGPS.getYear());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getMonth());
|
||||
Serial.print("-");
|
||||
Serial.print(myGPS.getDay());
|
||||
Serial.print(" ");
|
||||
Serial.print(myGPS.getHour());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getMinute());
|
||||
Serial.print(":");
|
||||
Serial.print(myGPS.getSecond());
|
||||
Serial.print(".");
|
||||
//Pretty print leading zeros
|
||||
int mseconds = myGPS.getMillisecond();
|
||||
if (mseconds < 100)
|
||||
Serial.print("0");
|
||||
if (mseconds < 10)
|
||||
Serial.print("0");
|
||||
Serial.print(mseconds);
|
||||
|
||||
Serial.print(" nanoSeconds: ");
|
||||
Serial.print(myGPS.getNanosecond());
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
/*
|
||||
u-blox M8 geofence example
|
||||
|
||||
Written by Paul Clark (PaulZC)
|
||||
10th December 2019
|
||||
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example demonstrates how to use the addGeofence and getGeofenceState functions
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15210
|
||||
ZOE-M8Q: https://www.sparkfun.com/products/15193
|
||||
|
||||
This example powers up the GPS and reads the fix.
|
||||
Once a valid 3D fix has been found, the code reads the latitude and longitude.
|
||||
The code then sets four geofences around that position with a radii of 5m, 10m, 15m and 20m with 95% confidence.
|
||||
The code then monitors the geofence status.
|
||||
The LED will be illuminated if you are inside the _combined_ geofence (i.e. within the 20m radius).
|
||||
|
||||
This code has been tested on the ZOE-M8Q.
|
||||
*/
|
||||
|
||||
#define LED LED_BUILTIN // Change this if your LED is on a different pin
|
||||
|
||||
#include <Wire.h> // Needed for I2C
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED, OUTPUT);
|
||||
|
||||
// Set up the I2C pins
|
||||
Wire.begin();
|
||||
|
||||
// Start the console serial port
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // Wait for the user to open the serial monitor
|
||||
delay(100);
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println(F("u-blox M8 geofence example"));
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
delay(1000); // Let the GPS power up
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
//myGPS.enableDebugging(); // Enable debug messages
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); // Limit I2C output to UBX (disable the NMEA noise)
|
||||
|
||||
Serial.println(F("Waiting for a 3D fix..."));
|
||||
|
||||
byte fixType = 0;
|
||||
|
||||
while (fixType < 3)
|
||||
{
|
||||
fixType = myGPS.getFixType(); // Get the fix type
|
||||
Serial.print(F("Fix: ")); // Print it
|
||||
Serial.print(fixType);
|
||||
if(fixType == 0) Serial.print(F(" = No fix"));
|
||||
else if(fixType == 1) Serial.print(F(" = Dead reckoning"));
|
||||
else if(fixType == 2) Serial.print(F(" = 2D"));
|
||||
else if(fixType == 3) Serial.print(F(" = 3D"));
|
||||
else if(fixType == 4) Serial.print(F(" = GNSS + Dead reckoning"));
|
||||
else if(fixType == 5) Serial.print(F(" = Time only"));
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
Serial.println(F("3D fix found!"));
|
||||
|
||||
long latitude = myGPS.getLatitude(); // Get the latitude in degrees * 10^-7
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude(); // Get the longitude in degrees * 10^-7
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.println(longitude);
|
||||
|
||||
uint32_t radius = 500; // Set the radius to 5m (radius is in m * 10^-2 i.e. cm)
|
||||
|
||||
byte confidence = 2; // Set the confidence level: 0=none, 1=68%, 2=95%, 3=99.7%, 4=99.99%
|
||||
|
||||
// Call clearGeofences() to clear all existing geofences.
|
||||
Serial.print(F("Clearing any existing geofences. clearGeofences returned: "));
|
||||
Serial.println(myGPS.clearGeofences());
|
||||
|
||||
// It is possible to define up to four geofences.
|
||||
// Call addGeofence up to four times to define them.
|
||||
Serial.println(F("Setting the geofences:"));
|
||||
|
||||
Serial.print(F("addGeofence for geofence 1 returned: "));
|
||||
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
|
||||
|
||||
radius = 1000; // 10m
|
||||
Serial.print(F("addGeofence for geofence 2 returned: "));
|
||||
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
|
||||
|
||||
radius = 1500; // 15m
|
||||
Serial.print(F("addGeofence for geofence 3 returned: "));
|
||||
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
|
||||
|
||||
radius = 2000; // 20m
|
||||
Serial.print(F("addGeofence for geofence 4 returned: "));
|
||||
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
geofenceState currentGeofenceState; // Create storage for the geofence state
|
||||
|
||||
boolean result = myGPS.getGeofenceState(currentGeofenceState);
|
||||
|
||||
Serial.print(F("getGeofenceState returned: ")); // Print the combined state
|
||||
Serial.print(result); // Get the geofence state
|
||||
|
||||
if (!result) // If getGeofenceState did not return true
|
||||
{
|
||||
Serial.println(F(".")); // Tidy up
|
||||
return; // and go round the loop again
|
||||
}
|
||||
|
||||
Serial.print(F(". status is: ")); // Print the status
|
||||
Serial.print(currentGeofenceState.status);
|
||||
|
||||
Serial.print(F(". numFences is: ")); // Print the numFences
|
||||
Serial.print(currentGeofenceState.numFences);
|
||||
|
||||
Serial.print(F(". combState is: ")); // Print the combined state
|
||||
Serial.print(currentGeofenceState.combState);
|
||||
|
||||
if (currentGeofenceState.combState == 0)
|
||||
{
|
||||
Serial.print(F(" = Unknown"));
|
||||
digitalWrite(LED, LOW);
|
||||
}
|
||||
if (currentGeofenceState.combState == 1)
|
||||
{
|
||||
Serial.print(F(" = Inside"));
|
||||
digitalWrite(LED, HIGH);
|
||||
}
|
||||
else if (currentGeofenceState.combState == 2)
|
||||
{
|
||||
Serial.print(F(" = Outside"));
|
||||
digitalWrite(LED, LOW);
|
||||
}
|
||||
|
||||
Serial.print(F(". The individual states are: ")); // Print the state of each geofence
|
||||
for(int i = 0; i < currentGeofenceState.numFences; i++)
|
||||
{
|
||||
if (i > 0) Serial.print(F(","));
|
||||
Serial.print(currentGeofenceState.states[i]);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
delay(1000);
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
Power Save Mode
|
||||
By: Paul Clark (PaulZC)
|
||||
Date: April 22nd, 2020
|
||||
|
||||
Based extensively on Example3_GetPosition
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to put the Ublox module into power save mode and then
|
||||
query its lat/long/altitude. We also turn off the NMEA output on the I2C port.
|
||||
This decreases the amount of I2C traffic dramatically.
|
||||
|
||||
** When it is able to ** the module will reduce its current draw.
|
||||
For the ZOE-M8Q with a passive antenna, you should see the current drop
|
||||
from (approx.) 25-28mA to (approx.) 9mA when power save mode kicks in.
|
||||
|
||||
Note: this will fail on the ZED (protocol version >= 27) as UBX-CFG-RXM is not supported
|
||||
|
||||
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
|
||||
to something google maps understands simply divide the numbers by 10,000,000. We
|
||||
do this so that we don't have to use floating point numbers.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
//myGPS.saveConfiguration(); //Uncomment this line to save the current settings to flash and BBR
|
||||
|
||||
Serial.println("Power save example.");
|
||||
Serial.println("1) Enable power saving");
|
||||
Serial.println("2) Disable power saving");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (Serial.available())
|
||||
{
|
||||
byte incoming = Serial.read();
|
||||
|
||||
if (incoming == '1')
|
||||
{
|
||||
// Put the GNSS into power save mode
|
||||
// (If you want to disable power save mode, call myGPS.powerSaveMode(false) instead)
|
||||
// This will fail on the ZED (protocol version >= 27) as UBX-CFG-RXM is not supported
|
||||
if (myGPS.powerSaveMode()) // Defaults to true
|
||||
Serial.println(F("Power Save Mode enabled."));
|
||||
else
|
||||
Serial.println(F("***!!! Power Save Mode FAILED !!!***"));
|
||||
}
|
||||
else if (incoming == '2')
|
||||
{
|
||||
//Go to normal power mode (not power saving mode)
|
||||
if (myGPS.powerSaveMode(false))
|
||||
Serial.println(F("Power Save Mode disabled."));
|
||||
else
|
||||
Serial.println(F("***!!! Power Save Disable FAILED !!!***"));
|
||||
}
|
||||
|
||||
// Read and print the new low power mode
|
||||
uint8_t lowPowerMode = myGPS.getPowerSaveMode();
|
||||
if (lowPowerMode == 255)
|
||||
{
|
||||
Serial.println(F("***!!! getPowerSaveMode FAILED !!!***"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(F("The low power mode is: "));
|
||||
Serial.print(lowPowerMode);
|
||||
if (lowPowerMode == 0)
|
||||
{
|
||||
Serial.println(F(" (Continuous)"));
|
||||
}
|
||||
else if (lowPowerMode == 1)
|
||||
{
|
||||
Serial.println(F(" (Power Save)"));
|
||||
}
|
||||
else if (lowPowerMode == 4)
|
||||
{
|
||||
Serial.println(F(" (Continuous)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F(" (Unknown!)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Query module every 10 seconds so it is easier to monitor the current draw
|
||||
if (millis() - lastTime > 10000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
byte fixType = myGPS.getFixType(); // Get the fix type
|
||||
Serial.print(F("Fix: "));
|
||||
Serial.print(fixType);
|
||||
if (fixType == 0)
|
||||
Serial.print(F("(No fix)"));
|
||||
else if (fixType == 1)
|
||||
Serial.print(F("(Dead reckoning)"));
|
||||
else if (fixType == 2)
|
||||
Serial.print(F("(2D)"));
|
||||
else if (fixType == 3)
|
||||
Serial.print(F("(3D)"));
|
||||
else if (fixType == 4)
|
||||
Serial.print(F("(GNSS + Dead reckoning)"));
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F(" Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
Set Dynamic Model
|
||||
By: Paul Clark (PaulZC)
|
||||
Date: April 22nd, 2020
|
||||
|
||||
Based extensively on Example3_GetPosition
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to change the Ublox module's dynamic platform model and then
|
||||
query its lat/long/altitude. We also turn off the NMEA output on the I2C port.
|
||||
This decreases the amount of I2C traffic dramatically.
|
||||
|
||||
Possible values for the dynamic model are: PORTABLE, STATIONARY, PEDESTRIAN, AUTOMOTIVE,
|
||||
SEA, AIRBORNE1g, AIRBORNE2g, AIRBORNE4g, WRIST, BIKE
|
||||
|
||||
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
|
||||
to something google maps understands simply divide the numbers by 10,000,000. We
|
||||
do this so that we don't have to use floating point numbers.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun Ublox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
// If we are going to change the dynamic platform model, let's do it here.
|
||||
// Possible values are:
|
||||
// PORTABLE, STATIONARY, PEDESTRIAN, AUTOMOTIVE, SEA, AIRBORNE1g, AIRBORNE2g, AIRBORNE4g, WRIST, BIKE
|
||||
|
||||
if (myGPS.setDynamicModel(DYN_MODEL_PORTABLE) == false) // Set the dynamic model to PORTABLE
|
||||
{
|
||||
Serial.println(F("***!!! Warning: setDynamicModel failed !!!***"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("Dynamic platform model changed successfully!"));
|
||||
}
|
||||
|
||||
// Let's read the new dynamic model to see if it worked
|
||||
uint8_t newDynamicModel = myGPS.getDynamicModel();
|
||||
if (newDynamicModel == 255)
|
||||
{
|
||||
Serial.println(F("***!!! Warning: getDynamicModel failed !!!***"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(F("The new dynamic model is: "));
|
||||
Serial.println(newDynamicModel);
|
||||
}
|
||||
|
||||
//myGPS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); //Uncomment this line to save only the NAV settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Read NMEA sentences over I2C using Ublox module SAM-M8Q, NEO-M8P, ZED-F9P, etc
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: August 22nd, 2018
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example reads the NMEA setences from the Ublox module over I2c and outputs
|
||||
them to the serial port
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false)
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
//This will pipe all NMEA sentences to the serial port so we can see them
|
||||
myGPS.setNMEAOutputPort(Serial);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
/*
|
||||
Send Custom Command
|
||||
By: Paul Clark (PaulZC)
|
||||
Date: April 20th, 2020
|
||||
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how you can create and send a custom UBX packet
|
||||
using the SparkFun u-blox library.
|
||||
|
||||
Previously it was possible to create and send a custom packet
|
||||
through the library but it would always appear to timeout as
|
||||
some of the internal functions referred to the internal private
|
||||
struct packetCfg.
|
||||
The most recent version of the library allows sendCommand to
|
||||
use a custom packet as if it were packetCfg and so:
|
||||
- sendCommand will return a sfe_ublox_status_e enum as if
|
||||
it had been called from within the library
|
||||
- the custom packet will be updated with data returned by the module
|
||||
(previously this was not possible from outside the library)
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#define NAV_RATE 20 // The new navigation rate in Hz (measurements per second)
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200); // You may need to increase this for high navigation rates!
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
// Let's configure the module's navigation rate as if we were using setNavigationFrequency
|
||||
|
||||
// Let's create our custom packet
|
||||
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
|
||||
// The next line creates and initialises the packet information which wraps around the payload
|
||||
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
|
||||
|
||||
// The structure of ubxPacket is:
|
||||
// uint8_t cls : The message Class
|
||||
// uint8_t id : The message ID
|
||||
// uint16_t len : Length of the payload. Does not include cls, id, or checksum bytes
|
||||
// uint16_t counter : Keeps track of number of overall bytes received. Some responses are larger than 255 bytes.
|
||||
// uint16_t startingSpot : The counter value needed to go past before we begin recording into payload array
|
||||
// uint8_t *payload : The payload
|
||||
// uint8_t checksumA : Given to us by the module. Checked against the rolling calculated A/B checksums.
|
||||
// uint8_t checksumB
|
||||
// sfe_ublox_packet_validity_e valid : Goes from NOT_DEFINED to VALID or NOT_VALID when checksum is checked
|
||||
// sfe_ublox_packet_validity_e classAndIDmatch : Goes from NOT_DEFINED to VALID or NOT_VALID when the Class and ID match the requestedClass and requestedID
|
||||
|
||||
// sendCommand will return:
|
||||
// SFE_UBLOX_STATUS_DATA_RECEIVED if the data we requested was read / polled successfully
|
||||
// SFE_UBLOX_STATUS_DATA_SENT if the data we sent was writted successfully (ACK'd)
|
||||
// Other values indicate errors. Please see the sfe_ublox_status_e enum for further details.
|
||||
|
||||
// Referring to the u-blox M8 Receiver Description and Protocol Specification we see that
|
||||
// the navigation rate is configured using the UBX-CFG-RATE message. So let's load our
|
||||
// custom packet with the correct information so we can read (poll / get) the current settings.
|
||||
|
||||
customCfg.cls = UBX_CLASS_CFG; // This is the message Class
|
||||
customCfg.id = UBX_CFG_RATE; // This is the message ID
|
||||
customCfg.len = 0; // Setting the len (length) to zero let's us poll the current settings
|
||||
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
|
||||
|
||||
// We also need to tell sendCommand how long it should wait for a reply
|
||||
uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
|
||||
|
||||
// Now let's read the current navigation rate. The results will be loaded into customCfg.
|
||||
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
|
||||
{
|
||||
Serial.println(F("sendCommand (poll / get) failed! Freezing..."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
// Referring to the message definition for UBX-CFG-RATE we see that the measurement rate
|
||||
// is stored in payload bytes 0 and 1 as a uint16_t in LSB-first (little endian) format
|
||||
|
||||
uint16_t rate = (customPayload[1] << 8) | customPayload[0]; // Extract the current rate (ms)
|
||||
float f_rate = 1000.0 / ((float)rate); // Convert the navigation rate to Hz (measurements per second)
|
||||
|
||||
// Print the current measurement rate
|
||||
Serial.print(F("The current measurement rate is: "));
|
||||
Serial.println(f_rate, 1);
|
||||
|
||||
// Let's change it
|
||||
rate = 1000 / NAV_RATE; // Load the new value into rate
|
||||
customPayload[0] = rate & 0xFF; // Store it in the payload
|
||||
customPayload[1] = rate >> 8;
|
||||
|
||||
// Print the new measurement rate
|
||||
Serial.print(F("The new measurement rate will be: "));
|
||||
Serial.println(NAV_RATE);
|
||||
|
||||
// We don't need to update customCfg.len as it will have been set to 6
|
||||
// when sendCommand read the data
|
||||
|
||||
// Now we write the custom packet back again to change the setting
|
||||
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT) // This time we are only expecting an ACK
|
||||
{
|
||||
Serial.println(F("sendCommand (set) failed! Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("Navigation rate updated. Here we go..."));
|
||||
}
|
||||
|
||||
myGPS.setAutoPVT(true); // Enable AutoPVT. The module will generate measurements automatically without being polled.
|
||||
|
||||
//myGPS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); //Uncomment this line to save only the NAV settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query the module as fast as possible
|
||||
int32_t latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
int32_t longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Lon: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
int32_t altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.println(F(" (mm)"));
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
Module Info - extracts and prints the full module information from UBX_MON_VER
|
||||
using a custom command.
|
||||
By: @mayopan
|
||||
Date: May 9th, 2020
|
||||
|
||||
Based on:
|
||||
Send Custom Command
|
||||
By: Paul Clark (PaulZC)
|
||||
Date: April 20th, 2020
|
||||
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
Previously it was possible to create and send a custom packet
|
||||
through the library but it would always appear to timeout as
|
||||
some of the internal functions referred to the internal private
|
||||
struct packetCfg.
|
||||
The most recent version of the library allows sendCommand to
|
||||
use a custom packet as if it were packetCfg and so:
|
||||
- sendCommand will return a sfe_ublox_status_e enum as if
|
||||
it had been called from within the library
|
||||
- the custom packet will be updated with data returned by the module
|
||||
(previously this was not possible from outside the library)
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#define MAX_PAYLOAD_SIZE 384 // Override MAX_PAYLOAD_SIZE for getModuleInfo which can return up to 348 bytes
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
|
||||
// Extend the class for getModuleInfo
|
||||
class SFE_UBLOX_GPS_ADD : public SFE_UBLOX_GPS
|
||||
{
|
||||
public:
|
||||
boolean getModuleInfo(uint16_t maxWait = 1100); //Queries module, texts
|
||||
|
||||
struct minfoStructure // Structure to hold the module info (uses 341 bytes of RAM)
|
||||
{
|
||||
char swVersion[30];
|
||||
char hwVersion[10];
|
||||
uint8_t extensionNo = 0;
|
||||
char extension[10][30];
|
||||
} minfo;
|
||||
};
|
||||
|
||||
SFE_UBLOX_GPS_ADD myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200); // You may need to increase this for high navigation rates!
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun Ublox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
Serial.print(F("Polling module info"));
|
||||
if (myGPS.getModuleInfo(1100) == false) // Try to get the module info
|
||||
{
|
||||
Serial.print(F("getModuleInfo failed! Freezing..."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println(F("Module Info : "));
|
||||
Serial.print(F("Soft version: "));
|
||||
Serial.println(myGPS.minfo.swVersion);
|
||||
Serial.print(F("Hard version: "));
|
||||
Serial.println(myGPS.minfo.hwVersion);
|
||||
Serial.print(F("Extensions:"));
|
||||
Serial.println(myGPS.minfo.extensionNo);
|
||||
for (int i = 0; i < myGPS.minfo.extensionNo; i++)
|
||||
{
|
||||
Serial.print(" ");
|
||||
Serial.println(myGPS.minfo.extension[i]);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.println(F("Done!"));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
boolean SFE_UBLOX_GPS_ADD::getModuleInfo(uint16_t maxWait)
|
||||
{
|
||||
myGPS.minfo.hwVersion[0] = 0;
|
||||
myGPS.minfo.swVersion[0] = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
myGPS.minfo.extension[i][0] = 0;
|
||||
myGPS.minfo.extensionNo = 0;
|
||||
|
||||
// Let's create our custom packet
|
||||
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
|
||||
|
||||
// The next line creates and initialises the packet information which wraps around the payload
|
||||
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
|
||||
|
||||
// The structure of ubxPacket is:
|
||||
// uint8_t cls : The message Class
|
||||
// uint8_t id : The message ID
|
||||
// uint16_t len : Length of the payload. Does not include cls, id, or checksum bytes
|
||||
// uint16_t counter : Keeps track of number of overall bytes received. Some responses are larger than 255 bytes.
|
||||
// uint16_t startingSpot : The counter value needed to go past before we begin recording into payload array
|
||||
// uint8_t *payload : The payload
|
||||
// uint8_t checksumA : Given to us by the module. Checked against the rolling calculated A/B checksums.
|
||||
// uint8_t checksumB
|
||||
// sfe_ublox_packet_validity_e valid : Goes from NOT_DEFINED to VALID or NOT_VALID when checksum is checked
|
||||
// sfe_ublox_packet_validity_e classAndIDmatch : Goes from NOT_DEFINED to VALID or NOT_VALID when the Class and ID match the requestedClass and requestedID
|
||||
|
||||
// sendCommand will return:
|
||||
// SFE_UBLOX_STATUS_DATA_RECEIVED if the data we requested was read / polled successfully
|
||||
// SFE_UBLOX_STATUS_DATA_SENT if the data we sent was writted successfully (ACK'd)
|
||||
// Other values indicate errors. Please see the sfe_ublox_status_e enum for further details.
|
||||
|
||||
// Referring to the u-blox M8 Receiver Description and Protocol Specification we see that
|
||||
// the module information can be read using the UBX-MON-VER message. So let's load our
|
||||
// custom packet with the correct information so we can read (poll / get) the module information.
|
||||
|
||||
customCfg.cls = UBX_CLASS_MON; // This is the message Class
|
||||
customCfg.id = UBX_MON_VER; // This is the message ID
|
||||
customCfg.len = 0; // Setting the len (length) to zero let's us poll the current settings
|
||||
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
|
||||
|
||||
// Now let's send the command. The module info is returned in customPayload
|
||||
|
||||
if (sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
|
||||
return (false); //If command send fails then bail
|
||||
|
||||
// Now let's extract the module info from customPayload
|
||||
|
||||
uint16_t position = 0;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
minfo.swVersion[i] = customPayload[position];
|
||||
position++;
|
||||
}
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
minfo.hwVersion[i] = customPayload[position];
|
||||
position++;
|
||||
}
|
||||
|
||||
while (customCfg.len >= position + 30)
|
||||
{
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
minfo.extension[minfo.extensionNo][i] = customPayload[position];
|
||||
position++;
|
||||
}
|
||||
minfo.extensionNo++;
|
||||
if (minfo.extensionNo > 9)
|
||||
break;
|
||||
}
|
||||
|
||||
return (true); //Success!
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
Powering off a ublox GPS module
|
||||
By: bjorn
|
||||
unsurv.org
|
||||
Date: July 20th, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows you how to turn off the ublox module to lower the power consumption.
|
||||
There are two functions: one just specifies a duration in milliseconds the other also specifies a pin on the GPS device to wake it up with.
|
||||
By driving a voltage from LOW to HIGH or HIGH to LOW on the chosen module pin you wake the device back up.
|
||||
Note: Doing so on the INT0 pin when using the regular powerOff(durationInMs) function will wake the device anyway. (tested on SAM-M8Q)
|
||||
Note: While powered off, you should not query the device for data or it might wake up. This can be used to wake the device but is not recommended.
|
||||
Works best when also putting your microcontroller to sleep.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard.
|
||||
To force the device to wake up you need to connect to a pin (for example INT0) seperately on the module.
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
|
||||
// define a digital pin capable of driving HIGH and LOW
|
||||
#define WAKEUP_PIN 5
|
||||
|
||||
// Possible GNSS interrupt pins for powerOffWithInterrupt are:
|
||||
// VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX = uartrx
|
||||
// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 = extint0 (default)
|
||||
// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 = extint1
|
||||
// VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS = spics
|
||||
// These values can be or'd (|) together to enable interrupts on multiple pins
|
||||
|
||||
void wakeUp() {
|
||||
|
||||
Serial.print("-- waking up module via pin " + String(WAKEUP_PIN));
|
||||
Serial.println(" on your microcontroller --");
|
||||
|
||||
digitalWrite(WAKEUP_PIN, LOW);
|
||||
delay(1000);
|
||||
digitalWrite(WAKEUP_PIN, HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(WAKEUP_PIN, LOW);
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(WAKEUP_PIN, OUTPUT);
|
||||
digitalWrite(WAKEUP_PIN, LOW);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Powering off for 20s, you should see the power consumption drop.
|
||||
Serial.println("-- Powering off module for 20s --");
|
||||
|
||||
myGPS.powerOff(20000);
|
||||
//myGPS.powerOffWithInterrupt(20000, VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0);
|
||||
|
||||
delay(10000);
|
||||
|
||||
// After 10 seconds wake the device via the specified pin on your microcontroller and module.
|
||||
wakeUp();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//Do nothing
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
Read NMEA sentences over I2C using Ublox module SAM-M8Q, NEO-M8P, etc
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: August 22nd, 2018
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example reads the NMEA characters over I2C and pipes them to MicroNMEA
|
||||
This example will output your current long/lat and satellites in view
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
For more MicroNMEA info see https://github.com/stevemarple/MicroNMEA
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
Go outside! Wait ~25 seconds and you should see your lat/long
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
#include <MicroNMEA.h> //http://librarymanager/All#MicroNMEA
|
||||
char nmeaBuffer[100];
|
||||
MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false)
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
if(nmea.isValid() == true)
|
||||
{
|
||||
long latitude_mdeg = nmea.getLatitude();
|
||||
long longitude_mdeg = nmea.getLongitude();
|
||||
|
||||
Serial.print("Latitude (deg): ");
|
||||
Serial.println(latitude_mdeg / 1000000., 6);
|
||||
Serial.print("Longitude (deg): ");
|
||||
Serial.println(longitude_mdeg / 1000000., 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print("No Fix - ");
|
||||
Serial.print("Num. satellites: ");
|
||||
Serial.println(nmea.getNumSatellites());
|
||||
}
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
||||
|
||||
//This function gets called from the SparkFun Ublox Arduino Library
|
||||
//As each NMEA character comes in you can specify what to do with it
|
||||
//Useful for passing to other libraries like tinyGPS, MicroNMEA, or even
|
||||
//a buffer, radio, etc.
|
||||
void SFE_UBLOX_GPS::processNMEA(char incoming)
|
||||
{
|
||||
//Take the incoming char from the Ublox I2C port and pass it on to the MicroNMEA lib
|
||||
//for sentence cracking
|
||||
nmea.process(incoming);
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
Reading lat and long via UBX binary commands - no more NMEA parsing!
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for its lat/long/altitude. We also
|
||||
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
|
||||
dramatically.
|
||||
|
||||
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
|
||||
to something google maps understands simply divide the numbers by 10,000,000. We
|
||||
do this so that we don't have to use floating point numbers.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
Get fix type and RTK fix type if available
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for fix type and RTK fix type.
|
||||
The fix type is as follows:
|
||||
0 = no fix
|
||||
1 = dead reckoning (requires external sensors)
|
||||
2 = 2D (not quite enough satellites in view)
|
||||
3 = 3D (the standard fix)
|
||||
4 = GNSS + dead reckoning (requires external sensors)
|
||||
5 = Time fix only
|
||||
|
||||
Additionally, if we are doing RTK, we can figure out if we have a floating
|
||||
RTK solution or if we have been able to resolve a fixec solution (better precision).
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Optional. Increase I2C clock speed to 400kHz.
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
|
||||
byte fixType = myGPS.getFixType();
|
||||
Serial.print(F(" Fix: "));
|
||||
if(fixType == 0) Serial.print(F("No fix"));
|
||||
else if(fixType == 1) Serial.print(F("Dead reckoning"));
|
||||
else if(fixType == 2) Serial.print(F("2D"));
|
||||
else if(fixType == 3) Serial.print(F("3D"));
|
||||
else if(fixType == 4) Serial.print(F("GNSS+Dead reckoning"));
|
||||
|
||||
byte RTK = myGPS.getCarrierSolutionType();
|
||||
Serial.print(" RTK: ");
|
||||
Serial.print(RTK);
|
||||
if (RTK == 1) Serial.print(F("High precision float fix!"));
|
||||
if (RTK == 2) Serial.print(F("High precision fix!"));
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
Get Speed/Heading and dilution of precision via UBX binary commands - no more NMEA parsing!
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for its lat/long/altitude.
|
||||
|
||||
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
|
||||
to something google maps understands simply divide the numbers by 1,000,000. We
|
||||
do this so that we don't have to use floating point numbers.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
|
||||
long speed = myGPS.getGroundSpeed();
|
||||
Serial.print(F(" Speed: "));
|
||||
Serial.print(speed);
|
||||
Serial.print(F(" (mm/s)"));
|
||||
|
||||
long heading = myGPS.getHeading();
|
||||
Serial.print(F(" Heading: "));
|
||||
Serial.print(heading);
|
||||
Serial.print(F(" (degrees * 10^-5)"));
|
||||
|
||||
int pDOP = myGPS.getPDOP();
|
||||
Serial.print(F(" pDOP: "));
|
||||
Serial.print(pDOP / 100.0, 2);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
Turn on/off various NMEA sentences.
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to turn on/off the NMEA sentences being output
|
||||
over UART1. We use the I2C interface on the Ublox module for configuration
|
||||
but you won't see any output from this sketch. You'll need to hook up
|
||||
a Serial Basic or other USB to Serial device to UART1 on your Ublox module
|
||||
to see the output.
|
||||
|
||||
This example turns off all sentences except for the GPGGA and GPVTG sentences.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a RedBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
Hookup a Serial Basic (https://www.sparkfun.com/products/15096) to UART1 on the Ublox module. Open a terminal at 57600bps
|
||||
and see GPGGA and GPVTG sentences.
|
||||
*/
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
unsigned long lastGPSSend = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200); // Serial debug output over USB visible from Arduino IDE
|
||||
Serial.println("Example showing how to enable/disable certain NMEA sentences");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false)
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
//Disable or enable various NMEA sentences over the UART1 interface
|
||||
myGPS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_UART1); //Several of these are on by default on virgin ublox board so let's disable them
|
||||
myGPS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1);
|
||||
myGPS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1);
|
||||
myGPS.disableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1);
|
||||
myGPS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1); //Only leaving GGA/VTG enabled at current navigation rate
|
||||
myGPS.enableNMEAMessage(UBX_NMEA_VTG, COM_PORT_UART1);
|
||||
|
||||
//Here's the advanced configure method
|
||||
//Some of the other examples in this library enable the PVT message so let's disable it
|
||||
myGPS.configureMessage(UBX_CLASS_NAV, UBX_NAV_PVT, COM_PORT_UART1, 0); //Message Class, ID, and port we want to configure, sendRate of 0 (disable).
|
||||
|
||||
myGPS.setUART1Output(COM_TYPE_NMEA); //Turn off UBX and RTCM sentences on the UART1 interface
|
||||
|
||||
myGPS.setSerialRate(57600); //Set UART1 to 57600bps.
|
||||
|
||||
myGPS.saveConfiguration(); //Save these settings to NVM
|
||||
|
||||
Serial.println(F("Messages configured. NMEA now being output over the UART1 port on the Ublox module at 57600bps."));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (millis() - lastGPSSend > 200)
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available, but we don't want to get NMEA here. Go check UART1.
|
||||
lastGPSSend = millis();
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
Set update rate to 10Hz
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to increase the output of the module from 1Hz to 4Hz.
|
||||
The max output rate various from model to model. RTFM! But you cannot do harm
|
||||
to the module.
|
||||
|
||||
We also disable NMEA output on the I2C bus and use only UBX. This dramatically
|
||||
decreases the amount of data that needs to be transmitted.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
long startTime = 0; //Used to calc the actual update rate.
|
||||
long updateCount = 0; //Used to calc the actual update rate.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
|
||||
|
||||
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
|
||||
Serial.print("Current update rate:");
|
||||
Serial.println(rate);
|
||||
|
||||
startTime = millis();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available. This is defined
|
||||
//by the update freq.
|
||||
if (millis() - lastTime > 25)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
|
||||
updateCount++;
|
||||
|
||||
//Calculate the actual update rate based on the sketch start time and the
|
||||
//number of updates we've received.
|
||||
Serial.print(F(" Rate: "));
|
||||
Serial.print( updateCount / ((millis() - startTime) / 1000.0), 2);
|
||||
Serial.print(F("Hz"));
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
Reading the protocol version of a Ublox module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for its protocol version.
|
||||
|
||||
Various modules have various protocol version. We've seen v18 up to v27. Depending
|
||||
on the protocol version there are different commands available. This is a handy
|
||||
way to predict which commands will or won't work.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
Serial.print(F("Version: "));
|
||||
byte versionHigh = myGPS.getProtocolVersionHigh();
|
||||
Serial.print(versionHigh);
|
||||
Serial.print(".");
|
||||
byte versionLow = myGPS.getProtocolVersionLow();
|
||||
Serial.print(versionLow);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Do nothing
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
Change the I2C address of a Ublox module using I2C
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to change the I2C address of a Ublox module
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Tracks the passing of 2000ms (2 seconds)
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
byte oldAddress = 0x42; //The default address for Ublox modules is 0x42
|
||||
byte newAddress = 0x3F; //Address you want to change to. Valid is 0x08 to 0x77.
|
||||
|
||||
while (Serial.available()) Serial.read(); //Trash any incoming chars
|
||||
Serial.print("Press a key to change address to 0x");
|
||||
Serial.println(newAddress, HEX);
|
||||
while (Serial.available() == false) ; //Wait for user to send character
|
||||
|
||||
if (myGPS.begin(Wire, oldAddress) == true) //Connect to the Ublox module using Wire port and the old address
|
||||
{
|
||||
Serial.print("GPS found at address 0x");
|
||||
Serial.println(oldAddress, HEX);
|
||||
|
||||
myGPS.setI2CAddress(newAddress); //Change I2C address of this device
|
||||
//Device's I2C address is stored to memory and loaded on each power-on
|
||||
|
||||
if (myGPS.begin(Wire, newAddress) == true)
|
||||
{
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
Serial.print("Address successfully changed to 0x");
|
||||
Serial.println(newAddress, HEX);
|
||||
Serial.print("Now load another example sketch using .begin(Wire, 0x");
|
||||
Serial.print(newAddress, HEX);
|
||||
Serial.println(") to use this GPS module");
|
||||
Serial.println("Freezing...");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
//Something went wrong, begin looking for the I2C device
|
||||
Serial.println("Address change failed. Beginning an I2C scan.");
|
||||
|
||||
Wire.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
byte address;
|
||||
int nDevices;
|
||||
|
||||
Serial.println("Scanning...");
|
||||
|
||||
nDevices = 0;
|
||||
for (address = 1; address < 127; address++ )
|
||||
{
|
||||
Wire.beginTransmission(address);
|
||||
byte error = Wire.endTransmission();
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
Serial.print("I2C device found at address 0x");
|
||||
if (address < 16)
|
||||
Serial.print("0");
|
||||
Serial.print(address, HEX);
|
||||
Serial.println(" !");
|
||||
|
||||
nDevices++;
|
||||
}
|
||||
else if (error == 4)
|
||||
{
|
||||
Serial.print("Unknown error at address 0x");
|
||||
if (address < 16)
|
||||
Serial.print("0");
|
||||
Serial.println(address, HEX);
|
||||
}
|
||||
}
|
||||
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
else
|
||||
Serial.println("done\n");
|
||||
|
||||
delay(5000); // wait 5 seconds for next scan
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on Ublox NEO-M8P module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: September 7th, 2018
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example sends the command to enable the four RTCM messages needed for RTK. This
|
||||
is the first part of a larger tutorial and example to setup an RTK base station.
|
||||
These commands are only accepted by the NEO-M8P module.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while(!Serial); //Wait for user to open terminal
|
||||
Serial.println("Ublox RTCM Enable Example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
while(Serial.available()) Serial.read(); //Clear any latent chars in serial buffer
|
||||
Serial.println("Press any key to send commands to enable RTCM 3.x");
|
||||
while(Serial.available() == 0) ; //Wait for user to press a key
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
boolean response = true;
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1077, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1087, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
|
||||
|
||||
if (response == true)
|
||||
{
|
||||
Serial.println("RTCM messages enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("RTCM failed to enable. Are you sure you have an NEO-M8P?");
|
||||
while(1); //Freeze
|
||||
}
|
||||
|
||||
//RTCM is now enabled but we haven't done a 'survey-in'
|
||||
//See example 4 for the full Base RTK setup
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on Ublox NEO-M8P-2 module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: September 7th, 2018
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example does all steps to configure and enable a NEO-M8P-2 as a base station:
|
||||
Begin Survey-In
|
||||
Once we've achieved 2m accuracy and 300s have passed, survey is complete
|
||||
Enable four RTCM messages
|
||||
Begin outputting RTCM bytes
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("Ublox NEO-M8P-2 base station example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
while (Serial.available()) Serial.read(); //Clear any latent chars in serial buffer
|
||||
Serial.println("Press any key to send commands to begin Survey-In");
|
||||
while (Serial.available() == 0) ; //Wait for user to press a key
|
||||
|
||||
boolean response;
|
||||
|
||||
//Check if Survey is in Progress before initiating one
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println("Failed to get Survey In status");
|
||||
while (1); //Freeze
|
||||
}
|
||||
|
||||
if (myGPS.svin.active == true)
|
||||
{
|
||||
Serial.print("Survey already in progress.");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Start survey
|
||||
response = myGPS.enableSurveyMode(300, 2.000); //Enable Survey in, 300 seconds, 2.0m
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println("Survey start failed");
|
||||
while (1);
|
||||
}
|
||||
Serial.println("Survey started. This will run until 300s has passed and less than 2m accuracy is achieved.");
|
||||
}
|
||||
|
||||
while(Serial.available()) Serial.read(); //Clear buffer
|
||||
|
||||
//Begin waiting for survey to complete
|
||||
while (myGPS.svin.valid == false)
|
||||
{
|
||||
if(Serial.available())
|
||||
{
|
||||
byte incoming = Serial.read();
|
||||
if(incoming == 'x')
|
||||
{
|
||||
//Stop survey mode
|
||||
response = myGPS.disableSurveyMode(); //Disable survey
|
||||
Serial.println("Survey stopped");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
|
||||
if (response == true)
|
||||
{
|
||||
Serial.print("Press x to end survey - ");
|
||||
Serial.print("Time elapsed: ");
|
||||
Serial.print((String)myGPS.svin.observationTime);
|
||||
|
||||
Serial.print(" Accuracy: ");
|
||||
Serial.print((String)myGPS.svin.meanAccuracy);
|
||||
Serial.println();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("SVIN request failed");
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println("Survey valid!");
|
||||
|
||||
response = true;
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1077, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1087, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
|
||||
|
||||
if (response == true)
|
||||
{
|
||||
Serial.println("RTCM messages enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("RTCM failed to enable. Are you sure you have an NEO-M8P?");
|
||||
while (1); //Freeze
|
||||
}
|
||||
|
||||
Serial.println("Base survey complete! RTCM now broadcasting.");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
||||
|
||||
//This function gets called from the SparkFun Ublox Arduino Library.
|
||||
//As each RTCM byte comes in you can specify what to do with it
|
||||
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
|
||||
void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
|
||||
{
|
||||
//Let's just pretty-print the HEX values for now
|
||||
if (myGPS.rtcmFrameCounter % 16 == 0) Serial.println();
|
||||
Serial.print(" ");
|
||||
if (incoming < 0x10) Serial.print("0");
|
||||
Serial.print(incoming, HEX);
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on Ublox NEO-M8P-2 module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: September 7th, 2018
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example does all steps to configure and enable a NEO-M8P-2 as a base station:
|
||||
Begin Survey-In
|
||||
Once we've achieved 2m accuracy and 300s have passed, survey is complete
|
||||
Enable four RTCM messages
|
||||
Begin outputting RTCM bytes
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
Plug a SerLCD onto the Qwiic bus
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Watch the output on the LCD or open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#define STAT_LED 13
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
#include <SerLCD.h> //Click here to get the library: http://librarymanager/All#SparkFun_SerLCD
|
||||
SerLCD lcd; // Initialize the library with default I2C address 0x72
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("Ublox GPS I2C Test");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
pinMode(STAT_LED, OUTPUT);
|
||||
digitalWrite(STAT_LED, LOW);
|
||||
|
||||
lcd.begin(Wire); //Set up the LCD for Serial communication at 9600bps
|
||||
lcd.setBacklight(0x4B0082); //indigo, a kind of dark purplish blue
|
||||
lcd.clear();
|
||||
lcd.print(F("LCD Ready"));
|
||||
|
||||
myGPS.begin(Wire);
|
||||
if (myGPS.isConnected() == false)
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F("No GPS detected"));
|
||||
while (1);
|
||||
}
|
||||
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("GPS Detected");
|
||||
|
||||
//Check if Survey is in Progress before initiating one
|
||||
boolean response;
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Failed to get Survey In status"));
|
||||
while (1); //Freeze
|
||||
}
|
||||
|
||||
if (myGPS.svin.active == true)
|
||||
{
|
||||
Serial.print(F("Survey already in progress."));
|
||||
lcd.setCursor(0, 2);
|
||||
lcd.print(F("Survey already going"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Start survey
|
||||
response = myGPS.enableSurveyMode(300, 2.000); //Enable Survey in, 300 seconds, 2.0m
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Survey start failed"));
|
||||
lcd.setCursor(0, 3);
|
||||
lcd.print(F("Survey start failed"));
|
||||
while (1);
|
||||
}
|
||||
Serial.println(F("Survey started. This will run until 300s has passed and less than 2m accuracy is achieved."));
|
||||
}
|
||||
|
||||
while (Serial.available()) Serial.read(); //Clear buffer
|
||||
|
||||
lcd.clear();
|
||||
lcd.print(F("Survey in progress"));
|
||||
|
||||
//Begin waiting for survey to complete
|
||||
while (myGPS.svin.valid == false)
|
||||
{
|
||||
if (Serial.available())
|
||||
{
|
||||
byte incoming = Serial.read();
|
||||
if (incoming == 'x')
|
||||
{
|
||||
//Stop survey mode
|
||||
response = myGPS.disableSurveyMode(); //Disable survey
|
||||
Serial.println(F("Survey stopped"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
|
||||
if (response == true)
|
||||
{
|
||||
Serial.print(F("Press x to end survey - "));
|
||||
Serial.print(F("Time elapsed: "));
|
||||
Serial.print((String)myGPS.svin.observationTime);
|
||||
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F("Elapsed: "));
|
||||
lcd.print((String)myGPS.svin.observationTime);
|
||||
|
||||
Serial.print(F(" Accuracy: "));
|
||||
Serial.print((String)myGPS.svin.meanAccuracy);
|
||||
Serial.println();
|
||||
|
||||
lcd.setCursor(0, 2);
|
||||
lcd.print(F("Accuracy: "));
|
||||
lcd.print((String)myGPS.svin.meanAccuracy);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("SVIN request failed"));
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println(F("Survey valid!"));
|
||||
|
||||
response = true;
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, UBX_RTCM_I2C_PORT, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1077, UBX_RTCM_I2C_PORT, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1087, UBX_RTCM_I2C_PORT, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, UBX_RTCM_I2C_PORT, 10); //Enable message every 10 seconds
|
||||
|
||||
if (response == true)
|
||||
{
|
||||
Serial.println(F("RTCM messages enabled"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("RTCM failed to enable. Are you sure you have an NEO-M8P?"));
|
||||
while (1); //Freeze
|
||||
}
|
||||
|
||||
Serial.println(F("Base survey complete! RTCM now broadcasting."));
|
||||
lcd.clear();
|
||||
lcd.print(F("Transmitting RTCM"));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
//Do anything you want. Call checkUblox() every second. NEO-M8P-2 has TX buffer of 4k bytes.
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
||||
|
||||
//This function gets called from the SparkFun Ublox Arduino Library.
|
||||
//As each RTCM byte comes in you can specify what to do with it
|
||||
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
|
||||
void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
|
||||
{
|
||||
//Let's just pretty-print the HEX values for now
|
||||
if (myGPS.rtcmFrameCounter % 16 == 0) Serial.println();
|
||||
Serial.print(" ");
|
||||
if (incoming < 0x10) Serial.print("0");
|
||||
Serial.print(incoming, HEX);
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
Reading lat, long and UTC time via UBX binary commands - no more NMEA parsing!
|
||||
By: Paul Clark and Nathan Seidle
|
||||
Using the library modifications provided by @blazczak and @geeksville
|
||||
|
||||
SparkFun Electronics
|
||||
Date: June 16th, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a Ublox module for its lat/long/altitude. We also
|
||||
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
|
||||
dramatically.
|
||||
|
||||
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
|
||||
to something google maps understands simply divide the numbers by 10,000,000. We
|
||||
do this so that we don't have to use floating point numbers.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library_Series_6_7.h"
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
Serial.print(F(" Time: "));
|
||||
|
||||
byte Hour = myGPS.getHour();
|
||||
if (Hour < 10)
|
||||
{
|
||||
Serial.print(F("0"));
|
||||
}
|
||||
Serial.print(Hour);
|
||||
Serial.print(F(":"));
|
||||
|
||||
byte Minute = myGPS.getMinute();
|
||||
if (Minute < 10)
|
||||
{
|
||||
Serial.print(F("0"));
|
||||
}
|
||||
Serial.print(Minute);
|
||||
Serial.print(F(":"));
|
||||
|
||||
byte Second = myGPS.getSecond();
|
||||
if (Second < 10)
|
||||
{
|
||||
Serial.print(F("0"));
|
||||
}
|
||||
Serial.print(Second);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,932 @@
|
||||
/*
|
||||
This is a library written for the Ublox ZED-F9P and NEO-M8P-2
|
||||
|
||||
Updated: June 16th, 2020
|
||||
|
||||
This copy includes changes by @blazczak and @geeksville to
|
||||
provide support for the older series 6 and 7 modules.
|
||||
|
||||
Disclaimer: SparkFun has not verified this copy of the library on either series 6 or 7.
|
||||
It should work, it looks like it will work, but we have no way of confirming this.
|
||||
We cannot guarantee that it will work reliably in your application.
|
||||
|
||||
Do you like this library? Help support SparkFun. Buy a board!
|
||||
https://www.sparkfun.com/products/15136
|
||||
https://www.sparkfun.com/products/15005
|
||||
https://www.sparkfun.com/products/15733
|
||||
https://www.sparkfun.com/products/15193
|
||||
https://www.sparkfun.com/products/15210
|
||||
|
||||
Original library written by Nathan Seidle @ SparkFun Electronics, September 6th, 2018
|
||||
|
||||
This library handles configuring and handling the responses
|
||||
from a Ublox GPS module. Works with most modules from Ublox including
|
||||
the Zed-F9P, NEO-M8P-2, NEO-M9N, ZOE-M8Q, SAM-M8Q, and many others.
|
||||
|
||||
https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library
|
||||
|
||||
Development environment specifics:
|
||||
Arduino IDE 1.8.5
|
||||
|
||||
SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2016 SparkFun Electronics
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to
|
||||
do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SPARKFUN_UBLOX_ARDUINO_LIBRARY_H
|
||||
#define SPARKFUN_UBLOX_ARDUINO_LIBRARY_H
|
||||
|
||||
#if (ARDUINO >= 100)
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
//Platform specific configurations
|
||||
|
||||
//Define the size of the I2C buffer based on the platform the user has
|
||||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
|
||||
|
||||
//I2C_BUFFER_LENGTH is defined in Wire.H
|
||||
#define I2C_BUFFER_LENGTH BUFFER_LENGTH
|
||||
|
||||
#elif defined(__SAMD21G18A__)
|
||||
|
||||
//SAMD21 uses RingBuffer.h
|
||||
#define I2C_BUFFER_LENGTH SERIAL_BUFFER_SIZE
|
||||
|
||||
//#elif __MK20DX256__
|
||||
//Teensy
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef I2C_BUFFER_LENGTH
|
||||
|
||||
//The catch-all default is 32
|
||||
#define I2C_BUFFER_LENGTH 32
|
||||
//#define I2C_BUFFER_LENGTH 16 //For testing on Artemis
|
||||
|
||||
#endif
|
||||
|
||||
// Define Serial for SparkFun SAMD based boards.
|
||||
// Boards like the RedBoard Turbo use SerialUSB (not Serial).
|
||||
// But other boards like the SAMD51 Thing Plus use Serial (not SerialUSB).
|
||||
// The next nine lines let the code compile cleanly on as many SAMD boards as possible.
|
||||
#if defined(ARDUINO_ARCH_SAMD) // Is this a SAMD board?
|
||||
#if defined(USB_VID) // Is the USB Vendor ID defined?
|
||||
#if (USB_VID == 0x1B4F) // Is this a SparkFun board?
|
||||
#if !defined(ARDUINO_SAMD51_THING_PLUS) // If it is not a SAMD51 Thing Plus
|
||||
#define Serial SerialUSB // Define Serial as SerialUSB
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
//Define a digital pin to aid checksum failure capture and analysis
|
||||
//Leave set to -1 if not needed
|
||||
const int checksumFailurePin = -1;
|
||||
|
||||
// Global Status Returns
|
||||
typedef enum
|
||||
{
|
||||
SFE_UBLOX_STATUS_SUCCESS,
|
||||
SFE_UBLOX_STATUS_FAIL,
|
||||
SFE_UBLOX_STATUS_CRC_FAIL,
|
||||
SFE_UBLOX_STATUS_TIMEOUT,
|
||||
SFE_UBLOX_STATUS_COMMAND_NACK, // Indicates that the command was unrecognised, invalid or that the module is too busy to respond
|
||||
SFE_UBLOX_STATUS_OUT_OF_RANGE,
|
||||
SFE_UBLOX_STATUS_INVALID_ARG,
|
||||
SFE_UBLOX_STATUS_INVALID_OPERATION,
|
||||
SFE_UBLOX_STATUS_MEM_ERR,
|
||||
SFE_UBLOX_STATUS_HW_ERR,
|
||||
SFE_UBLOX_STATUS_DATA_SENT, // This indicates that a 'set' was successful
|
||||
SFE_UBLOX_STATUS_DATA_RECEIVED, // This indicates that a 'get' (poll) was successful
|
||||
SFE_UBLOX_STATUS_I2C_COMM_FAILURE,
|
||||
SFE_UBLOX_STATUS_DATA_OVERWRITTEN // This is an error - the data was valid but has been or _is being_ overwritten by another packet
|
||||
} sfe_ublox_status_e;
|
||||
|
||||
// ubxPacket validity
|
||||
typedef enum
|
||||
{
|
||||
SFE_UBLOX_PACKET_VALIDITY_NOT_VALID,
|
||||
SFE_UBLOX_PACKET_VALIDITY_VALID,
|
||||
SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED,
|
||||
SFE_UBLOX_PACKET_NOTACKNOWLEDGED // This indicates that we received a NACK
|
||||
} sfe_ublox_packet_validity_e;
|
||||
|
||||
// Identify which packet buffer is in use:
|
||||
// packetCfg (or a custom packet), packetAck or packetBuf
|
||||
typedef enum
|
||||
{
|
||||
SFE_UBLOX_PACKET_PACKETCFG,
|
||||
SFE_UBLOX_PACKET_PACKETACK,
|
||||
SFE_UBLOX_PACKET_PACKETBUF
|
||||
} sfe_ublox_packet_buffer_e;
|
||||
|
||||
//Registers
|
||||
const uint8_t UBX_SYNCH_1 = 0xB5;
|
||||
const uint8_t UBX_SYNCH_2 = 0x62;
|
||||
|
||||
//The following are UBX Class IDs. Descriptions taken from ZED-F9P Interface Description Document page 32, NEO-M8P Interface Description page 145
|
||||
const uint8_t UBX_CLASS_NAV = 0x01; //Navigation Results Messages: Position, Speed, Time, Acceleration, Heading, DOP, SVs used
|
||||
const uint8_t UBX_CLASS_RXM = 0x02; //Receiver Manager Messages: Satellite Status, RTC Status
|
||||
const uint8_t UBX_CLASS_INF = 0x04; //Information Messages: Printf-Style Messages, with IDs such as Error, Warning, Notice
|
||||
const uint8_t UBX_CLASS_ACK = 0x05; //Ack/Nak Messages: Acknowledge or Reject messages to UBX-CFG input messages
|
||||
const uint8_t UBX_CLASS_CFG = 0x06; //Configuration Input Messages: Configure the receiver.
|
||||
const uint8_t UBX_CLASS_UPD = 0x09; //Firmware Update Messages: Memory/Flash erase/write, Reboot, Flash identification, etc.
|
||||
const uint8_t UBX_CLASS_MON = 0x0A; //Monitoring Messages: Communication Status, CPU Load, Stack Usage, Task Status
|
||||
const uint8_t UBX_CLASS_AID = 0x0B; //(NEO-M8P ONLY!!!) AssistNow Aiding Messages: Ephemeris, Almanac, other A-GPS data input
|
||||
const uint8_t UBX_CLASS_TIM = 0x0D; //Timing Messages: Time Pulse Output, Time Mark Results
|
||||
const uint8_t UBX_CLASS_ESF = 0x10; //(NEO-M8P ONLY!!!) External Sensor Fusion Messages: External Sensor Measurements and Status Information
|
||||
const uint8_t UBX_CLASS_MGA = 0x13; //Multiple GNSS Assistance Messages: Assistance data for various GNSS
|
||||
const uint8_t UBX_CLASS_LOG = 0x21; //Logging Messages: Log creation, deletion, info and retrieval
|
||||
const uint8_t UBX_CLASS_SEC = 0x27; //Security Feature Messages
|
||||
const uint8_t UBX_CLASS_HNR = 0x28; //(NEO-M8P ONLY!!!) High Rate Navigation Results Messages: High rate time, position speed, heading
|
||||
const uint8_t UBX_CLASS_NMEA = 0xF0; //NMEA Strings: standard NMEA strings
|
||||
|
||||
//The following are used for configuration. Descriptions are from the ZED-F9P Interface Description pg 33-34 and NEO-M9N Interface Description pg 47-48
|
||||
const uint8_t UBX_CFG_ANT = 0x13; //Antenna Control Settings. Used to configure the antenna control settings
|
||||
const uint8_t UBX_CFG_BATCH = 0x93; //Get/set data batching configuration.
|
||||
const uint8_t UBX_CFG_CFG = 0x09; //Clear, Save, and Load Configurations. Used to save current configuration
|
||||
const uint8_t UBX_CFG_DAT = 0x06; //Set User-defined Datum or The currently defined Datum
|
||||
const uint8_t UBX_CFG_DGNSS = 0x70; //DGNSS configuration
|
||||
const uint8_t UBX_CFG_GEOFENCE = 0x69; //Geofencing configuration. Used to configure a geofence
|
||||
const uint8_t UBX_CFG_GNSS = 0x3E; //GNSS system configuration
|
||||
const uint8_t UBX_CFG_INF = 0x02; //Depending on packet length, either: poll configuration for one protocol, or information message configuration
|
||||
const uint8_t UBX_CFG_ITFM = 0x39; //Jamming/Interference Monitor configuration
|
||||
const uint8_t UBX_CFG_LOGFILTER = 0x47; //Data Logger Configuration
|
||||
const uint8_t UBX_CFG_MSG = 0x01; //Poll a message configuration, or Set Message Rate(s), or Set Message Rate
|
||||
const uint8_t UBX_CFG_NAV5 = 0x24; //Navigation Engine Settings. Used to configure the navigation engine including the dynamic model.
|
||||
const uint8_t UBX_CFG_NAVX5 = 0x23; //Navigation Engine Expert Settings
|
||||
const uint8_t UBX_CFG_NMEA = 0x17; //Extended NMEA protocol configuration V1
|
||||
const uint8_t UBX_CFG_ODO = 0x1E; //Odometer, Low-speed COG Engine Settings
|
||||
const uint8_t UBX_CFG_PM2 = 0x3B; //Extended power management configuration
|
||||
const uint8_t UBX_CFG_PMS = 0x86; //Power mode setup
|
||||
const uint8_t UBX_CFG_PRT = 0x00; //Used to configure port specifics. Polls the configuration for one I/O Port, or Port configuration for UART ports, or Port configuration for USB port, or Port configuration for SPI port, or Port configuration for DDC port
|
||||
const uint8_t UBX_CFG_PWR = 0x57; //Put receiver in a defined power state
|
||||
const uint8_t UBX_CFG_RATE = 0x08; //Navigation/Measurement Rate Settings. Used to set port baud rates.
|
||||
const uint8_t UBX_CFG_RINV = 0x34; //Contents of Remote Inventory
|
||||
const uint8_t UBX_CFG_RST = 0x04; //Reset Receiver / Clear Backup Data Structures. Used to reset device.
|
||||
const uint8_t UBX_CFG_RXM = 0x11; //RXM configuration
|
||||
const uint8_t UBX_CFG_SBAS = 0x16; //SBAS configuration
|
||||
const uint8_t UBX_CFG_TMODE3 = 0x71; //Time Mode Settings 3. Used to enable Survey In Mode
|
||||
const uint8_t UBX_CFG_TP5 = 0x31; //Time Pulse Parameters
|
||||
const uint8_t UBX_CFG_USB = 0x1B; //USB Configuration
|
||||
const uint8_t UBX_CFG_VALDEL = 0x8C; //Used for config of higher version Ublox modules (ie protocol v27 and above). Deletes values corresponding to provided keys/ provided keys with a transaction
|
||||
const uint8_t UBX_CFG_VALGET = 0x8B; //Used for config of higher version Ublox modules (ie protocol v27 and above). Configuration Items
|
||||
const uint8_t UBX_CFG_VALSET = 0x8A; //Used for config of higher version Ublox modules (ie protocol v27 and above). Sets values corresponding to provided key-value pairs/ provided key-value pairs within a transaction.
|
||||
|
||||
//The following are used to enable NMEA messages. Descriptions come from the NMEA messages overview in the ZED-F9P Interface Description
|
||||
const uint8_t UBX_NMEA_MSB = 0xF0; //All NMEA enable commands have 0xF0 as MSB
|
||||
const uint8_t UBX_NMEA_DTM = 0x0A; //GxDTM (datum reference)
|
||||
const uint8_t UBX_NMEA_GAQ = 0x45; //GxGAQ (poll a standard message (if the current talker ID is GA))
|
||||
const uint8_t UBX_NMEA_GBQ = 0x44; //GxGBQ (poll a standard message (if the current Talker ID is GB))
|
||||
const uint8_t UBX_NMEA_GBS = 0x09; //GxGBS (GNSS satellite fault detection)
|
||||
const uint8_t UBX_NMEA_GGA = 0x00; //GxGGA (Global positioning system fix data)
|
||||
const uint8_t UBX_NMEA_GLL = 0x01; //GxGLL (latitude and long, whith time of position fix and status)
|
||||
const uint8_t UBX_NMEA_GLQ = 0x43; //GxGLQ (poll a standard message (if the current Talker ID is GL))
|
||||
const uint8_t UBX_NMEA_GNQ = 0x42; //GxGNQ (poll a standard message (if the current Talker ID is GN))
|
||||
const uint8_t UBX_NMEA_GNS = 0x0D; //GxGNS (GNSS fix data)
|
||||
const uint8_t UBX_NMEA_GPQ = 0x040; //GxGPQ (poll a standard message (if the current Talker ID is GP))
|
||||
const uint8_t UBX_NMEA_GRS = 0x06; //GxGRS (GNSS range residuals)
|
||||
const uint8_t UBX_NMEA_GSA = 0x02; //GxGSA (GNSS DOP and Active satellites)
|
||||
const uint8_t UBX_NMEA_GST = 0x07; //GxGST (GNSS Pseudo Range Error Statistics)
|
||||
const uint8_t UBX_NMEA_GSV = 0x03; //GxGSV (GNSS satellites in view)
|
||||
const uint8_t UBX_NMEA_RMC = 0x04; //GxRMC (Recommended minimum data)
|
||||
const uint8_t UBX_NMEA_TXT = 0x41; //GxTXT (text transmission)
|
||||
const uint8_t UBX_NMEA_VLW = 0x0F; //GxVLW (dual ground/water distance)
|
||||
const uint8_t UBX_NMEA_VTG = 0x05; //GxVTG (course over ground and Ground speed)
|
||||
const uint8_t UBX_NMEA_ZDA = 0x08; //GxZDA (Time and Date)
|
||||
|
||||
//The following are used to configure the NMEA protocol main talker ID and GSV talker ID
|
||||
const uint8_t UBX_NMEA_MAINTALKERID_NOTOVERRIDDEN = 0x00; //main talker ID is system dependent
|
||||
const uint8_t UBX_NMEA_MAINTALKERID_GP = 0x01; //main talker ID is GPS
|
||||
const uint8_t UBX_NMEA_MAINTALKERID_GL = 0x02; //main talker ID is GLONASS
|
||||
const uint8_t UBX_NMEA_MAINTALKERID_GN = 0x03; //main talker ID is combined receiver
|
||||
const uint8_t UBX_NMEA_MAINTALKERID_GA = 0x04; //main talker ID is Galileo
|
||||
const uint8_t UBX_NMEA_MAINTALKERID_GB = 0x05; //main talker ID is BeiDou
|
||||
const uint8_t UBX_NMEA_GSVTALKERID_GNSS = 0x00; //GNSS specific Talker ID (as defined by NMEA)
|
||||
const uint8_t UBX_NMEA_GSVTALKERID_MAIN = 0x01; //use the main Talker ID
|
||||
|
||||
//The following are used to configure INF UBX messages (information messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 34)
|
||||
const uint8_t UBX_INF_CLASS = 0x04; //All INF messages have 0x04 as the class
|
||||
const uint8_t UBX_INF_DEBUG = 0x04; //ASCII output with debug contents
|
||||
const uint8_t UBX_INF_ERROR = 0x00; //ASCII output with error contents
|
||||
const uint8_t UBX_INF_NOTICE = 0x02; //ASCII output with informational contents
|
||||
const uint8_t UBX_INF_TEST = 0x03; //ASCII output with test contents
|
||||
const uint8_t UBX_INF_WARNING = 0x01; //ASCII output with warning contents
|
||||
|
||||
//The following are used to configure LOG UBX messages (loggings messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 34)
|
||||
const uint8_t UBX_LOG_CREATE = 0x07; //Create Log File
|
||||
const uint8_t UBX_LOG_ERASE = 0x03; //Erase Logged Data
|
||||
const uint8_t UBX_LOG_FINDTIME = 0x0E; //Find index of a log entry based on a given time, or response to FINDTIME requested
|
||||
const uint8_t UBX_LOG_INFO = 0x08; //Poll for log information, or Log information
|
||||
const uint8_t UBX_LOG_RETRIEVEPOSEXTRA = 0x0F; //Odometer log entry
|
||||
const uint8_t UBX_LOG_RETRIEVEPOS = 0x0B; //Position fix log entry
|
||||
const uint8_t UBX_LOG_RETRIEVESTRING = 0x0D; //Byte string log entry
|
||||
const uint8_t UBX_LOG_RETRIEVE = 0x09; //Request log data
|
||||
const uint8_t UBX_LOG_STRING = 0x04; //Store arbitrary string on on-board flash
|
||||
|
||||
//The following are used to configure MGA UBX messages (Multiple GNSS Assistance Messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 34)
|
||||
const uint8_t UBX_MGA_ACK_DATA0 = 0x60; //Multiple GNSS Acknowledge message
|
||||
const uint8_t UBX_MGA_BDS_EPH = 0x03; //BDS Ephemeris Assistance
|
||||
const uint8_t UBX_MGA_BDS_ALM = 0x03; //BDS Almanac Assistance
|
||||
const uint8_t UBX_MGA_BDS_HEALTH = 0x03; //BDS Health Assistance
|
||||
const uint8_t UBX_MGA_BDS_UTC = 0x03; //BDS UTC Assistance
|
||||
const uint8_t UBX_MGA_BDS_IONO = 0x03; //BDS Ionospheric Assistance
|
||||
const uint8_t UBX_MGA_DBD = 0x80; //Either: Poll the Navigation Database, or Navigation Database Dump Entry
|
||||
const uint8_t UBX_MGA_GAL_EPH = 0x02; //Galileo Ephemeris Assistance
|
||||
const uint8_t UBX_MGA_GAL_ALM = 0x02; //Galileo Almanac Assitance
|
||||
const uint8_t UBX_MGA_GAL_TIMOFFSET = 0x02; //Galileo GPS time offset assistance
|
||||
const uint8_t UBX_MGA_GAL_UTC = 0x02; //Galileo UTC Assistance
|
||||
const uint8_t UBX_MGA_GLO_EPH = 0x06; //GLONASS Ephemeris Assistance
|
||||
const uint8_t UBX_MGA_GLO_ALM = 0x06; //GLONASS Almanac Assistance
|
||||
const uint8_t UBX_MGA_GLO_TIMEOFFSET = 0x06; //GLONASS Auxiliary Time Offset Assistance
|
||||
const uint8_t UBX_MGA_GPS_EPH = 0x00; //GPS Ephemeris Assistance
|
||||
const uint8_t UBX_MGA_GPS_ALM = 0x00; //GPS Almanac Assistance
|
||||
const uint8_t UBX_MGA_GPS_HEALTH = 0x00; //GPS Health Assistance
|
||||
const uint8_t UBX_MGA_GPS_UTC = 0x00; //GPS UTC Assistance
|
||||
const uint8_t UBX_MGA_GPS_IONO = 0x00; //GPS Ionosphere Assistance
|
||||
const uint8_t UBX_MGA_INI_POS_XYZ = 0x40; //Initial Position Assistance
|
||||
const uint8_t UBX_MGA_INI_POS_LLH = 0x40; //Initial Position Assitance
|
||||
const uint8_t UBX_MGA_INI_TIME_UTC = 0x40; //Initial Time Assistance
|
||||
const uint8_t UBX_MGA_INI_TIME_GNSS = 0x40; //Initial Time Assistance
|
||||
const uint8_t UBX_MGA_INI_CLKD = 0x40; //Initial Clock Drift Assitance
|
||||
const uint8_t UBX_MGA_INI_FREQ = 0x40; //Initial Frequency Assistance
|
||||
const uint8_t UBX_MGA_INI_EOP = 0x40; //Earth Orientation Parameters Assistance
|
||||
const uint8_t UBX_MGA_QZSS_EPH = 0x05; //QZSS Ephemeris Assistance
|
||||
const uint8_t UBX_MGA_QZSS_ALM = 0x05; //QZSS Almanac Assistance
|
||||
const uint8_t UBX_MGA_QZAA_HEALTH = 0x05; //QZSS Health Assistance
|
||||
|
||||
//The following are used to configure the MON UBX messages (monitoring messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 35)
|
||||
const uint8_t UBX_MON_COMMS = 0x36; //Comm port information
|
||||
const uint8_t UBX_MON_GNSS = 0x28; //Information message major GNSS selection
|
||||
const uint8_t UBX_MON_HW2 = 0x0B; //Extended Hardware Status
|
||||
const uint8_t UBX_MON_HW3 = 0x37; //HW I/O pin information
|
||||
const uint8_t UBX_MON_HW = 0x09; //Hardware Status
|
||||
const uint8_t UBX_MON_IO = 0x02; //I/O Subsystem Status
|
||||
const uint8_t UBX_MON_MSGPP = 0x06; //Message Parse and Process Status
|
||||
const uint8_t UBX_MON_PATCH = 0x27; //Output information about installed patches
|
||||
const uint8_t UBX_MON_RF = 0x38; //RF information
|
||||
const uint8_t UBX_MON_RXBUF = 0x07; //Receiver Buffer Status
|
||||
const uint8_t UBX_MON_RXR = 0x21; //Receiver Status Information
|
||||
const uint8_t UBX_MON_TXBUF = 0x08; //Transmitter Buffer Status. Used for query tx buffer size/state.
|
||||
const uint8_t UBX_MON_VER = 0x04; //Receiver/Software Version. Used for obtaining Protocol Version.
|
||||
|
||||
//The following are used to configure the NAV UBX messages (navigation results messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 35-36)
|
||||
const uint8_t UBX_NAV_ATT = 0x05; //Vehicle "Attitude" Solution
|
||||
const uint8_t UBX_NAV_CLOCK = 0x22; //Clock Solution
|
||||
const uint8_t UBX_NAV_DOP = 0x04; //Dilution of precision
|
||||
const uint8_t UBX_NAV_EOE = 0x61; //End of Epoch
|
||||
const uint8_t UBX_NAV_GEOFENCE = 0x39; //Geofencing status. Used to poll the geofence status
|
||||
const uint8_t UBX_NAV_HPPOSECEF = 0x13; //High Precision Position Solution in ECEF. Used to find our positional accuracy (high precision).
|
||||
const uint8_t UBX_NAV_HPPOSLLH = 0x14; //High Precision Geodetic Position Solution. Used for obtaining lat/long/alt in high precision
|
||||
const uint8_t UBX_NAV_ODO = 0x09; //Odometer Solution
|
||||
const uint8_t UBX_NAV_ORB = 0x34; //GNSS Orbit Database Info
|
||||
const uint8_t UBX_NAV_POSECEF = 0x01; //Position Solution in ECEF
|
||||
const uint8_t UBX_NAV_POSLLH = 0x02; //Geodetic Position Solution
|
||||
const uint8_t UBX_NAV_PVT = 0x07; //All the things! Position, velocity, time, PDOP, height, h/v accuracies, number of satellites. Navigation Position Velocity Time Solution.
|
||||
const uint8_t UBX_NAV_RELPOSNED = 0x3C; //Relative Positioning Information in NED frame
|
||||
const uint8_t UBX_NAV_RESETODO = 0x10; //Reset odometer
|
||||
const uint8_t UBX_NAV_SAT = 0x35; //Satellite Information
|
||||
const uint8_t UBX_NAV_SIG = 0x43; //Signal Information
|
||||
const uint8_t UBX_NAV_STATUS = 0x03; //Receiver Navigation Status
|
||||
const uint8_t UBX_NAV_SVIN = 0x3B; //Survey-in data. Used for checking Survey In status
|
||||
const uint8_t UBX_NAV_TIMEBDS = 0x24; //BDS Time Solution
|
||||
const uint8_t UBX_NAV_TIMEGAL = 0x25; //Galileo Time Solution
|
||||
const uint8_t UBX_NAV_TIMEGLO = 0x23; //GLO Time Solution
|
||||
const uint8_t UBX_NAV_TIMEGPS = 0x20; //GPS Time Solution
|
||||
const uint8_t UBX_NAV_TIMELS = 0x26; //Leap second event information
|
||||
const uint8_t UBX_NAV_TIMEUTC = 0x21; //UTC Time Solution
|
||||
const uint8_t UBX_NAV_VELECEF = 0x11; //Velocity Solution in ECEF
|
||||
const uint8_t UBX_NAV_VELNED = 0x12; //Velocity Solution in NED
|
||||
|
||||
//The following are used to configure the RXM UBX messages (receiver manager messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 36)
|
||||
const uint8_t UBX_RXM_MEASX = 0x14; //Satellite Measurements for RRLP
|
||||
const uint8_t UBX_RXM_PMREQ = 0x41; //Requests a Power Management task (two differenent packet sizes)
|
||||
const uint8_t UBX_RXM_RAWX = 0x15; //Multi-GNSS Raw Measurement Data
|
||||
const uint8_t UBX_RXM_RLM = 0x59; //Galileo SAR Short-RLM report (two different packet sizes)
|
||||
const uint8_t UBX_RXM_RTCM = 0x32; //RTCM input status
|
||||
const uint8_t UBX_RXM_SFRBX = 0x13; //Boradcast Navigation Data Subframe
|
||||
|
||||
//The following are used to configure the SEC UBX messages (security feature messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 36)
|
||||
const uint8_t UBX_SEC_UNIQID = 0x03; //Unique chip ID
|
||||
|
||||
//The following are used to configure the TIM UBX messages (timing messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 36)
|
||||
const uint8_t UBX_TIM_TM2 = 0x03; //Time mark data
|
||||
const uint8_t UBX_TIM_TP = 0x01; //Time Pulse Timedata
|
||||
const uint8_t UBX_TIM_VRFY = 0x06; //Sourced Time Verification
|
||||
|
||||
//The following are used to configure the UPD UBX messages (firmware update messages). Descriptions from UBX messages overview (ZED-F9P Interface Description Document page 36)
|
||||
const uint8_t UBX_UPD_SOS = 0x14; //Poll Backup Fil Restore Status, Create Backup File in Flash, Clear Backup File in Flash, Backup File Creation Acknowledge, System Restored from Backup
|
||||
|
||||
//The following are used to enable RTCM messages
|
||||
const uint8_t UBX_RTCM_MSB = 0xF5; //All RTCM enable commands have 0xF5 as MSB
|
||||
const uint8_t UBX_RTCM_1005 = 0x05; //Stationary RTK reference ARP
|
||||
const uint8_t UBX_RTCM_1074 = 0x4A; //GPS MSM4
|
||||
const uint8_t UBX_RTCM_1077 = 0x4D; //GPS MSM7
|
||||
const uint8_t UBX_RTCM_1084 = 0x54; //GLONASS MSM4
|
||||
const uint8_t UBX_RTCM_1087 = 0x57; //GLONASS MSM7
|
||||
const uint8_t UBX_RTCM_1094 = 0x5E; //Galileo MSM4
|
||||
const uint8_t UBX_RTCM_1097 = 0x61; //Galileo MSM7
|
||||
const uint8_t UBX_RTCM_1124 = 0x7C; //BeiDou MSM4
|
||||
const uint8_t UBX_RTCM_1127 = 0x7F; //BeiDou MSM7
|
||||
const uint8_t UBX_RTCM_1230 = 0xE6; //GLONASS code-phase biases, set to once every 10 seconds
|
||||
const uint8_t UBX_RTCM_4072_0 = 0xFE; //Reference station PVT (ublox proprietary RTCM message)
|
||||
const uint8_t UBX_RTCM_4072_1 = 0xFD; //Additional reference station information (ublox proprietary RTCM message)
|
||||
|
||||
const uint8_t UBX_ACK_NACK = 0x00;
|
||||
const uint8_t UBX_ACK_ACK = 0x01;
|
||||
const uint8_t UBX_ACK_NONE = 0x02; //Not a real value
|
||||
|
||||
// The following constants are used to get External Sensor Measurements and Status
|
||||
// Information.
|
||||
const uint8_t UBX_ESF_MEAS = 0x02;
|
||||
const uint8_t UBX_ESF_RAW = 0x03;
|
||||
const uint8_t UBX_ESF_STATUS = 0x10;
|
||||
const uint8_t UBX_ESF_INS = 0x15; //36 bytes
|
||||
|
||||
const uint8_t SVIN_MODE_DISABLE = 0x00;
|
||||
const uint8_t SVIN_MODE_ENABLE = 0x01;
|
||||
|
||||
//The following consts are used to configure the various ports and streams for those ports. See -CFG-PRT.
|
||||
const uint8_t COM_PORT_I2C = 0;
|
||||
const uint8_t COM_PORT_UART1 = 1;
|
||||
const uint8_t COM_PORT_UART2 = 2;
|
||||
const uint8_t COM_PORT_USB = 3;
|
||||
const uint8_t COM_PORT_SPI = 4;
|
||||
|
||||
const uint8_t COM_TYPE_UBX = (1 << 0);
|
||||
const uint8_t COM_TYPE_NMEA = (1 << 1);
|
||||
const uint8_t COM_TYPE_RTCM3 = (1 << 5);
|
||||
|
||||
//The following consts are used to generate KEY values for the advanced protocol functions of VELGET/SET/DEL
|
||||
const uint8_t VAL_SIZE_1 = 0x01; //One bit
|
||||
const uint8_t VAL_SIZE_8 = 0x02; //One byte
|
||||
const uint8_t VAL_SIZE_16 = 0x03; //Two bytes
|
||||
const uint8_t VAL_SIZE_32 = 0x04; //Four bytes
|
||||
const uint8_t VAL_SIZE_64 = 0x05; //Eight bytes
|
||||
|
||||
//These are the Bitfield layers definitions for the UBX-CFG-VALSET message (not to be confused with Bitfield deviceMask in UBX-CFG-CFG)
|
||||
const uint8_t VAL_LAYER_RAM = (1 << 0);
|
||||
const uint8_t VAL_LAYER_BBR = (1 << 1);
|
||||
const uint8_t VAL_LAYER_FLASH = (1 << 2);
|
||||
|
||||
//Below are various Groups, IDs, and sizes for various settings
|
||||
//These can be used to call getVal/setVal/delVal
|
||||
const uint8_t VAL_GROUP_I2COUTPROT = 0x72;
|
||||
const uint8_t VAL_GROUP_I2COUTPROT_SIZE = VAL_SIZE_1; //All fields in I2C group are currently 1 bit
|
||||
|
||||
const uint8_t VAL_ID_I2COUTPROT_UBX = 0x01;
|
||||
const uint8_t VAL_ID_I2COUTPROT_NMEA = 0x02;
|
||||
const uint8_t VAL_ID_I2COUTPROT_RTCM3 = 0x03;
|
||||
|
||||
const uint8_t VAL_GROUP_I2C = 0x51;
|
||||
const uint8_t VAL_GROUP_I2C_SIZE = VAL_SIZE_8; //All fields in I2C group are currently 1 byte
|
||||
|
||||
const uint8_t VAL_ID_I2C_ADDRESS = 0x01;
|
||||
|
||||
// Configuration Sub-Section mask definitions for saveConfigSelective (UBX-CFG-CFG)
|
||||
const uint32_t VAL_CFG_SUBSEC_IOPORT = 0x00000001; // ioPort - communications port settings (causes IO system reset!)
|
||||
const uint32_t VAL_CFG_SUBSEC_MSGCONF = 0x00000002; // msgConf - message configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_INFMSG = 0x00000004; // infMsg - INF message configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_NAVCONF = 0x00000008; // navConf - navigation configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_RXMCONF = 0x00000010; // rxmConf - receiver manager configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_SENCONF = 0x00000100; // senConf - sensor interface configuration (requires protocol 19+)
|
||||
const uint32_t VAL_CFG_SUBSEC_RINVCONF = 0x00000200; // rinvConf - remove inventory configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_ANTCONF = 0x00000400; // antConf - antenna configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_LOGCONF = 0x00000800; // logConf - logging configuration
|
||||
const uint32_t VAL_CFG_SUBSEC_FTSCONF = 0x00001000; // ftsConf - FTS configuration (FTS products only)
|
||||
|
||||
enum dynModel // Possible values for the dynamic platform model, which provide more accuract position output for the situation. Description extracted from ZED-F9P Integration Manual
|
||||
{
|
||||
DYN_MODEL_PORTABLE = 0, //Applications with low acceleration, e.g. portable devices. Suitable for most situations.
|
||||
// 1 is not defined
|
||||
DYN_MODEL_STATIONARY = 2, //Used in timing applications (antenna must be stationary) or other stationary applications. Velocity restricted to 0 m/s. Zero dynamics assumed.
|
||||
DYN_MODEL_PEDESTRIAN, //Applications with low acceleration and speed, e.g. how a pedestrian would move. Low acceleration assumed.
|
||||
DYN_MODEL_AUTOMOTIVE, //Used for applications with equivalent dynamics to those of a passenger car. Low vertical acceleration assumed
|
||||
DYN_MODEL_SEA, //Recommended for applications at sea, with zero vertical velocity. Zero vertical velocity assumed. Sea level assumed.
|
||||
DYN_MODEL_AIRBORNE1g, //Airborne <1g acceleration. Used for applications with a higher dynamic range and greater vertical acceleration than a passenger car. No 2D position fixes supported.
|
||||
DYN_MODEL_AIRBORNE2g, //Airborne <2g acceleration. Recommended for typical airborne environments. No 2D position fixes supported.
|
||||
DYN_MODEL_AIRBORNE4g, //Airborne <4g acceleration. Only recommended for extremely dynamic environments. No 2D position fixes supported.
|
||||
DYN_MODEL_WRIST, // Not supported in protocol versions less than 18. Only recommended for wrist worn applications. Receiver will filter out arm motion.
|
||||
DYN_MODEL_BIKE, // Supported in protocol versions 19.2
|
||||
};
|
||||
|
||||
#ifndef MAX_PAYLOAD_SIZE
|
||||
|
||||
#define MAX_PAYLOAD_SIZE 256 //We need ~220 bytes for getProtocolVersion on most ublox modules
|
||||
//#define MAX_PAYLOAD_SIZE 768 //Worst case: UBX_CFG_VALSET packet with 64 keyIDs each with 64 bit values
|
||||
|
||||
#endif
|
||||
|
||||
//-=-=-=-=- UBX binary specific variables
|
||||
typedef struct
|
||||
{
|
||||
uint8_t cls;
|
||||
uint8_t id;
|
||||
uint16_t len; //Length of the payload. Does not include cls, id, or checksum bytes
|
||||
uint16_t counter; //Keeps track of number of overall bytes received. Some responses are larger than 255 bytes.
|
||||
uint16_t startingSpot; //The counter value needed to go past before we begin recording into payload array
|
||||
uint8_t *payload;
|
||||
uint8_t checksumA; //Given to us from module. Checked against the rolling calculated A/B checksums.
|
||||
uint8_t checksumB;
|
||||
sfe_ublox_packet_validity_e valid; //Goes from NOT_DEFINED to VALID or NOT_VALID when checksum is checked
|
||||
sfe_ublox_packet_validity_e classAndIDmatch; // Goes from NOT_DEFINED to VALID or NOT_VALID when the Class and ID match the requestedClass and requestedID
|
||||
} ubxPacket;
|
||||
|
||||
// Struct to hold the results returned by getGeofenceState (returned by UBX-NAV-GEOFENCE)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t status; // Geofencing status: 0 - Geofencing not available or not reliable; 1 - Geofencing active
|
||||
uint8_t numFences; // Number of geofences
|
||||
uint8_t combState; // Combined (logical OR) state of all geofences: 0 - Unknown; 1 - Inside; 2 - Outside
|
||||
uint8_t states[4]; // Geofence states: 0 - Unknown; 1 - Inside; 2 - Outside
|
||||
} geofenceState;
|
||||
|
||||
// Struct to hold the current geofence parameters
|
||||
typedef struct
|
||||
{
|
||||
uint8_t numFences; // Number of active geofences
|
||||
int32_t lats[4]; // Latitudes of geofences (in degrees * 10^-7)
|
||||
int32_t longs[4]; // Longitudes of geofences (in degrees * 10^-7)
|
||||
uint32_t rads[4]; // Radii of geofences (in m * 10^-2)
|
||||
} geofenceParams;
|
||||
|
||||
class SFE_UBLOX_GPS
|
||||
{
|
||||
public:
|
||||
SFE_UBLOX_GPS(void);
|
||||
|
||||
// A default of 250ms for maxWait seems fine for I2C but is not enough for SerialUSB.
|
||||
// If you know you are only going to be using I2C / Qwiic communication, you can
|
||||
// safely reduce defaultMaxWait to 250.
|
||||
#ifndef defaultMaxWait // Let's allow the user to define their own value if they want to
|
||||
#define defaultMaxWait 1100
|
||||
#endif
|
||||
|
||||
//By default use the default I2C address, and use Wire port
|
||||
boolean begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42); //Returns true if module is detected
|
||||
//serialPort needs to be perviously initialized to correct baud rate
|
||||
boolean begin(Stream &serialPort); //Returns true if module is detected
|
||||
|
||||
//Returns true if device answers on _gpsI2Caddress address or via Serial
|
||||
//maxWait is only used for Serial
|
||||
boolean isConnected(uint16_t maxWait = 1100);
|
||||
|
||||
//Changed in V1.8.1: provides backward compatibility for the examples that call checkUblox directly
|
||||
//Will default to using packetCfg to look for explicit autoPVT packets so they get processed correctly by processUBX
|
||||
boolean checkUblox(uint8_t requestedClass = UBX_CLASS_NAV, uint8_t requestedID = UBX_NAV_PVT); //Checks module with user selected commType
|
||||
|
||||
boolean checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); //Method for I2C polling of data, passing any new bytes to process()
|
||||
boolean checkUbloxSerial(ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); //Method for serial polling of data, passing any new bytes to process()
|
||||
|
||||
void process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); //Processes NMEA and UBX binary sentences one byte at a time
|
||||
void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); //Given a character, file it away into the uxb packet structure
|
||||
void processRTCMframe(uint8_t incoming); //Monitor the incoming bytes for start and length bytes
|
||||
void processRTCM(uint8_t incoming) __attribute__((weak)); //Given rtcm byte, do something with it. User can overwrite if desired to pipe bytes to radio, internet, etc.
|
||||
|
||||
void processUBXpacket(ubxPacket *msg); //Once a packet has been received and validated, identify this packet's class/id and update internal flags
|
||||
void processNMEA(char incoming) __attribute__((weak)); //Given a NMEA character, do something with it. User can overwrite if desired to use something like tinyGPS or MicroNMEA libraries
|
||||
|
||||
void calcChecksum(ubxPacket *msg); //Sets the checksumA and checksumB of a given messages
|
||||
sfe_ublox_status_e sendCommand(ubxPacket *outgoingUBX, uint16_t maxWait = defaultMaxWait); //Given a packet and payload, send everything including CRC bytes, return true if we got a response
|
||||
sfe_ublox_status_e sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait = 250);
|
||||
void sendSerialCommand(ubxPacket *outgoingUBX);
|
||||
|
||||
void printPacket(ubxPacket *packet); //Useful for debugging
|
||||
|
||||
void factoryReset(); //Send factory reset sequence (i.e. load "default" configuration and perform hardReset)
|
||||
void hardReset(); //Perform a reset leading to a cold start (zero info start-up)
|
||||
|
||||
boolean setI2CAddress(uint8_t deviceAddress, uint16_t maxTime = 250); //Changes the I2C address of the Ublox module
|
||||
void setSerialRate(uint32_t baudrate, uint8_t uartPort = COM_PORT_UART1, uint16_t maxTime = defaultMaxWait); //Changes the serial baud rate of the Ublox module, uartPort should be COM_PORT_UART1/2
|
||||
void setNMEAOutputPort(Stream &nmeaOutputPort); //Sets the internal variable for the port to direct NMEA characters to
|
||||
|
||||
boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second
|
||||
uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module
|
||||
boolean saveConfiguration(uint16_t maxWait = defaultMaxWait); //Save current configuration to flash and BBR (battery backed RAM)
|
||||
boolean factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults
|
||||
boolean saveConfigSelective(uint32_t configMask, uint16_t maxWait = defaultMaxWait); //Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
|
||||
|
||||
sfe_ublox_status_e waitForACKResponse(ubxPacket *outgoingUBX, uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = defaultMaxWait); //Poll the module until a config packet and an ACK is received
|
||||
sfe_ublox_status_e waitForNoACKResponse(ubxPacket *outgoingUBX, uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = defaultMaxWait); //Poll the module until a config packet is received
|
||||
|
||||
// getPVT will only return data once in each navigation cycle. By default, that is once per second.
|
||||
// Therefore we should set getPVTmaxWait to slightly longer than that.
|
||||
// If you change the navigation frequency to (e.g.) 4Hz using setNavigationFrequency(4)
|
||||
// then you should use a shorter maxWait for getPVT. 300msec would be about right: getPVT(300)
|
||||
// The same is true for getHPPOSLLH.
|
||||
#define getPVTmaxWait 1100 // Default maxWait for getPVT and all functions which call it
|
||||
#define getHPPOSLLHmaxWait 1100 // Default maxWait for getHPPOSLLH and all functions which call it
|
||||
|
||||
boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
|
||||
boolean setAutoPVT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic PVT reports at the navigation frequency
|
||||
boolean getPVT(uint16_t maxWait = getPVTmaxWait); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Returns true if new PVT is available.
|
||||
boolean getTimeData(uint16_t maxWait = getPVTmaxWait); //Query module for latest time data. Calls getPVT or getTIMEUTC depending on which module is attached.
|
||||
boolean getPositionData(uint16_t maxWait = getPVTmaxWait); //Query module for latest position data. Calls getPVT or getPOSLLH depending on which module is attached.
|
||||
boolean getTIMEUTC(uint16_t maxWait = getPVTmaxWait); //Query module for current time (for use with older chip series). Returns true if new data is available.
|
||||
boolean getPOSLLH(uint16_t maxWait = getPVTmaxWait); //Query module for current position (for use with older chip series). Returns true if new data is available.
|
||||
|
||||
boolean setAutoPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic PVT reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
|
||||
boolean getHPPOSLLH(uint16_t maxWait = getHPPOSLLHmaxWait); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Returns true if new PVT is available.
|
||||
void flushPVT(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
|
||||
|
||||
int32_t getLatitude(uint16_t maxWait = getPVTmaxWait); //Returns the current latitude in degrees * 10^-7. Auto selects between HighPrecision and Regular depending on ability of module.
|
||||
int32_t getLongitude(uint16_t maxWait = getPVTmaxWait); //Returns the current longitude in degrees * 10-7. Auto selects between HighPrecision and Regular depending on ability of module.
|
||||
int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid
|
||||
int32_t getAltitudeMSL(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above mean sea level
|
||||
uint8_t getSIV(uint16_t maxWait = getPVTmaxWait); //Returns number of sats used in fix
|
||||
uint8_t getFixType(uint16_t maxWait = getPVTmaxWait); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
|
||||
uint8_t getCarrierSolutionType(uint16_t maxWait = getPVTmaxWait); //Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
|
||||
int32_t getGroundSpeed(uint16_t maxWait = getPVTmaxWait); //Returns speed in mm/s
|
||||
int32_t getHeading(uint16_t maxWait = getPVTmaxWait); //Returns heading in degrees * 10^-7
|
||||
uint16_t getPDOP(uint16_t maxWait = getPVTmaxWait); //Returns positional dillution of precision * 10^-2 (dimensionless)
|
||||
uint16_t getYear(uint16_t maxWait = getPVTmaxWait);
|
||||
uint8_t getMonth(uint16_t maxWait = getPVTmaxWait);
|
||||
uint8_t getDay(uint16_t maxWait = getPVTmaxWait);
|
||||
uint8_t getHour(uint16_t maxWait = getPVTmaxWait);
|
||||
uint8_t getMinute(uint16_t maxWait = getPVTmaxWait);
|
||||
uint8_t getSecond(uint16_t maxWait = getPVTmaxWait);
|
||||
uint16_t getMillisecond(uint16_t maxWait = getPVTmaxWait);
|
||||
int32_t getNanosecond(uint16_t maxWait = getPVTmaxWait);
|
||||
uint32_t getTimeOfWeek(uint16_t maxWait = getPVTmaxWait);
|
||||
|
||||
int32_t getHighResLatitude(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int8_t getHighResLatitudeHp(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int32_t getHighResLongitude(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int8_t getHighResLongitudeHp(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int32_t getElipsoid(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int8_t getElipsoidHp(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int32_t getMeanSeaLevel(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int8_t getMeanSeaLevelHp(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
int32_t getGeoidSeparation(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
uint32_t getHorizontalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
uint32_t getVerticalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);
|
||||
|
||||
//Port configurations
|
||||
boolean setPortOutput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure a given port to output UBX, NMEA, RTCM3 or a combination thereof
|
||||
boolean setPortInput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure a given port to input UBX, NMEA, RTCM3 or a combination thereof
|
||||
boolean getPortSettings(uint8_t portID, uint16_t maxWait = defaultMaxWait); //Returns the current protocol bits in the UBX-CFG-PRT command for a given port
|
||||
|
||||
boolean setI2COutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure I2C port to output UBX, NMEA, RTCM3 or a combination thereof
|
||||
boolean setUART1Output(uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure UART1 port to output UBX, NMEA, RTCM3 or a combination thereof
|
||||
boolean setUART2Output(uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure UART2 port to output UBX, NMEA, RTCM3 or a combination thereof
|
||||
boolean setUSBOutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure USB port to output UBX, NMEA, RTCM3 or a combination thereof
|
||||
boolean setSPIOutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure SPI port to output UBX, NMEA, RTCM3 or a combination thereof
|
||||
|
||||
//Functions to turn on/off message types for a given port ID (see COM_PORT_I2C, etc above)
|
||||
boolean configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate, uint16_t maxWait = defaultMaxWait);
|
||||
boolean enableMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate = 1, uint16_t maxWait = defaultMaxWait);
|
||||
boolean disableMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint16_t maxWait = defaultMaxWait);
|
||||
boolean enableNMEAMessage(uint8_t msgID, uint8_t portID, uint8_t sendRate = 1, uint16_t maxWait = defaultMaxWait);
|
||||
boolean disableNMEAMessage(uint8_t msgID, uint8_t portID, uint16_t maxWait = defaultMaxWait);
|
||||
boolean enableRTCMmessage(uint8_t messageNumber, uint8_t portID, uint8_t sendRate, uint16_t maxWait = defaultMaxWait); //Given a message number turns on a message ID for output over given PortID
|
||||
boolean disableRTCMmessage(uint8_t messageNumber, uint8_t portID, uint16_t maxWait = defaultMaxWait); //Turn off given RTCM message from a given port
|
||||
|
||||
//General configuration (used only on protocol v27 and higher - ie, ZED-F9P)
|
||||
//It is probably safe to assume that users of the ZED-F9P will be using I2C / Qwiic.
|
||||
//If they are using Serial then the higher baud rate will also help. So let's leave maxWait set to 250ms.
|
||||
uint8_t getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
|
||||
uint8_t getVal8(uint32_t keyID, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
|
||||
uint8_t setVal(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
|
||||
uint8_t setVal8(uint32_t keyID, uint8_t value, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Sets the 8-bit value at a given group/id/size location
|
||||
uint8_t setVal16(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
|
||||
uint8_t setVal32(uint32_t keyID, uint32_t value, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Sets the 32-bit value at a given group/id/size location
|
||||
uint8_t newCfgValset8(uint32_t keyID, uint8_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 8-bit value
|
||||
uint8_t newCfgValset16(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 16-bit value
|
||||
uint8_t newCfgValset32(uint32_t keyID, uint32_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 32-bit value
|
||||
uint8_t addCfgValset8(uint32_t keyID, uint8_t value); //Add a new KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket
|
||||
uint8_t addCfgValset16(uint32_t keyID, uint16_t value); //Add a new KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket
|
||||
uint8_t addCfgValset32(uint32_t keyID, uint32_t value); //Add a new KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket
|
||||
uint8_t sendCfgValset8(uint32_t keyID, uint8_t value, uint16_t maxWait = 250); //Add the final KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
|
||||
uint8_t sendCfgValset16(uint32_t keyID, uint16_t value, uint16_t maxWait = 250); //Add the final KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
|
||||
uint8_t sendCfgValset32(uint32_t keyID, uint32_t value, uint16_t maxWait = 250); //Add the final KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
|
||||
|
||||
//Functions used for RTK and base station setup
|
||||
//It is probably safe to assume that users of the RTK will be using I2C / Qwiic. So let's leave maxWait set to 250ms.
|
||||
boolean getSurveyMode(uint16_t maxWait = 250); //Get the current TimeMode3 settings
|
||||
boolean setSurveyMode(uint8_t mode, uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); //Control survey in mode
|
||||
boolean enableSurveyMode(uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); //Begin Survey-In for NEO-M8P
|
||||
boolean disableSurveyMode(uint16_t maxWait = 250); //Stop Survey-In mode
|
||||
|
||||
boolean getSurveyStatus(uint16_t maxWait); //Reads survey in status and sets the global variables
|
||||
|
||||
uint32_t getPositionAccuracy(uint16_t maxWait = 1100); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P,
|
||||
|
||||
uint8_t getProtocolVersionHigh(uint16_t maxWait = 500); //Returns the PROTVER XX.00 from UBX-MON-VER register
|
||||
uint8_t getProtocolVersionLow(uint16_t maxWait = 500); //Returns the PROTVER 00.XX from UBX-MON-VER register
|
||||
boolean getProtocolVersion(uint16_t maxWait = 500); //Queries module, loads low/high bytes
|
||||
|
||||
boolean getRELPOSNED(uint16_t maxWait = 1100); //Get Relative Positioning Information of the NED frame
|
||||
|
||||
void enableDebugging(Stream &debugPort = Serial, boolean printLimitedDebug = false); //Given a port to print to, enable debug messages. Default to all, not limited.
|
||||
void disableDebugging(void); //Turn off debug statements
|
||||
void debugPrint(char *message); //Safely print debug statements
|
||||
void debugPrintln(char *message); //Safely print debug statements
|
||||
const char *statusString(sfe_ublox_status_e stat); //Pretty print the return value
|
||||
|
||||
//Support for geofences
|
||||
boolean addGeofence(int32_t latitude, int32_t longitude, uint32_t radius, byte confidence = 0, byte pinPolarity = 0, byte pin = 0, uint16_t maxWait = 1100); // Add a new geofence
|
||||
boolean clearGeofences(uint16_t maxWait = 1100); //Clears all geofences
|
||||
boolean getGeofenceState(geofenceState ¤tGeofenceState, uint16_t maxWait = 1100); //Returns the combined geofence state
|
||||
boolean clearAntPIO(uint16_t maxWait = 1100); //Clears the antenna control pin settings to release the PIOs
|
||||
geofenceParams currentGeofenceParams; // Global to store the geofence parameters
|
||||
|
||||
boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100);
|
||||
uint8_t getPowerSaveMode(uint16_t maxWait = 1100); // Returns 255 if the sendCommand fails
|
||||
|
||||
//Change the dynamic platform model using UBX-CFG-NAV5
|
||||
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);
|
||||
uint8_t getDynamicModel(uint16_t maxWait = 1100); // Get the dynamic model - returns 255 if the sendCommand fails
|
||||
|
||||
boolean getEsfInfo(uint16_t maxWait = 1100);
|
||||
boolean getEsfIns(uint16_t maxWait = 1100);
|
||||
boolean getEsfDataInfo(uint16_t maxWait = 1100);
|
||||
boolean getEsfRawDataInfo(uint16_t maxWait = 1100);
|
||||
sfe_ublox_status_e getSensState(uint8_t sensor, uint16_t maxWait = 1100);
|
||||
boolean getVehAtt(uint16_t maxWait = 1100);
|
||||
|
||||
//Survey-in specific controls
|
||||
struct svinStructure
|
||||
{
|
||||
boolean active;
|
||||
boolean valid;
|
||||
uint16_t observationTime;
|
||||
float meanAccuracy;
|
||||
} svin;
|
||||
|
||||
//Relative Positioning Info in NED frame specific controls
|
||||
struct frelPosInfoStructure
|
||||
{
|
||||
uint16_t refStationID;
|
||||
|
||||
float relPosN;
|
||||
float relPosE;
|
||||
float relPosD;
|
||||
|
||||
long relPosLength;
|
||||
long relPosHeading;
|
||||
|
||||
int8_t relPosHPN;
|
||||
int8_t relPosHPE;
|
||||
int8_t relPosHPD;
|
||||
int8_t relPosHPLength;
|
||||
|
||||
float accN;
|
||||
float accE;
|
||||
float accD;
|
||||
|
||||
bool gnssFixOk;
|
||||
bool diffSoln;
|
||||
bool relPosValid;
|
||||
uint8_t carrSoln;
|
||||
bool isMoving;
|
||||
bool refPosMiss;
|
||||
bool refObsMiss;
|
||||
} relPosInfo;
|
||||
|
||||
//The major datums we want to globally store
|
||||
uint16_t gpsYear;
|
||||
uint8_t gpsMonth;
|
||||
uint8_t gpsDay;
|
||||
uint8_t gpsHour;
|
||||
uint8_t gpsMinute;
|
||||
uint8_t gpsSecond;
|
||||
uint16_t gpsMillisecond;
|
||||
int32_t gpsNanosecond;
|
||||
|
||||
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
|
||||
int32_t longitude; //Degrees * 10^-7 (more accurate than floats)
|
||||
int32_t altitude; //Number of mm above ellipsoid
|
||||
int32_t altitudeMSL; //Number of mm above Mean Sea Level
|
||||
uint8_t SIV; //Number of satellites used in position solution
|
||||
uint8_t fixType; //Tells us when we have a solution aka lock
|
||||
uint8_t carrierSolution; //Tells us when we have an RTK float/fixed solution
|
||||
int32_t groundSpeed; //mm/s
|
||||
int32_t headingOfMotion; //degrees * 10^-5
|
||||
uint16_t pDOP; //Positional dilution of precision * 10^-2 (dimensionless)
|
||||
uint8_t versionLow; //Loaded from getProtocolVersion().
|
||||
uint8_t versionHigh;
|
||||
|
||||
uint32_t timeOfWeek; // ms
|
||||
int32_t highResLatitude; // Degrees * 10^-7
|
||||
int32_t highResLongitude; // Degrees * 10^-7
|
||||
int32_t elipsoid; // Height above ellipsoid in mm (Typo! Should be eLLipsoid! **Uncorrected for backward-compatibility.**)
|
||||
int32_t meanSeaLevel; // Height above mean sea level in mm
|
||||
int32_t geoidSeparation; // This seems to only be provided in NMEA GGA and GNS messages
|
||||
uint32_t horizontalAccuracy; // mm * 10^-1 (i.e. 0.1mm)
|
||||
uint32_t verticalAccuracy; // mm * 10^-1 (i.e. 0.1mm)
|
||||
int8_t elipsoidHp; // High precision component of the height above ellipsoid in mm * 10^-1 (Deliberate typo! Should be eLLipsoidHp!)
|
||||
int8_t meanSeaLevelHp; // High precision component of Height above mean sea level in mm * 10^-1
|
||||
int8_t highResLatitudeHp; // High precision component of latitude: Degrees * 10^-9
|
||||
int8_t highResLongitudeHp; // High precision component of longitude: Degrees * 10^-9
|
||||
|
||||
uint16_t rtcmFrameCounter = 0; //Tracks the type of incoming byte inside RTCM frame
|
||||
|
||||
#define DEF_NUM_SENS 7
|
||||
struct deadReckData
|
||||
{
|
||||
uint8_t version;
|
||||
uint8_t fusionMode;
|
||||
|
||||
uint8_t xAngRateVald;
|
||||
uint8_t yAngRateVald;
|
||||
uint8_t zAngRateVald;
|
||||
uint8_t xAccelVald;
|
||||
uint8_t yAccelVald;
|
||||
uint8_t zAccelVald;
|
||||
|
||||
int32_t xAngRate;
|
||||
int32_t yAngRate;
|
||||
int32_t zAngRate;
|
||||
|
||||
int32_t xAccel;
|
||||
int32_t yAccel;
|
||||
int32_t zAccel;
|
||||
|
||||
// The array size is based on testing directly on M8U and F9R
|
||||
uint32_t rawData;
|
||||
uint32_t rawDataType;
|
||||
uint32_t rawTStamp;
|
||||
|
||||
uint32_t data[DEF_NUM_SENS];
|
||||
uint32_t dataType[DEF_NUM_SENS];
|
||||
uint32_t dataTStamp[DEF_NUM_SENS];
|
||||
} imuMeas;
|
||||
|
||||
struct indivImuData
|
||||
{
|
||||
|
||||
uint8_t numSens;
|
||||
|
||||
uint8_t senType;
|
||||
boolean isUsed;
|
||||
boolean isReady;
|
||||
uint8_t calibStatus;
|
||||
uint8_t timeStatus;
|
||||
|
||||
uint8_t freq; // Hz
|
||||
|
||||
boolean badMeas;
|
||||
boolean badTag;
|
||||
boolean missMeas;
|
||||
boolean noisyMeas;
|
||||
} ubloxSen;
|
||||
|
||||
struct vehicleAttitude
|
||||
{
|
||||
// All values in degrees
|
||||
int32_t roll;
|
||||
int32_t pitch;
|
||||
int32_t heading;
|
||||
uint32_t accRoll;
|
||||
uint32_t accPitch;
|
||||
uint32_t accHeading;
|
||||
} vehAtt;
|
||||
|
||||
private:
|
||||
//Depending on the sentence type the processor will load characters into different arrays
|
||||
enum SentenceTypes
|
||||
{
|
||||
NONE = 0,
|
||||
NMEA,
|
||||
UBX,
|
||||
RTCM
|
||||
} currentSentence = NONE;
|
||||
|
||||
//Depending on the ubx binary response class, store binary responses into different places
|
||||
enum classTypes
|
||||
{
|
||||
CLASS_NONE = 0,
|
||||
CLASS_ACK,
|
||||
CLASS_NOT_AN_ACK
|
||||
} ubxFrameClass = CLASS_NONE;
|
||||
|
||||
enum commTypes
|
||||
{
|
||||
COMM_TYPE_I2C = 0,
|
||||
COMM_TYPE_SERIAL,
|
||||
COMM_TYPE_SPI
|
||||
} commType = COMM_TYPE_I2C; //Controls which port we look to for incoming bytes
|
||||
|
||||
//Functions
|
||||
boolean checkUbloxInternal(ubxPacket *incomingUBX, uint8_t requestedClass = 255, uint8_t requestedID = 255); //Checks module with user selected commType
|
||||
uint32_t extractLong(uint8_t spotToStart); //Combine four bytes from payload into long
|
||||
uint16_t extractInt(uint8_t spotToStart); //Combine two bytes from payload into int
|
||||
uint8_t extractByte(uint8_t spotToStart); //Get byte from payload
|
||||
int8_t extractSignedChar(uint8_t spotToStart); //Get signed 8-bit value from payload
|
||||
void addToChecksum(uint8_t incoming); //Given an incoming byte, adjust rollingChecksumA/B
|
||||
|
||||
//Variables
|
||||
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
|
||||
Stream *_serialPort; //The generic connection to user's chosen Serial hardware
|
||||
Stream *_nmeaOutputPort = NULL; //The user can assign an output port to print NMEA sentences if they wish
|
||||
Stream *_debugSerial; //The stream to send debug messages to if enabled
|
||||
|
||||
uint8_t _gpsI2Caddress = 0x42; //Default 7-bit unshifted address of the ublox 6/7/8/M8/F9 series
|
||||
//This can be changed using the ublox configuration software
|
||||
|
||||
boolean _printDebug = false; //Flag to print the serial commands we are sending to the Serial port for debug
|
||||
boolean _printLimitedDebug = false; //Flag to print limited debug messages. Useful for I2C debugging or high navigation rates
|
||||
|
||||
//The packet buffers
|
||||
//These are pointed at from within the ubxPacket
|
||||
uint8_t payloadAck[2]; // Holds the requested ACK/NACK
|
||||
uint8_t payloadCfg[MAX_PAYLOAD_SIZE]; // Holds the requested data packet
|
||||
uint8_t payloadBuf[2]; // Temporary buffer used to screen incoming packets or dump unrequested packets
|
||||
|
||||
//Init the packet structures and init them with pointers to the payloadAck, payloadCfg and payloadBuf arrays
|
||||
ubxPacket packetAck = {0, 0, 0, 0, 0, payloadAck, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
|
||||
ubxPacket packetCfg = {0, 0, 0, 0, 0, payloadCfg, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
|
||||
ubxPacket packetBuf = {0, 0, 0, 0, 0, payloadBuf, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
|
||||
|
||||
//Flag if this packet is unrequested (and so should be ignored and not copied into packetCfg or packetAck)
|
||||
boolean ignoreThisPayload = false;
|
||||
|
||||
//Identify which buffer is in use
|
||||
//Data is stored in packetBuf until the requested class and ID can be validated
|
||||
//If a match is seen, data is diverted into packetAck or packetCfg
|
||||
sfe_ublox_packet_buffer_e activePacketBuffer = SFE_UBLOX_PACKET_PACKETBUF;
|
||||
|
||||
//Limit checking of new data to every X ms
|
||||
//If we are expecting an update every X Hz then we should check every half that amount of time
|
||||
//Otherwise we may block ourselves from seeing new data
|
||||
uint8_t i2cPollingWait = 100; //Default to 100ms. Adjusted when user calls setNavigationFrequency()
|
||||
|
||||
unsigned long lastCheck = 0;
|
||||
boolean autoPVT = false; //Whether autoPVT is enabled or not
|
||||
boolean autoPVTImplicitUpdate = true; // Whether autoPVT is triggered by accessing stale data (=true) or by a call to checkUblox (=false)
|
||||
uint16_t ubxFrameCounter; //It counts all UBX frame. [Fixed header(2bytes), CLS(1byte), ID(1byte), length(2bytes), payload(x bytes), checksums(2bytes)]
|
||||
|
||||
uint8_t rollingChecksumA; //Rolls forward as we receive incoming bytes. Checked against the last two A/B checksum bytes
|
||||
uint8_t rollingChecksumB; //Rolls forward as we receive incoming bytes. Checked against the last two A/B checksum bytes
|
||||
|
||||
//Create bit field for staleness of each datum in PVT we want to monitor
|
||||
//moduleQueried.latitude goes true each time we call getPVT()
|
||||
//This reduces the number of times we have to call getPVT as this can take up to ~1s per read
|
||||
//depending on update rate
|
||||
struct
|
||||
{
|
||||
uint32_t gpsiTOW : 1;
|
||||
uint32_t gpsYear : 1;
|
||||
uint32_t gpsMonth : 1;
|
||||
uint32_t gpsDay : 1;
|
||||
uint32_t gpsHour : 1;
|
||||
uint32_t gpsMinute : 1;
|
||||
uint32_t gpsSecond : 1;
|
||||
uint32_t gpsNanosecond : 1;
|
||||
|
||||
uint32_t all : 1;
|
||||
uint32_t longitude : 1;
|
||||
uint32_t latitude : 1;
|
||||
uint32_t altitude : 1;
|
||||
uint32_t altitudeMSL : 1;
|
||||
uint32_t SIV : 1;
|
||||
uint32_t fixType : 1;
|
||||
uint32_t carrierSolution : 1;
|
||||
uint32_t groundSpeed : 1;
|
||||
uint32_t headingOfMotion : 1;
|
||||
uint32_t pDOP : 1;
|
||||
uint32_t versionNumber : 1;
|
||||
} moduleQueried;
|
||||
|
||||
struct
|
||||
{
|
||||
uint16_t all : 1;
|
||||
uint16_t timeOfWeek : 1;
|
||||
uint16_t highResLatitude : 1;
|
||||
uint16_t highResLongitude : 1;
|
||||
uint16_t elipsoid : 1;
|
||||
uint16_t meanSeaLevel : 1;
|
||||
uint16_t geoidSeparation : 1; // Redundant but kept for backward-compatibility
|
||||
uint16_t horizontalAccuracy : 1;
|
||||
uint16_t verticalAccuracy : 1;
|
||||
uint16_t elipsoidHp : 1;
|
||||
uint16_t meanSeaLevelHp : 1;
|
||||
uint16_t highResLatitudeHp : 1;
|
||||
uint16_t highResLongitudeHp : 1;
|
||||
} highResModuleQueried;
|
||||
|
||||
uint16_t rtcmLen = 0;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,154 @@
|
||||
/*
|
||||
Get the high precision geodetic solution for latitude and longitude
|
||||
By: Nathan Seidle
|
||||
Modified by: Steven Rowland and Paul Clark
|
||||
SparkFun Electronics
|
||||
Date: April 17th, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to inspect the accuracy of the high-precision
|
||||
positional solution. Please see below for information about the units.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(Serial);
|
||||
|
||||
if (myGPS.begin(Wire) == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.setNavigationFrequency(20); //Set output to 20 times a second
|
||||
|
||||
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
|
||||
Serial.print("Current update rate: ");
|
||||
Serial.println(rate);
|
||||
|
||||
//myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
// getHighResLatitude: returns the latitude from HPPOSLLH as an int32_t in degrees * 10^-7
|
||||
// getHighResLatitudeHp: returns the high resolution component of latitude from HPPOSLLH as an int8_t in degrees * 10^-9
|
||||
// getHighResLongitude: returns the longitude from HPPOSLLH as an int32_t in degrees * 10^-7
|
||||
// getHighResLongitudeHp: returns the high resolution component of longitude from HPPOSLLH as an int8_t in degrees * 10^-9
|
||||
// getElipsoid: returns the height above ellipsoid as an int32_t in mm
|
||||
// getElipsoidHp: returns the high resolution component of the height above ellipsoid as an int8_t in mm * 10^-1
|
||||
// getMeanSeaLevel: returns the height above mean sea level as an int32_t in mm
|
||||
// getMeanSeaLevelHp: returns the high resolution component of the height above mean sea level as an int8_t in mm * 10^-1
|
||||
// getHorizontalAccuracy: returns the horizontal accuracy estimate from HPPOSLLH as an uint32_t in mm * 10^-1
|
||||
|
||||
// If you want to use the high precision latitude and longitude with the full 9 decimal places
|
||||
// you will need to use a 64-bit double - which is not supported on all platforms
|
||||
|
||||
// To allow this example to run on standard platforms, we cheat by converting lat and lon to integer and fractional degrees
|
||||
|
||||
// The high resolution altitudes can be converted into standard 32-bit float
|
||||
|
||||
// First, let's collect the position data
|
||||
int32_t latitude = myGPS.getHighResLatitude();
|
||||
int8_t latitudeHp = myGPS.getHighResLatitudeHp();
|
||||
int32_t longitude = myGPS.getHighResLongitude();
|
||||
int8_t longitudeHp = myGPS.getHighResLongitudeHp();
|
||||
int32_t ellipsoid = myGPS.getElipsoid();
|
||||
int8_t ellipsoidHp = myGPS.getElipsoidHp();
|
||||
int32_t msl = myGPS.getMeanSeaLevel();
|
||||
int8_t mslHp = myGPS.getMeanSeaLevelHp();
|
||||
uint32_t accuracy = myGPS.getHorizontalAccuracy();
|
||||
|
||||
// Defines storage for the lat and lon units integer and fractional parts
|
||||
int32_t lat_int; // Integer part of the latitude in degrees
|
||||
int32_t lat_frac; // Fractional part of the latitude
|
||||
int32_t lon_int; // Integer part of the longitude in degrees
|
||||
int32_t lon_frac; // Fractional part of the longitude
|
||||
|
||||
// Calculate the latitude and longitude integer and fractional parts
|
||||
lat_int = latitude / 10000000; // Convert latitude from degrees * 10^-7 to Degrees
|
||||
lat_frac = latitude - (lat_int * 10000000); // Calculate the fractional part of the latitude
|
||||
lat_frac = (lat_frac * 100) + latitudeHp; // Now add the high resolution component
|
||||
if (lat_frac < 0) // If the fractional part is negative, remove the minus sign
|
||||
{
|
||||
lat_frac = 0 - lat_frac;
|
||||
}
|
||||
lon_int = longitude / 10000000; // Convert latitude from degrees * 10^-7 to Degrees
|
||||
lon_frac = longitude - (lon_int * 10000000); // Calculate the fractional part of the longitude
|
||||
lon_frac = (lon_frac * 100) + longitudeHp; // Now add the high resolution component
|
||||
if (lon_frac < 0) // If the fractional part is negative, remove the minus sign
|
||||
{
|
||||
lon_frac = 0 - lon_frac;
|
||||
}
|
||||
|
||||
// Print the lat and lon
|
||||
Serial.print("Lat (deg): ");
|
||||
Serial.print(lat_int); // Print the integer part of the latitude
|
||||
Serial.print(".");
|
||||
Serial.print(lat_frac); // Print the fractional part of the latitude
|
||||
Serial.print(", Lon (deg): ");
|
||||
Serial.print(lon_int); // Print the integer part of the latitude
|
||||
Serial.print(".");
|
||||
Serial.println(lon_frac); // Print the fractional part of the latitude
|
||||
|
||||
// Now define float storage for the heights and accuracy
|
||||
float f_ellipsoid;
|
||||
float f_msl;
|
||||
float f_accuracy;
|
||||
|
||||
// Calculate the height above ellipsoid in mm * 10^-1
|
||||
f_ellipsoid = (ellipsoid * 10) + ellipsoidHp;
|
||||
// Now convert to m
|
||||
f_ellipsoid = f_ellipsoid / 10000.0; // Convert from mm * 10^-1 to m
|
||||
|
||||
// Calculate the height above mean sea level in mm * 10^-1
|
||||
f_msl = (msl * 10) + mslHp;
|
||||
// Now convert to m
|
||||
f_msl = f_msl / 10000.0; // Convert from mm * 10^-1 to m
|
||||
|
||||
// Convert the horizontal accuracy (mm * 10^-1) to a float
|
||||
f_accuracy = accuracy;
|
||||
// Now convert to m
|
||||
f_accuracy = f_accuracy / 10000.0; // Convert from mm * 10^-1 to m
|
||||
|
||||
// Finally, do the printing
|
||||
Serial.print("Ellipsoid (m): ");
|
||||
Serial.print(f_ellipsoid, 4); // Print the ellipsoid with 4 decimal places
|
||||
|
||||
Serial.print(", Mean Sea Level(m): ");
|
||||
Serial.print(f_msl, 4); // Print the mean sea level with 4 decimal places
|
||||
|
||||
Serial.print(", Accuracy (m): ");
|
||||
Serial.println(f_accuracy, 4); // Print the accuracy with 4 decimal places
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*
|
||||
Get the high precision geodetic solution for latitude and longitude using double
|
||||
By: Nathan Seidle
|
||||
Modified by: Paul Clark (PaulZC)
|
||||
SparkFun Electronics
|
||||
Date: April 17th, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to inspect the accuracy of the high-precision
|
||||
positional solution. Please see below for information about the units.
|
||||
|
||||
** This example will only work correctly on platforms which support 64-bit double **
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and (e.g.) a Redboard Artemis https://www.sparkfun.com/products/15444
|
||||
or an Artemis Thing Plus https://www.sparkfun.com/products/15574
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> // Needed for I2C to GPS
|
||||
|
||||
#define myWire Wire // This will work on the Redboard Artemis and the Artemis Thing Plus using Qwiic
|
||||
//#define myWire Wire1 // Uncomment this line if you are using the extra SCL1/SDA1 pins (D17 and D16) on the Thing Plus
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
|
||||
myWire.begin();
|
||||
|
||||
//myGPS.enableDebugging(Serial); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin(myWire) == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
// Check that this platform supports 64-bit (8 byte) double
|
||||
if (sizeof(double) < 8)
|
||||
{
|
||||
Serial.println(F("Warning! Your platform does not support 64-bit double."));
|
||||
Serial.println(F("The latitude and longitude will be inaccurate."));
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
//myGPS.setNavigationFrequency(20); //Set output to 20 times a second
|
||||
|
||||
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
|
||||
Serial.print("Current update rate: ");
|
||||
Serial.println(rate);
|
||||
|
||||
//myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second.
|
||||
//The module only responds when a new position is available.
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
// getHighResLatitude: returns the latitude from HPPOSLLH as an int32_t in degrees * 10^-7
|
||||
// getHighResLatitudeHp: returns the high resolution component of latitude from HPPOSLLH as an int8_t in degrees * 10^-9
|
||||
// getHighResLongitude: returns the longitude from HPPOSLLH as an int32_t in degrees * 10^-7
|
||||
// getHighResLongitudeHp: returns the high resolution component of longitude from HPPOSLLH as an int8_t in degrees * 10^-9
|
||||
// getElipsoid: returns the height above ellipsoid as an int32_t in mm
|
||||
// getElipsoidHp: returns the high resolution component of the height above ellipsoid as an int8_t in mm * 10^-1
|
||||
// getMeanSeaLevel: returns the height above mean sea level as an int32_t in mm
|
||||
// getMeanSeaLevelHp: returns the high resolution component of the height above mean sea level as an int8_t in mm * 10^-1
|
||||
// getHorizontalAccuracy: returns the horizontal accuracy estimate from HPPOSLLH as an uint32_t in mm * 10^-1
|
||||
|
||||
// First, let's collect the position data
|
||||
int32_t latitude = myGPS.getHighResLatitude();
|
||||
int8_t latitudeHp = myGPS.getHighResLatitudeHp();
|
||||
int32_t longitude = myGPS.getHighResLongitude();
|
||||
int8_t longitudeHp = myGPS.getHighResLongitudeHp();
|
||||
int32_t ellipsoid = myGPS.getElipsoid();
|
||||
int8_t ellipsoidHp = myGPS.getElipsoidHp();
|
||||
int32_t msl = myGPS.getMeanSeaLevel();
|
||||
int8_t mslHp = myGPS.getMeanSeaLevelHp();
|
||||
uint32_t accuracy = myGPS.getHorizontalAccuracy();
|
||||
|
||||
// Defines storage for the lat and lon as double
|
||||
double d_lat; // latitude
|
||||
double d_lon; // longitude
|
||||
|
||||
// Assemble the high precision latitude and longitude
|
||||
d_lat = ((double)latitude) / 10000000.0; // Convert latitude from degrees * 10^-7 to degrees
|
||||
d_lat += ((double)latitudeHp) / 1000000000.0; // Now add the high resolution component (degrees * 10^-9 )
|
||||
d_lon = ((double)longitude) / 10000000.0; // Convert longitude from degrees * 10^-7 to degrees
|
||||
d_lon += ((double)longitudeHp) / 1000000000.0; // Now add the high resolution component (degrees * 10^-9 )
|
||||
|
||||
// Print the lat and lon
|
||||
Serial.print("Lat (deg): ");
|
||||
Serial.print(d_lat, 9);
|
||||
Serial.print(", Lon (deg): ");
|
||||
Serial.print(d_lon, 9);
|
||||
|
||||
// Now define float storage for the heights and accuracy
|
||||
float f_ellipsoid;
|
||||
float f_msl;
|
||||
float f_accuracy;
|
||||
|
||||
// Calculate the height above ellipsoid in mm * 10^-1
|
||||
f_ellipsoid = (ellipsoid * 10) + ellipsoidHp;
|
||||
// Now convert to m
|
||||
f_ellipsoid = f_ellipsoid / 10000.0; // Convert from mm * 10^-1 to m
|
||||
|
||||
// Calculate the height above mean sea level in mm * 10^-1
|
||||
f_msl = (msl * 10) + mslHp;
|
||||
// Now convert to m
|
||||
f_msl = f_msl / 10000.0; // Convert from mm * 10^-1 to m
|
||||
|
||||
// Convert the horizontal accuracy (mm * 10^-1) to a float
|
||||
f_accuracy = accuracy;
|
||||
// Now convert to m
|
||||
f_accuracy = f_accuracy / 10000.0; // Convert from mm * 10^-1 to m
|
||||
|
||||
// Finally, do the printing
|
||||
Serial.print(", Ellipsoid (m): ");
|
||||
Serial.print(f_ellipsoid, 4); // Print the ellipsoid with 4 decimal places
|
||||
|
||||
Serial.print(", Mean Sea Level (m): ");
|
||||
Serial.print(f_msl, 4); // Print the mean sea level with 4 decimal places
|
||||
|
||||
Serial.print(", Accuracy (m): ");
|
||||
Serial.println(f_accuracy, 4); // Print the accuracy with 4 decimal places
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
Set the static position of the receiver.
|
||||
By: SparkFun Electronics / Nathan Seidle
|
||||
Date: September 26th, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to set the static position of a receiver
|
||||
using an Earth-Centered, Earth-Fixed (ECEF) location. This is the
|
||||
output from a long (24 hour+) survey-in. Setting the static position
|
||||
immediately causes the receiver to begin outputting RTCM data (if
|
||||
enabled), perfect for setting up your own RTCM NTRIP caster or CORS.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200); // You may need to increase this for high navigation rates!
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun u-blox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
|
||||
{
|
||||
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
|
||||
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...
|
||||
|
||||
//Units are cm so 1234 = 12.34m
|
||||
//myGPS.setStaticPosition(-128020831, -471680385, 408666581);
|
||||
|
||||
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
|
||||
myGPS.setStaticPosition(-128020830, -80, -471680384, -70, 408666581, 10); //With high precision 0.1mm parts
|
||||
|
||||
//We can also set via lat/long
|
||||
//40.09029751,-105.18507900,1560.238
|
||||
//myGPS.setStaticPosition(400902975, -1051850790, 156024, true); //True at end enables lat/long input
|
||||
//myGPS.setStaticPosition(400902975, 10, -1051850790, 0, 156023, 80, true);
|
||||
|
||||
//Now let's use getVals to read back the data
|
||||
//long ecefX = myGPS.getVal32(0x40030003);
|
||||
//Serial.print("ecefX: ");
|
||||
//Serial.println(ecefX);
|
||||
|
||||
Serial.println(F("Done!"));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
Configuring the GPS to automatically send HPPOSLLH position reports over I2C
|
||||
By: Paul Clark
|
||||
Date: October 27th 2020
|
||||
|
||||
Based on an earlier example:
|
||||
By: Nathan Seidle and Thorsten von Eicken
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to configure the U-Blox GPS the send navigation reports automatically
|
||||
and retrieving the latest one via getHPPOSLLH. This eliminates the blocking in getHPPOSLLH while the GPS
|
||||
produces a fresh navigation solution at the expense of returning a slighly old solution.
|
||||
|
||||
This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS
|
||||
simply outputs the UBX_NAV_HPPOSLLH packet. With I2C it queues it into its internal I2C buffer (4KB in
|
||||
size?) where it can be retrieved in the next I2C poll.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable lots of helpful debug messages
|
||||
//myGPS.enableDebugging(Serial, true); // Uncomment this line to enable the minimum of helpful debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
|
||||
//myGPS.factoryDefault(); delay(5000);
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR
|
||||
|
||||
myGPS.setNavigationFrequency(1); //Produce one solution per second
|
||||
|
||||
|
||||
// The acid test: all four of these combinations should work seamlessly :-)
|
||||
|
||||
//myGPS.setAutoPVT(false); // Library will poll each reading
|
||||
//myGPS.setAutoHPPOSLLH(false); // Library will poll each reading
|
||||
|
||||
//myGPS.setAutoPVT(true); // Tell the GPS to "send" each solution automatically
|
||||
//myGPS.setAutoHPPOSLLH(false); // Library will poll each reading
|
||||
|
||||
//myGPS.setAutoPVT(false); // Library will poll each reading
|
||||
//myGPS.setAutoHPPOSLLH(true); // Tell the GPS to "send" each hi res solution automatically
|
||||
|
||||
myGPS.setAutoPVT(true); // Tell the GPS to "send" each solution automatically
|
||||
myGPS.setAutoHPPOSLLH(true); // Tell the GPS to "send" each hi res solution automatically
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Calling getHPPOSLLH returns true if there actually is a fresh navigation solution available.
|
||||
// Calling getPVT returns true if there actually is a fresh navigation solution available.
|
||||
if ((myGPS.getHPPOSLLH()) || (myGPS.getPVT()))
|
||||
{
|
||||
Serial.println();
|
||||
|
||||
long highResLatitude = myGPS.getHighResLatitude();
|
||||
Serial.print(F("Hi Res Lat: "));
|
||||
Serial.print(highResLatitude);
|
||||
|
||||
int highResLatitudeHp = myGPS.getHighResLatitudeHp();
|
||||
Serial.print(F(" "));
|
||||
Serial.print(highResLatitudeHp);
|
||||
|
||||
long highResLongitude = myGPS.getHighResLongitude();
|
||||
Serial.print(F(" Hi Res Long: "));
|
||||
Serial.print(highResLongitude);
|
||||
|
||||
int highResLongitudeHp = myGPS.getHighResLongitudeHp();
|
||||
Serial.print(F(" "));
|
||||
Serial.print(highResLongitudeHp);
|
||||
|
||||
unsigned long horizAccuracy = myGPS.getHorizontalAccuracy();
|
||||
Serial.print(F(" Horiz accuracy: "));
|
||||
Serial.print(horizAccuracy);
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F(" Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.println(longitude);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(".");
|
||||
delay(50);
|
||||
}
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
/*
|
||||
Use ESP32 WiFi to push RTCM data to RTK2Go (caster) as a Server
|
||||
By: SparkFun Electronics / Nathan Seidle
|
||||
Date: December 14th, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to gather RTCM data over I2C and push it to a casting service over WiFi.
|
||||
It's confusing, but the Arduino is acting as a 'server' to a 'caster'. In this case we will
|
||||
use RTK2Go.com as our caster because it is free. A rover (car, surveyor stick, etc) can
|
||||
then connect to RTK2Go as a 'client' and get the RTCM data it needs.
|
||||
|
||||
You will need to register your mountpoint here: http://www.rtk2go.com/new-reservation/
|
||||
(They'll probably block the credentials we include in this example)
|
||||
|
||||
To see if your mountpoint is active go here: http://rtk2go.com:2101/
|
||||
|
||||
This is a proof of concept. Serving RTCM to a caster over WiFi is useful when you need to
|
||||
set up a high-precision base station.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/16481
|
||||
RTK Surveyor: https://www.sparkfun.com/products/17369
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a ESP32 Thing Plus
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <WiFi.h>
|
||||
#include "secrets.h"
|
||||
WiFiClient client;
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
//Basic Connection settings to RTK2Go NTRIP Caster - See secrets for mount specific credentials
|
||||
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
const uint16_t casterPort = 2101;
|
||||
const char * casterHost = "rtk2go.com";
|
||||
const char * ntrip_server_name = "SparkFun_RTK_Surveyor";
|
||||
|
||||
long lastSentRTCM_ms = 0; //Time of last data pushed to socket
|
||||
int maxTimeBeforeHangup_ms = 10000; //If we fail to get a complete RTCM frame after 10s, then disconnect from caster
|
||||
|
||||
uint32_t serverBytesSent = 0; //Just a running total
|
||||
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
long lastReport_ms = 0; //Time of last report of bytes sent
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200); // You may need to increase this for high navigation rates!
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println(F("SparkFun u-blox Example"));
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
|
||||
{
|
||||
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
Serial.print("Connecting to local WiFi");
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
Serial.print("\nWiFi connected with IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); //UBX+RTCM3 is not a valid option so we enable all three.
|
||||
|
||||
myGPS.setNavigationFrequency(1); //Set output in Hz. RTCM rarely benefits from >1Hz.
|
||||
|
||||
//Disable all NMEA sentences
|
||||
bool response = true;
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C);
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_I2C);
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_I2C);
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_RMC, COM_PORT_I2C);
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_GST, COM_PORT_I2C);
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_I2C);
|
||||
response &= myGPS.disableNMEAMessage(UBX_NMEA_VTG, COM_PORT_I2C);
|
||||
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Failed to disable NMEA. Freezing..."));
|
||||
while (1);
|
||||
}
|
||||
else
|
||||
Serial.println(F("NMEA disabled"));
|
||||
|
||||
//Enable necessary RTCM sentences
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through UART2, message every second
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
|
||||
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Failed to enable RTCM. Freezing..."));
|
||||
while (1);
|
||||
}
|
||||
else
|
||||
Serial.println(F("RTCM sentences enabled"));
|
||||
|
||||
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...
|
||||
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
|
||||
//For more infomation see Example12_setStaticPosition
|
||||
//Note: If you leave these coordinates in place and setup your antenna *not* at SparkFun, your receiver
|
||||
//will be very confused and fail to generate correction data because, well, you aren't at SparkFun...
|
||||
//See this tutorial on getting PPP coordinates: https://learn.sparkfun.com/tutorials/how-to-build-a-diy-gnss-reference-station/all
|
||||
response &= myGPS.setStaticPosition(-128020830, -80, -471680384, -70, 408666581, 10); //With high precision 0.1mm parts
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Failed to enter static position. Freezing..."));
|
||||
while (1);
|
||||
}
|
||||
else
|
||||
Serial.println(F("Static position set"));
|
||||
|
||||
//You could instead do a survey-in but it takes much longer to start generating RTCM data. See Example4_BaseWithLCD
|
||||
//myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
|
||||
|
||||
if (myGPS.saveConfiguration() == false) //Save the current settings to flash and BBR
|
||||
Serial.println(F("Module failed to save."));
|
||||
|
||||
Serial.println(F("Module configuration complete"));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (Serial.available()) beginServing();
|
||||
|
||||
Serial.println(F("Press any key to start serving."));
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void beginServing()
|
||||
{
|
||||
Serial.println("Xmit to RTK2Go. Press any key to stop");
|
||||
delay(10); //Wait for any serial to arrive
|
||||
while (Serial.available()) Serial.read(); //Flush
|
||||
|
||||
while (Serial.available() == 0)
|
||||
{
|
||||
//Connect if we are not already
|
||||
if (client.connected() == false)
|
||||
{
|
||||
Serial.printf("Opening socket to %s\n", casterHost);
|
||||
|
||||
if (client.connect(casterHost, casterPort) == true) //Attempt connection
|
||||
{
|
||||
Serial.printf("Connected to %s:%d\n", casterHost, casterPort);
|
||||
|
||||
const int SERVER_BUFFER_SIZE = 512;
|
||||
char serverBuffer[SERVER_BUFFER_SIZE];
|
||||
|
||||
snprintf(serverBuffer, SERVER_BUFFER_SIZE, "SOURCE %s /%s\r\nSource-Agent: NTRIP %s/%s\r\n\r\n",
|
||||
mntpnt_pw, mntpnt, ntrip_server_name, "App Version 1.0");
|
||||
|
||||
Serial.printf("Sending credentials:\n%s\n", serverBuffer);
|
||||
client.write(serverBuffer, strlen(serverBuffer));
|
||||
|
||||
//Wait for response
|
||||
unsigned long timeout = millis();
|
||||
while (client.available() == 0)
|
||||
{
|
||||
if (millis() - timeout > 5000)
|
||||
{
|
||||
Serial.println(">>> Client Timeout !");
|
||||
client.stop();
|
||||
return;
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
||||
//Check reply
|
||||
bool connectionSuccess = false;
|
||||
char response[512];
|
||||
int responseSpot = 0;
|
||||
while (client.available())
|
||||
{
|
||||
response[responseSpot++] = client.read();
|
||||
if (strstr(response, "200") > 0) //Look for 'ICY 200 OK'
|
||||
connectionSuccess = true;
|
||||
if (responseSpot == 512 - 1) break;
|
||||
}
|
||||
response[responseSpot] = '\0';
|
||||
|
||||
if (connectionSuccess == false)
|
||||
{
|
||||
Serial.printf("Failed to connect to RTK2Go: %s", response);
|
||||
}
|
||||
} //End attempt to connect
|
||||
else
|
||||
{
|
||||
Serial.println("Connection to host failed");
|
||||
}
|
||||
} //End connected == false
|
||||
|
||||
if (client.connected() == true)
|
||||
{
|
||||
delay(10);
|
||||
while (Serial.available()) Serial.read(); //Flush any endlines or carriage returns
|
||||
|
||||
lastReport_ms = millis();
|
||||
lastSentRTCM_ms = millis();
|
||||
|
||||
//This is the main sending loop. We scan for new ublox data but processRTCM() is where the data actually gets sent out.
|
||||
while (1)
|
||||
{
|
||||
if (Serial.available()) break;
|
||||
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
//Close socket if we don't have new data for 10s
|
||||
//RTK2Go will ban your IP address if you abuse it. See http://www.rtk2go.com/how-to-get-your-ip-banned/
|
||||
//So let's not leave the socket open/hanging without data
|
||||
if (millis() - lastSentRTCM_ms > maxTimeBeforeHangup_ms)
|
||||
{
|
||||
Serial.println("RTCM timeout. Disconnecting...");
|
||||
client.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
delay(10);
|
||||
|
||||
//Report some statistics every 250
|
||||
if (millis() - lastReport_ms > 250)
|
||||
{
|
||||
lastReport_ms += 250;
|
||||
Serial.printf("Total sent: %d\n", serverBytesSent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
Serial.println("User pressed a key");
|
||||
Serial.println("Disconnecting...");
|
||||
client.stop();
|
||||
|
||||
delay(10);
|
||||
while (Serial.available()) Serial.read(); //Flush any endlines or carriage returns
|
||||
}
|
||||
|
||||
//This function gets called from the SparkFun u-blox Arduino Library.
|
||||
//As each RTCM byte comes in you can specify what to do with it
|
||||
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
|
||||
void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
|
||||
{
|
||||
if (client.connected() == true)
|
||||
{
|
||||
client.write(incoming); //Send this byte to socket
|
||||
serverBytesSent++;
|
||||
lastSentRTCM_ms = millis();
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
//Your WiFi credentials
|
||||
const char* ssid = "TRex";
|
||||
const char* password = "hasBigTeeth";
|
||||
|
||||
//Your RTK2GO mount point credentials
|
||||
const char* mntpnt_pw = "WR5wRo4H";
|
||||
const char* mntpnt = "bldr_dwntwn2";
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
Get the high position accuracy of the RTK enhanced position
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to inspect the accuracy of the high-precision
|
||||
positional solution.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
long accuracy = myGPS.getPositionAccuracy();
|
||||
Serial.print(F(" 3D Positional Accuracy: "));
|
||||
Serial.print(accuracy);
|
||||
Serial.println(F("mm"));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
Configuring Ublox Module using new VALGET / VALSET / VALDEL methods
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 3rd, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
Ublox depricated many -CFG messages and replaced them with new
|
||||
VALGET, VALSET, VALDEL methods. This shows the basics of how to use
|
||||
these methods.
|
||||
|
||||
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("SparkFun Ublox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
byte response;
|
||||
response = myGPS.getVal8(VAL_GROUP_I2C, VAL_ID_I2C_ADDRESS, VAL_GROUP_I2C_SIZE, VAL_LAYER_RAM);
|
||||
Serial.print(F("I2C Address: 0x"));
|
||||
Serial.println(response >> 1, HEX); //We have to shift by 1 to get the common '7-bit' I2C address format
|
||||
|
||||
response = myGPS.getVal8(VAL_GROUP_I2COUTPROT, VAL_ID_I2COUTPROT_NMEA, VAL_GROUP_I2COUTPROT_SIZE, VAL_LAYER_RAM);
|
||||
Serial.print(F("Output NMEA over I2C port: 0x"));
|
||||
Serial.print(response, HEX);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 9th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example does all steps to configure and enable a ZED-F9P as a base station:
|
||||
Begin Survey-In
|
||||
Once we've achieved 2m accuracy and 300s have passed, survey is complete
|
||||
Enable six RTCM messages
|
||||
Begin outputting RTCM bytes
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
//#define USE_SERIAL1 // Uncomment this line to push the RTCM data to Serial1
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("Ublox Base station example");
|
||||
|
||||
#ifdef USE_SERIAL1
|
||||
// If our board supports it, we can output the RTCM data on Serial1
|
||||
Serial1.begin(115200);
|
||||
#endif
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
|
||||
//myGPS.factoryDefault(); delay(5000);
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR
|
||||
|
||||
while (Serial.available()) Serial.read(); //Clear any latent chars in serial buffer
|
||||
Serial.println("Press any key to send commands to begin Survey-In");
|
||||
while (Serial.available() == 0) ; //Wait for user to press a key
|
||||
|
||||
boolean response = true;
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
|
||||
|
||||
//Use COM_PORT_UART1 for the above six messages to direct RTCM messages out UART1
|
||||
//COM_PORT_UART2, COM_PORT_USB, COM_PORT_SPI are also available
|
||||
//For example: response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_UART1, 10);
|
||||
|
||||
if (response == true)
|
||||
{
|
||||
Serial.println("RTCM messages enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("RTCM failed to enable. Are you sure you have an ZED-F9P?");
|
||||
while (1); //Freeze
|
||||
}
|
||||
|
||||
//Check if Survey is in Progress before initiating one
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println("Failed to get Survey In status");
|
||||
while (1); //Freeze
|
||||
}
|
||||
|
||||
if (myGPS.svin.active == true)
|
||||
{
|
||||
Serial.print("Survey already in progress.");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Start survey
|
||||
//The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info.
|
||||
//response = myGPS.enableSurveyMode(300, 2.000); //Enable Survey in on NEO-M8P, 300 seconds, 2.0m
|
||||
response = myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println("Survey start failed");
|
||||
while (1);
|
||||
}
|
||||
Serial.println("Survey started. This will run until 60s has passed and less than 5m accuracy is achieved.");
|
||||
}
|
||||
|
||||
while(Serial.available()) Serial.read(); //Clear buffer
|
||||
|
||||
//Begin waiting for survey to complete
|
||||
while (myGPS.svin.valid == false)
|
||||
{
|
||||
if(Serial.available())
|
||||
{
|
||||
byte incoming = Serial.read();
|
||||
if(incoming == 'x')
|
||||
{
|
||||
//Stop survey mode
|
||||
response = myGPS.disableSurveyMode(); //Disable survey
|
||||
Serial.println("Survey stopped");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
|
||||
if (response == true)
|
||||
{
|
||||
Serial.print("Press x to end survey - ");
|
||||
Serial.print("Time elapsed: ");
|
||||
Serial.print((String)myGPS.svin.observationTime);
|
||||
|
||||
Serial.print(" Accuracy: ");
|
||||
Serial.print((String)myGPS.svin.meanAccuracy);
|
||||
Serial.println();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("SVIN request failed");
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println("Survey valid!");
|
||||
|
||||
Serial.println("Base survey complete! RTCM now broadcasting.");
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX | COM_TYPE_RTCM3); //Set the I2C port to output UBX and RTCM sentences (not really an option, turns on NMEA as well)
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
||||
|
||||
//This function gets called from the SparkFun Ublox Arduino Library.
|
||||
//As each RTCM byte comes in you can specify what to do with it
|
||||
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
|
||||
void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
|
||||
{
|
||||
#ifdef USE_SERIAL1
|
||||
//Push the RTCM data to Serial1
|
||||
Serial1.write(incoming);
|
||||
#endif
|
||||
|
||||
//Pretty-print the HEX values to Serial
|
||||
if (myGPS.rtcmFrameCounter % 16 == 0) Serial.println();
|
||||
Serial.print(" ");
|
||||
if (incoming < 0x10) Serial.print("0");
|
||||
Serial.print(incoming, HEX);
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 9th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example does all steps to configure and enable a ZED-F9P as a base station:
|
||||
Begin Survey-In
|
||||
Once we've achieved 2m accuracy and 300s have passed, survey is complete
|
||||
Enable six RTCM messages
|
||||
Begin outputting RTCM bytes
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||
Plug a SerLCD onto the Qwiic bus
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Watch the output on the LCD or open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#define STAT_LED 13
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
#include <SerLCD.h> //http://librarymanager/All#SparkFun_SerLCD
|
||||
SerLCD lcd; // Initialize the library with default I2C address 0x72
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("Ublox GPS I2C Test");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
pinMode(STAT_LED, OUTPUT);
|
||||
digitalWrite(STAT_LED, LOW);
|
||||
|
||||
lcd.begin(Wire); //Set up the LCD for Serial communication at 9600bps
|
||||
lcd.setBacklight(0x4B0082); //indigo, a kind of dark purplish blue
|
||||
lcd.clear();
|
||||
lcd.print(F("LCD Ready"));
|
||||
|
||||
myGPS.begin(Wire);
|
||||
if (myGPS.isConnected() == false)
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F("No GPS detected"));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("GPS Detected");
|
||||
|
||||
//myGPS.setI2COutput(COM_TYPE_RTCM3); //Set the I2C port to output RTCM3 sentences (turn off NMEA noise)
|
||||
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX sentences (turn off NMEA noise)
|
||||
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
|
||||
|
||||
boolean response = true;
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_I2C, 1);
|
||||
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
|
||||
if (response == true)
|
||||
{
|
||||
Serial.println(F("RTCM messages enabled"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("RTCM failed to enable. Are you sure you have an ZED-F9P? Freezing."));
|
||||
while (1)
|
||||
; //Freeze
|
||||
}
|
||||
|
||||
//Check if Survey is in Progress before initiating one
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Failed to get Survey In status. Freezing."));
|
||||
while (1)
|
||||
; //Freeze
|
||||
}
|
||||
|
||||
if (myGPS.svin.active == true)
|
||||
{
|
||||
Serial.print(F("Survey already in progress."));
|
||||
lcd.setCursor(0, 2);
|
||||
lcd.print(F("Survey already going"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Start survey
|
||||
response = myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
|
||||
if (response == false)
|
||||
{
|
||||
Serial.println(F("Survey start failed"));
|
||||
lcd.setCursor(0, 3);
|
||||
lcd.print(F("Survey start failed. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
Serial.println(F("Survey started. This will run until 60s has passed and less than 5m accuracy is achieved."));
|
||||
}
|
||||
|
||||
while (Serial.available())
|
||||
Serial.read(); //Clear buffer
|
||||
|
||||
lcd.clear();
|
||||
lcd.print(F("Survey in progress"));
|
||||
|
||||
//Begin waiting for survey to complete
|
||||
while (myGPS.svin.valid == false)
|
||||
{
|
||||
if (Serial.available())
|
||||
{
|
||||
byte incoming = Serial.read();
|
||||
if (incoming == 'x')
|
||||
{
|
||||
//Stop survey mode
|
||||
response = myGPS.disableSurveyMode(); //Disable survey
|
||||
Serial.println(F("Survey stopped"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
|
||||
if (response == true)
|
||||
{
|
||||
Serial.print(F("Press x to end survey - "));
|
||||
Serial.print(F("Time elapsed: "));
|
||||
Serial.print((String)myGPS.svin.observationTime);
|
||||
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F("Elapsed: "));
|
||||
lcd.print((String)myGPS.svin.observationTime);
|
||||
|
||||
Serial.print(F(" Accuracy: "));
|
||||
Serial.print((String)myGPS.svin.meanAccuracy);
|
||||
Serial.println();
|
||||
|
||||
lcd.setCursor(0, 2);
|
||||
lcd.print(F("Accuracy: "));
|
||||
lcd.print((String)myGPS.svin.meanAccuracy);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("SVIN request failed"));
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println(F("Survey valid!"));
|
||||
|
||||
Serial.println(F("Base survey complete! RTCM now broadcasting."));
|
||||
lcd.clear();
|
||||
lcd.print(F("Transmitting RTCM"));
|
||||
|
||||
myGPS.setI2COutput(COM_TYPE_UBX | COM_TYPE_RTCM3); //Set the I2C port to output UBX and RTCM sentences (not really an option, turns on NMEA as well)
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
|
||||
|
||||
//Do anything you want. Call checkUblox() every second. ZED-F9P has TX buffer of 4k bytes.
|
||||
|
||||
delay(250); //Don't pound too hard on the I2C bus
|
||||
}
|
||||
|
||||
//This function gets called from the SparkFun Ublox Arduino Library.
|
||||
//As each RTCM byte comes in you can specify what to do with it
|
||||
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
|
||||
void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
|
||||
{
|
||||
//Let's just pretty-print the HEX values for now
|
||||
if (myGPS.rtcmFrameCounter % 16 == 0)
|
||||
Serial.println();
|
||||
Serial.print(" ");
|
||||
if (incoming < 0x10)
|
||||
Serial.print("0");
|
||||
Serial.print(incoming, HEX);
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 9th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query the module for RELPOS information in the NED frame.
|
||||
It assumes you already have RTCM correction data being fed to the receiver.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a RedBoard Qwiic or BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
//#define USE_SERIAL1 // Uncomment this line to push the RTCM data from Serial1 to the module via I2C
|
||||
|
||||
size_t numBytes = 0; // Record the number os bytes received from Serial1
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); //Wait for user to open terminal
|
||||
Serial.println("Ublox Base station example");
|
||||
|
||||
#ifdef USE_SERIAL1
|
||||
// If our board supports it, we can receive the RTCM data on Serial1
|
||||
Serial1.begin(115200);
|
||||
#endif
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
|
||||
//myGPS.factoryDefault(); delay(5000);
|
||||
|
||||
#ifdef USE_SERIAL1
|
||||
Serial.print(F("Enabling UBX and RTCM input on I2C. Result: "));
|
||||
Serial.print(myGPS.setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_RTCM3)); //Enable UBX and RTCM input on I2C
|
||||
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (myGPS.getRELPOSNED() == true)
|
||||
{
|
||||
Serial.print("relPosN: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosN, 4);
|
||||
Serial.print("relPosE: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosE, 4);
|
||||
Serial.print("relPosD: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosD, 4);
|
||||
|
||||
Serial.print("relPosLength: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosLength);
|
||||
Serial.print("relPosHeading: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosHeading);
|
||||
|
||||
Serial.print("relPosHPN: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosHPN);
|
||||
Serial.print("relPosHPE: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosHPE);
|
||||
Serial.print("relPosHPD: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosHPD);
|
||||
Serial.print("relPosHPLength: ");
|
||||
Serial.println(myGPS.relPosInfo.relPosHPLength);
|
||||
|
||||
Serial.print("accN: ");
|
||||
Serial.println(myGPS.relPosInfo.accN, 4);
|
||||
Serial.print("accE: ");
|
||||
Serial.println(myGPS.relPosInfo.accE, 4);
|
||||
Serial.print("accD: ");
|
||||
Serial.println(myGPS.relPosInfo.accD, 4);
|
||||
|
||||
Serial.print("gnssFixOk: ");
|
||||
if (myGPS.relPosInfo.gnssFixOk == true)
|
||||
Serial.println("x");
|
||||
else
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("diffSolution: ");
|
||||
if (myGPS.relPosInfo.diffSoln == true)
|
||||
Serial.println("x");
|
||||
else
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("relPosValid: ");
|
||||
if (myGPS.relPosInfo.relPosValid == true)
|
||||
Serial.println("x");
|
||||
else
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("carrier Solution Type: ");
|
||||
if (myGPS.relPosInfo.carrSoln == 0)
|
||||
Serial.println("None");
|
||||
else if (myGPS.relPosInfo.carrSoln == 1)
|
||||
Serial.println("Float");
|
||||
else if (myGPS.relPosInfo.carrSoln == 2)
|
||||
Serial.println("Fixed");
|
||||
|
||||
Serial.print("isMoving: ");
|
||||
if (myGPS.relPosInfo.isMoving == true)
|
||||
Serial.println("x");
|
||||
else
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("refPosMiss: ");
|
||||
if (myGPS.relPosInfo.refPosMiss == true)
|
||||
Serial.println("x");
|
||||
else
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("refObsMiss: ");
|
||||
if (myGPS.relPosInfo.refObsMiss == true)
|
||||
Serial.println("x");
|
||||
else
|
||||
Serial.println("");
|
||||
}
|
||||
else
|
||||
Serial.println("RELPOS request failed");
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
#ifdef USE_SERIAL1
|
||||
uint8_t store[256];
|
||||
while ((Serial1.available()) && (numBytes < 256)) // Check if data has been received
|
||||
{
|
||||
store[numBytes++] = Serial1.read(); // Read a byte from Serial1 and store it
|
||||
}
|
||||
if (numBytes > 0) // Check if data was received
|
||||
{
|
||||
//Serial.print("Pushing ");
|
||||
//Serial.print(numBytes);
|
||||
//Serial.println(" bytes via I2C");
|
||||
myGPS.pushRawData(((uint8_t *)&store), numBytes); // Push the RTCM data via I2C
|
||||
numBytes = 0; // Reset numBytes
|
||||
}
|
||||
#endif
|
||||
delay(10);
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
Get a device's I2C address using advanced getVal method
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 9th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
|
||||
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
|
||||
commands instead. This example shows how to use this new command structure.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a RedBoard Qwiic or BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("u-blox getVal example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
|
||||
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB
|
||||
|
||||
uint8_t currentI2Caddress = myGPS.getVal8(UBLOX_CFG_I2C_ADDRESS);
|
||||
Serial.print("Current I2C address (should be 0x42): 0x");
|
||||
Serial.println(currentI2Caddress >> 1, HEX); //Ublox module returns a shifted 8-bit address. Make it 7-bit unshifted.
|
||||
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//Query module only every second. Doing it more often will just cause I2C traffic.
|
||||
//The module only responds when a new position is available
|
||||
if (millis() - lastTime > 1000)
|
||||
{
|
||||
lastTime = millis(); //Update the timer
|
||||
|
||||
long latitude = myGPS.getLatitude();
|
||||
Serial.print(F("Lat: "));
|
||||
Serial.print(latitude);
|
||||
|
||||
long longitude = myGPS.getLongitude();
|
||||
Serial.print(F(" Long: "));
|
||||
Serial.print(longitude);
|
||||
Serial.print(F(" (degrees * 10^-7)"));
|
||||
|
||||
long altitude = myGPS.getAltitude();
|
||||
Serial.print(F(" Alt: "));
|
||||
Serial.print(altitude);
|
||||
Serial.print(F(" (mm)"));
|
||||
|
||||
byte SIV = myGPS.getSIV();
|
||||
Serial.print(F(" SIV: "));
|
||||
Serial.print(SIV);
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: January 9th, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
|
||||
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
|
||||
commands instead. This example shows how to use this new command structure.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a RedBoard Qwiic or BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("u-blox getVal example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
|
||||
{
|
||||
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
|
||||
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB
|
||||
|
||||
bool setValueSuccess;
|
||||
|
||||
//These key values are hard coded and defined in u-blox_config_keys.h.
|
||||
//You can obtain them from the ZED-F9P interface description doc
|
||||
//or from u-center's Messages->CFG->VALSET window. Keys must be 32-bit.
|
||||
//setValueSuccess = myGPS.setVal(UBLOX_CFG_NMEA_HIGHPREC, 0); //Enable high precision NMEA
|
||||
setValueSuccess = myGPS.setVal(UBLOX_CFG_RATE_MEAS, 100); //Set measurement rate to 100ms (10Hz update rate)
|
||||
//setValueSuccess = myGPS.setVal(UBLOX_CFG_RATE_MEAS, 1000); //Set measurement rate to 1000ms (1Hz update rate)
|
||||
|
||||
//Below is the original way we enabled the RTCM message on the I2C port. After that, we show how to do the same
|
||||
//but with setVal().
|
||||
//Original: myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
//setValueSuccess = myGPS.setVal(0x209102bd, 1); //Set output rate of msg 1005 over the I2C port to once per second
|
||||
|
||||
if (setValueSuccess == true)
|
||||
{
|
||||
Serial.println("Value was successfully set");
|
||||
}
|
||||
else
|
||||
Serial.println("Value set failed");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
Configuring port settings using the newer getVal/setVal methods
|
||||
By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Date: October 23rd, 2020
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
This example shows how to query a u-blox module for its UART1 settings and
|
||||
then change them if the settings aren't what we want.
|
||||
|
||||
Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a RedBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("SparkFun u-blox Example");
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
|
||||
{
|
||||
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
bool response = true;
|
||||
|
||||
//Read the settings from RAM (what the module is running right now, not BBR, Flash, or default)
|
||||
uint8_t currentUART1Setting_ubx = myGPS.getVal8(UBLOX_CFG_UART1INPROT_UBX);
|
||||
uint8_t currentUART1Setting_nmea = myGPS.getVal8(UBLOX_CFG_UART1INPROT_NMEA);
|
||||
uint8_t currentUART1Setting_rtcm3 = myGPS.getVal8(UBLOX_CFG_UART1INPROT_RTCM3X);
|
||||
|
||||
Serial.print("currentUART1Setting_ubx: ");
|
||||
Serial.println(currentUART1Setting_ubx);
|
||||
Serial.print("currentUART1Setting_nmea: ");
|
||||
Serial.println(currentUART1Setting_nmea);
|
||||
Serial.print("currentUART1Setting_rtcm3: ");
|
||||
Serial.println(currentUART1Setting_rtcm3);
|
||||
|
||||
//Check if NMEA and RTCM are enabled for UART1
|
||||
if (currentUART1Setting_ubx == 0 || currentUART1Setting_nmea == 0)
|
||||
{
|
||||
Serial.println("Updating UART1 configuration");
|
||||
|
||||
//setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed
|
||||
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_UBX, 1); //Enable UBX on UART1 Input
|
||||
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_NMEA, 1); //Enable NMEA on UART1 Input
|
||||
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_RTCM3X, 0); //Disable RTCM on UART1 Input
|
||||
|
||||
if (response == false)
|
||||
Serial.println("SetVal failed");
|
||||
else
|
||||
Serial.println("SetVal succeeded");
|
||||
}
|
||||
else
|
||||
Serial.println("No port change needed");
|
||||
|
||||
//Change speed of UART2
|
||||
uint32_t currentUART2Baud = myGPS.getVal32(UBLOX_CFG_UART2_BAUDRATE);
|
||||
Serial.print("currentUART2Baud: ");
|
||||
Serial.println(currentUART2Baud);
|
||||
|
||||
if (currentUART2Baud != 57600)
|
||||
{
|
||||
response &= myGPS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 57600);
|
||||
if (response == false)
|
||||
Serial.println("SetVal failed");
|
||||
else
|
||||
Serial.println("SetVal succeeded");
|
||||
}
|
||||
else
|
||||
Serial.println("No baud change needed");
|
||||
|
||||
Serial.println("Done");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module
|
||||
Based on Example7 By: Nathan Seidle
|
||||
SparkFun Electronics
|
||||
Updated by Paul Clark to demonstrate setVal8/16/32, newCfgValset8/16/32, addCfgValset8/16/32 and sendCfgValset8/16/32
|
||||
Date: July 1st, 2019
|
||||
License: MIT. See license file for more information but you can
|
||||
basically do whatever you want with this code.
|
||||
|
||||
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
|
||||
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
|
||||
commands instead. This example shows how to use this new command structure.
|
||||
|
||||
Feel like supporting open source hardware?
|
||||
Buy a board from SparkFun!
|
||||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||
NEO-M8P RTK: https://www.sparkfun.com/products/15005
|
||||
SAM-M8Q: https://www.sparkfun.com/products/15106
|
||||
|
||||
Hardware Connections:
|
||||
Plug a Qwiic cable into the GPS and a RedBoard Qwiic or BlackBoard
|
||||
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||
Open the serial monitor at 115200 baud to see the output
|
||||
*/
|
||||
|
||||
#include <Wire.h> //Needed for I2C to GPS
|
||||
|
||||
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||
SFE_UBLOX_GPS myGPS;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
; //Wait for user to open terminal
|
||||
Serial.println("u-blox multi setVal example");
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
|
||||
|
||||
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
|
||||
{
|
||||
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
|
||||
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB
|
||||
|
||||
bool setValueSuccess = true;
|
||||
|
||||
//These key values are hard coded. You can obtain them from the ZED-F9P interface description doc
|
||||
//or from u-center's Messages->CFG->VALSET window. Keys must be 32-bit.
|
||||
//Choose setVal8, setVal16 or setVal32 depending on the required value data width (1, 2 or 4 bytes)
|
||||
//L, U1, I1, E1 and X1 values are 8-bit
|
||||
//U2, I2, E2 and X2 values are 16-bit
|
||||
//U4, I4, R4, E4, X4 values are 32-bit
|
||||
|
||||
setValueSuccess &= myGPS.setVal8(UBLOX_CFG_NMEA_HIGHPREC, 0); //Enable high precision NMEA (value is 8-bit (L / U1))
|
||||
//setValueSuccess &= myGPS.setVal16(UBLOX_CFG_RATE_MEAS, 200); //Set measurement rate to 100ms (10Hz update rate) (value is 16-bit (U2))
|
||||
//setValueSuccess &= myGPS.setVal16(UBLOX_CFG_RATE_MEAS, 200, 1); //Set rate setting in RAM instead of BBR
|
||||
setValueSuccess &= myGPS.setVal16(UBLOX_CFG_RATE_MEAS, 1000); //Set measurement rate to 1000ms (1Hz update rate) (value is 16-bit (U2))
|
||||
|
||||
//Below is the original way we enabled a single RTCM message on the I2C port. After that, we show how to do the same
|
||||
//but with multiple messages all in one go using newCfgValset, addCfgValset and sendCfgValset.
|
||||
//Original: myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
|
||||
|
||||
//Begin with newCfgValset8/16/32
|
||||
setValueSuccess &= myGPS.newCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1); //Set output rate of msg 1005 over the I2C port to once per measurement (value is 8-bit (U1))
|
||||
//setValueSuccess &= myGPS.newCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1, VAL_LAYER_RAM); //Set this and the following settings in RAM only instead of Flash/RAM/BBR
|
||||
//Add extra keyIDs and values using addCfgValset8/16/32
|
||||
setValueSuccess &= myGPS.addCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1077_I2C, 1); //Set output rate of msg 1077 over the I2C port to once per measurement (value is 8-bit (U1))
|
||||
setValueSuccess &= myGPS.addCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1087_I2C, 1); //Set output rate of msg 1087 over the I2C port to once per measurement (value is 8-bit (U1))
|
||||
setValueSuccess &= myGPS.addCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1127_I2C, 1); //Set output rate of msg 1127 over the I2C port to once per measurement (value is 8-bit (U1))
|
||||
setValueSuccess &= myGPS.addCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1097_I2C, 1); //Set output rate of msg 1097 over the I2C port to once per measurement (value is 8-bit (U1))
|
||||
// Add the final value and send the packet using sendCfgValset8/16/32
|
||||
setValueSuccess &= myGPS.sendCfgValset8(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 10); //Set output rate of msg 1230 over the I2C port to once every 10 measurements (value is 8-bit (U1))
|
||||
|
||||
if (setValueSuccess == true)
|
||||
{
|
||||
Serial.println("Values were successfully set");
|
||||
}
|
||||
else
|
||||
Serial.println("Value set failed");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
|
||||
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
|
||||
project(sparkfun_ublox_zephyr_library)
|
||||
|
||||
zephyr_compile_options(-fdiagnostics-color=always)
|
||||
|
||||
zephyr_include_directories(.)
|
||||
target_sources(app PRIVATE src/SparkFun_Ublox_Zephyr_Library.cpp)
|
||||
target_sources(app PRIVATE src/SparkFun_Ublox_Zephyr_Interface.cpp)
|
||||
|
||||
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c)
|
@ -0,0 +1,4 @@
|
||||
&i2c0 {
|
||||
status = "okay";
|
||||
compatible = "nordic,nrf-twim";
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
#turn on c++ support
|
||||
CONFIG_CPLUSPLUS=y
|
||||
|
||||
# turn on peripherals
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_0=y
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user