Arduino lawn mower gps. GPS-RTK Hookup Guide

Implementation of an IoT-Based Solar-Powered Smart Lawn Mower

Abstract

Rapid growth in technology has created opportunities to design and develop high-end applications and tools. Conventional mowers in practice are mostly fuel-powered and require personnel assistance for operation. This work develops a Smart lawn mower powered by a solar photovoltaic (PV) panel and controlled by an Internet of Things- (IoT-) based technique. The designed lawn mower comprises one brushless direct current (BLDC) motor, four gear motors, sensors, an Arduino-based charge controller, and a Raspberry Pi-powered renewable energy source making it a sustainable device. A lawn mower is operated and controlled through an Android application. Raspberry Pi is used as an edge computing device for transmitting data through the Internet and for communication with Android applications. Arduino UNO is used for energy management and motor control operation. The main novelty of this research is IOT-based motion control feature which provides the user the provision to operate the mower remotely. Results of the designed model depict an average of 89.5% electrical efficiency of the system based on varying weather conditions. Application of the designed model is golf clubs, playgrounds, and lawns eliminating operator costs, saving energy, reducing noise pollution, and achieving environmental sustainability goals.

Introduction

With the advancements in technology, conventional ways of performing different tasks have been replaced with improved methods. Human work is being replaced by machines fully or partially, and automation is getting involved in commercial and domestic processes. Like in different industries to increase production and to improve accuracy, the use of robotics is becoming very common day by day. Similarly, daily life domestic tasks are also getting automated with the help of recent technologies. Along with automation, solar energy is another area that is becoming popular over time. It has become an important source of power generation because it is pollution-free. Sun is the main source of solar energy, and the energy through the sun is about 12 times the total world’s energy demand. PV cells are being used to convert solar energy into electrical energy, and this process has an efficiency of about 18% to 23% [1]. Automation and solar photovoltaic energy are the two modern technologies that have been used in this research to improve conventional lawn mowers.

1.1. Background

A few decades back, a lot of human effort was required for grass-cutting tasks. Over time, a large amount of human effort has been replaced with a single person and a machine. These machines were operated manually by humans. Later on, these machines were upgraded with engines and sharp blades as shown in Figure 1 [2]. These engines use conventional energy sources which are not environment friendly and result in global warming. Global warming is one of the major challenges that humanity is facing, and it needs to be addressed seriously. The engines used for mowers are getting replaced with electric motors which require electrical power for their operation, and the electrical power used for motors still comes from conventional energy sources. The same is the case with conventional lawnmowers. Such mowers also need a long cord to power the electric motors of grass cutters that is very dangerous as it operates on high voltages. It also limits the operational range of these mowers because of the limited cord length. Increasing the chord length also increases operational costs. Despite the addition of motors, lawn mowers still require a significant amount of human effort to operate. So, this human effort can further be reduced by using the latest technology as proposed in this work.

1.2. Literature Review

Solar-powered Smart lawnmower developed in [3] is an advanced version of a grass-cutting machine. It gets its power from a photovoltaic module mounted on the top and uses Smart control methods for the movement of the lawnmower. The electrical energy produced by the solar panel is stored in a 12 V battery by using a charge controller. The complete operation of this lawnmower is controlled by computing devices used in the design. Motors are controlled by the driver circuit. Mowing is done using a high-speed DC motor which provides the torque required to drive the blades directly coupled with the shaft of the motor. The IoT-based control of this lawnmower is based on Hypertext Transfer Protocol (HTTP) requests and a python code written to control the lawnmower. The unique Internet Protocol (IP) address of the lawnmower along with the Transmission Control Protocol (TCP) request is used to control the lawnmower. Furthermore, an Android application is designed to call HTTP addresses when any key is pressed. All the keys have different addresses assigned to them.

In [4], a solution for the solar-powered Smart lawnmower is proposed, where a PIC 16F877 microcontroller for robotic operation is used. While for solar charging, they used a direct online (DOL) connection method in which the solar panel is directly connected to the battery for charging. A gyroscope sensor is used to control the directions of the system. The microcontroller reads distance in meters and moves to the left side when the meter is complete. In [5], an artificial intelligence- (AI-) based lawn mowing model is proposed. In this paper, a Smart lawn mowing method is proposed using computer vision (CV) and ultrasonic sensors. A Raspberry Pi 3 is used as the main controller which runs the python code for AI. An ultrasonic sensor is used in this work for distance measurement from an obstacle. The Pi camera is used for video streaming and based on convolution neural network (CNN), the obstacle detection model is applied to the video stream. Raspberry Pi detects the obstacles and sends signals to move the motor driver according to the AI algorithm. In [6], three motors are used to make the design cost-efficient. Two motors are directly coupled with rear wheels while the front wheel is freely moveable. For solar charging, a PWM-based solar charge controller is used while Arduino is used as the main controller of the project. In this paper, the author performs a stress-strain analysis on solid works for a lawnmower. The overall system efficiency is 93.37%. Likewise, some other lawn mowers are proposed in [7, 8]. In these papers, Arduino UNO microcontroller interfaced with Bluetooth module is used for main control of lawn mower. The Bluetooth module is connected to an Android application. Users send navigation commands from the Android application. The proposed design is simulated on Proteus, and it is verified through hardware implementation [7]. While in [8], additional PIR sensors along with ultrasonic sensors are used for pathfinding and obstacle detection.

A model of solar-powered lawn mower controlling RF communication is proposed in [9]. An HT12E encoder IC is used to convert the received parallel data to serial data. The microcontroller is programmed according to the time interval of HT12E output. Each functionality is differentiated by the high duration of each channel. HT12E starts working at a low signal at the TE pin. This low signal on the TE pin starts the communication of 4 data bits. Likewise, [10] proposed a cost-efficient autonomous Smart lawnmower. It is a two-wheeled robot that can also be controlled manually using the mobile app. ESP8266 is used as a microcontroller for this robot. For remote control operation, a camera is installed on ESP8266 for live video streaming on the mobile screen. L298N motor driver is also used to drive the wheel motors, whereas the speed of motors is controlled by PWM. Similarly, a vision-based solar-powered robotic mower is presented in [11]. Unlike other robotic mowers, this design requires no wires to maintain its operation within the lawn. The design also detects and avoids objects and humans on the lawn. Another solar-powered lawn mower is developed in [12]. It is comprised of a direct current (D.C) motor, a rechargeable battery, a solar panel, a stainless-steel blade, and a control switch. Performance evaluation of the developed machine is carried out with different types of grasses and the design gives good results. over, in [13], another solar-powered lawn mower is implemented. A design is proposed for the lawn mower that is powered through solar energy as well as electrical energy. This reduced both environment and noise pollution.

Most recently, a fully autonomous solar-powered lawn mower is presented in [14]. In this design, 12 V batteries are used to power all the electrical components. Arduino microcontroller is used to control the motors used for the movement of the mower and the grass cutter motor. Based on information coming from the sensors, controller makes the corresponding decisions. The 12-volt battery used in this design is continuously charged by a solar panel mounted on the top of this mower. The presented design is simple and cheaper than other solutions. Another solar-powered lawn mower is implemented on the principle of mowing in [15]. The components used in this work are a direct current (DC) motor, battery, solar panel, steel blade, and speed controller. The required torque necessary for the steel blade was achieved through the DC motor. The speed controller is used to control the speed of the DC motor. The battery involved in this work is recharged through the charging circuit containing a solar panel and charge controller. The performance of the developed mower is evaluated with various thicknesses and shapes of the cutting blade. It was found that the cutting efficiency of the mower ranges from 70.50% to 84.10%. over, in [16], fabrication and working of a Smart solar grass cutter are presented. An efficient and environment-friendly solar-powered lawn mower is designed for this work. A microcontroller is used to control the different lawn mowing movements and actions. Two DC motors are used for the movement of the grass cutter, whereas one DC blade motor is used for grass cutting. It is designed to be remotely controlled using an Arduino UNO microcontroller. A Smart Solar Tracker is also implemented via Bluetooth and a smartphone. It can operate for more than two hours when the battery is fully charged. A comparison of the abovementioned design is presented in Table 1.

There are some other lawn mowers available that lack the feature of being solar-powered; yet, their working and design are very significant. These are nonsolar but electrically powered and autonomously control lawn mowers, like a robotic system is developed in [17]. This work deals with the fabrication and design of the prototype. For the computer-aided design and simulation of an automated lawn mower, the author used Auto-desk Inventor 2018. The electrical system containing the connections between the microcontroller and the rest of the electrical system is designed to cut grass efficiently with minimum or zero human effort. The designed model of lawn mower contains GPS, cameras, infrared, and ultrasonic sensors for obstacle detection. Arduino microcontroller is used to control the two geared motors to control the direction of the lawn mower. The controlling is done by readings from the sensors connected to the microcontroller. The mower makes a 180-degree turn in case of any obstacle is detected in the path, and it cuts the grass with high efficiency. Similarly, another automated lawn mower is developed in [18]. This paper deals with the design of a Smart lawn mower able to distinguish between obstacles using image processing. A user interfaces mobile phone application is designed so that users can choose the slow mode, inching mode, and obstacle avoidance mode. Rather than using wheels and tires, crawler tracks are used for better surface gripping. In this lawn mower, the built-in python toolkit “Tkinter” is used for the actions to be taken for the lawn mower using a human-machine interface. The Digital Signal Processing (DSP) chip is used as the core controller of the project while Raspberry Pi is used for image recognition and human-machine interface. Another fully automated lawn mower that can be used with minimum human effort is presented in [19]. The lawn mower is designed to cut the grass within a predefined ground area without any user intervention. It can also be used in any other location using radio control (RC). In this model, Raspberry Pi 3 is used as the main controller communicating with the RC transmitter and Navio2-HAT for GPS location. Another battery power lawn mower is proposed in [20]. The primary FOCUS of this project is to get higher electrical efficiency and reduce the cost by the use of Li-ion batteries and brushless direct current (BLDC) motors. Simple electrical circuits using operational amplifiers and voltage sensors are used for the protection of motors and batteries.

With the advancement in technology, new approaches are being employed for lawn mowing. This context [21] highlights some of the problems in conventional lawn mowing techniques and models. As a solution, an electrically powered lawn mower vehicle is designed for this work. The mower is powered by Li-ion batteries, and a solar platform is installed for the charging of batteries. The mechanical structure is flexible to change the height of the blades during grass cutting. Image processing techniques are also used for obstacle detection and path planning. Another solar-powered lawn mower is developed in [22] with an ARM controller along with ultrasonic and color sensors. A color sensor is used for grass detection while an ultrasonic sensor is used for obstacle detection. The system is tested on different ground surfaces, and it is concluded that the model can be used efficiently on flat surfaces.

The sensor data is crucial for robotic navigational tasks like path planning and collision or obstacle avoidance. AI algorithms may have the ability to adapt obstacle detection and pathfinding with much higher efficiency than microcontrollers. In this context, a method for obstacle detection using digital image processing is proposed by [23]. The paper deals with object classification that usually exists on football grounds. This work deals with image filtering, segmentation, and edge detection using image processing. RoboRealm tool is used for object detection and recognition, whereas [24] proposed a model for obstacle detection in the path using machine learning. The model can estimate the distance, scale information, and distinguish pedestrians from other barriers using a camera. The machine learning model is divided into two branches: obstacle estimation and pedestrian detection. These two branches are used for infers scales and pedestrian categorical detection, respectively. The model is tested, and results are collected during a real-time experiment with a maximum distance error of 5% and 94% pedestrian detection accuracy.

Nowadays, Android phones have become an important part of our daily life. Rather than using radio control methods for robotics, engineers are working on smartphone applications to control robots directly from Android applications. There are some lawn mowers presented recently that are working with Android applications. The implementation of Android applications for mower operation results in low-cost lawn mowers. In this regard, Android-controlled lawn mowers are proposed in [25, 26]. Like other models, an Arduino microcontroller is used as the main controller for these mowers while a Bluetooth module is used to communicate with the Android application. The Android applications for these projects are designed in MIT app inventor. The fusion of robotics with the IoT has given rise to a new idea known as IoT-aided robotics technology or the Internet of Robotic Things (IoRT). The IoRT technology has also resulted in the development of effective mobile robot applications. Such mobile robot applications can be used for services, household tasks, and healthcare. Like in [27], an IoRT lawn mower working with IBM and Cloud services is presented. IBM Cloud is used as a means of communication between Android applications and microcontrollers. Furthermore, an IoT-based robot lawn mower is developed [28]. In this work, the assembly of the mower is based on PVC pipes, while an additional water sprinkler feature is also added to the robotic mower. Users can operate sprinklers and control the mower through Bluetooth connectivity with an Android phone. Industrial IoT applications are carried out using a safe infrastructure to communicate with sensors and surveillance cameras. Thenceforth, the Industrial Internet of Things (IIOT) can be used with machine learning-based algorithm for monitoring and event detection [29].

There are some nonprogramming-based online tools available for the development of the Android application. MIT app inventor is one of these open-source online tools for designing and developing custom Android applications [30]. HTTP requests are one of the widely used methods for Android communication, while a microcontroller connected to the local area network is used as a server and receives HTTP requests over the same network. To control any GPIO pin of the NodeMCU, a unique request along with IP address and port number is accessed through a web browser while connected to the same network [31]. Based on such technology, a mobile robot is proposed in [32] that can be controlled using Wi-Fi. The primary aim of this robot is to expand the control radius of the robot. Wi-Fi has a wide range as compared with other communication mediums like Bluetooth and Infrared. ESP8266 development module is used in it as a microcontroller. A Telnet SSH server is created on LAN which made it possible to be connected with external clients. The PC control software sends the speed parameters of the robot motors (in the range of 0 to 100), and it is connected to the control unit of the mobile robot (server) as a client via TCP/IP connection. The speed of the rear motors can be changed by changing the PWM pulse width. The application managing TCP/IP-based connection and control of the mobile robot is built up of two classes. In the first class, there is the description of TCP/IP connection, where the responsibility of the TCP client class is to establish, maintain, and close new connections on the IP address and port. In the second class, there is the description of performing control of the mobile robot by cursor keys.

1.3. Objectives

Considering all the issues mentioned in the background and limitations in the previous work mentioned in the literature review, a solar-powered Smart lawnmower is proposed as the best solution. As the world is focused on using renewable energy resources to overcome greenhouse gases. This work will be very useful for reducing fuel consumption. over, it significantly reduces further human efforts required for the process of grass cutting. The designed lawnmower is applicable on large ground areas like golf clubs, cricket grounds, or parks where a large area is needed to be mowed. Conventionally, a large number of human operators or ground keepers need to be hired for lawn mowing, but this lawn mower is very useful in such areas as a single user can cut grass without operating it manually. over, solar energy allows operating this mower in large areas where power cords cannot reach power grid-powered mowers. The novelty of this research involves two aspects. Firstly, the lawn mower is powered with PV that powers all the electrical equipment of lawn mower, and it supplies electrical power to charge the battery to be used during night time. Secondly, the mower is controlled using IoT-architecture which made it possible to reduce the human labor.

The section division of this paper is as follows. Section 2 outlines the design and implementation, whereas Section 3 contains Results and Discussion. Finally, Section 4 contains the conclusion of this research work.

Design and Implementation

The work is divided into two parts. In the first part, detail about hardware is mentioned, whereas the second part is composed of software architecture developed for the proposed design. Figure 2 is the block diagram of the proposed design.

GPS-RTK Hookup Guide

The NEO-M8P-2 module is great module for high accuracy GNSS and GPS location solutions including RTK. The NEO-M8P-2 is unique in that it is was one of the first modules from u-blox capable of both rover and base station operations. The ‘-2’ designation means this module has survey-in mode allowing the module to become a base station and produce RTCM 3.x correction data. From here on we will refer to the module as NEO-M8P but it should not be confused with the NEO-M8P-0 module (which is not able to produce RTCM data).

SparkFun GPS-RTK Board. NEO-M8P-2 (Qwiic)

The SparkFun GPS-RTK Board is a powerful breakout for the NEO-M8P-2 module from u-blox. The NEO-M8P-2 is a top-of-the-line mo…

Suggested Reading

Before getting started, be sure to checkout our What is GPS RTK? tutorial and if you want to pre-read a bit have a look at our Getting Started with U-Center.

arduino, lawn, mower, gps-rtk, hookup

Hardware Overview

Communication Ports

The NEO-M8P-2 is unique in that it has four communication ports which are all active simultaneously. You can read NMEA data over I2C while you send configuration commands over the UART and vice/versa. The only limit is that the SPI pins are mapped onto the I2C and UART pins so it’s either SPI or I2CUART. The USB port is available at all times.

USB

The micro-B connector makes it easy to connect the NEO-M8P to u-center for configuration and quick viewing of NMEA sentences. It is also possible to connect a Raspberry Pi or other SBC over USB. The NEO-M8P enumerates as a serial COM port and it is a seperate serial port from the UART interface. See Getting Started with U-Center for more information about getting the USB port to be a serial COM port.

A 3.3V regulator is provided to regulate the 5V USB down to 3.3V the module requires. External 5V can be applied or a direct feed of 3.3V can be provided. Note that if you’re provide the board with 3.3V directly it should be a clean supply with minimal noise (less than 50mV VPP ripple is ideal for precision locating).

I 2 C (a.k.a DDC)

The u-blox NEO-M8P has a DDC port which is really just an I2C port (without all the fuss of trademark issues). All features are accessible over the I2C ports including reading NMEA sentences, sending UBX configuration strings, piping RTCM data into the module, etc. We’ve written a handful of sketches and an Arduino library to aid in using the NEO-M8P over I2C in a snap. You can get the library through the Arduino library manager by searching ‘SparkFun u-blox GNSS’. Checkout the SparkFun u-blox GNSS Arduino Library section for more information.

UART/Serial

The classic serial pins are available on the NEO-M8P but are shared with the SPI pins. Because USB covers most serial needs we didn’t label the UART pins explicitly. By default the UART pins are enabled. Be sure the DSEL jumper on the rear of the board is open.

SPI

The NEO-M8P can also be configured for SPI communication. By default the SPI port is disable. To enable SPI close the DSEL jumper on the rear of the board. Closing this jumper will disable the UART and I2C interfaces.

Control Pins

The control pins are highlighted below.

These pins are used for various extra control of the NEO-M8P:

  • FENCE: Geofence output pin. Configured with U-Center. Will go high or low when a geofence is setup. Useful for triggering alarms and actions when the module exits a programmed perimeter.
  • RTK: RTK output pin. Remains high when module is normal GPS mode. Begins blinking when RTCM corrections are received and module enters RTK float mode. Goes low when module enters RTK fixed mode and begins outputting cm-level accurate locations.
  • PPS: Pulse-per-second output pin. Begins blinking at 1Hz when module gets basic GPS/GNSS position lock.
  • RST: Reset input pin. Pull this line low to reset the module.
  • SAFE: Safeboot input pin. This is required for firmware updates to the module and generally should not be used or connected.
  • INT: Interrupt input/output pin. Can be configured using U-Center to bring the module out of deep sleep or to output an interrupt for various module states.

Antenna

The NEO-M8P requires a good quality GPS or GNSS (preferred) antenna. A U.FL connector is provided. Note: U.FL connectors are rated for only a few mating cycles (about 30) so we recommend you set it and forget it. A U.FL to SMA cable threaded through the mounting hole provides a robust connection that is also easy to disconnect at the SMA connection if needed. Low-cost magnetic GPS/GNSS antennas can be used (checkout the u-blox white paper) but a 4” / 10cm metal disc is required to be placed under the antenna as a ground plane.

LEDs

The board includes four status LEDs as indicated in the image below.

The power (PWR) LED will illuminate when 3.3V is activated either over USB or via the Qwiic bus.

The pulse per second (PPS) LED will illuminate with each successful update once a position lock has been achieved.

The RTK LED will be illuminated constantly upon power up. Once RTCM data has been successfully received it will begin to blink. This is a good way to see if the NEO-M8P is getting RTCM from various sources.

arduino, lawn, mower, gps-rtk, hookup

The FENCE LED can be configured to turn on/off for geofencing applications.

Jumpers

There are four jumpers located on the back of the board to configure the GPS-RTK.

Closing DSEL enables the SPI interface and disables the UART and I2C interfaces. USB will still function.

Cutting the I2C jumper will remove the 2.2k Ohm resistors from the I2C bus. If you have many devices on your I2C bus you may want to remove these jumpers. Not sure how to cut a jumper? Read here!

Jumpers JP1, JP2, JP3, are provided on the rear of the board to allow isolation of the various status LEDs.

Backup Battery

The MS621FE rechargeable battery maintains the battery backed RAM (BBR) on the NEO-M8P. This allows for much faster position locks. The BBR is also used for module configuration retention. The battery is automatically trickle charged when power is applied and should maintain settings and GNSS orbit data for up to two weeks without power.

Connecting an Antenna

U.FL connectors are very good but they are a designed to be implemented inside a small embedded application like a laptop. Exposing a U.FL connector to the wild risks it getting damaged. To prevent damaging the U.FL connection we recommend threading the U.FL cable through the stand-off hole, then attach the U.FL connectors. This will provide a great stress relief for the antenna connection. Now attach your SMA antenna of choice.

Be Careful! U.FL connectors are easily damaged. Make sure the connectors are aligned, flush face to face (not at an angle), then press down using a rigid blunt edge such as the edge of a PCB or point of a small flat head screwdriver. For more information, check out our tips and tricks on using a u.FL connector.

If you’re indoors you must run an SMA extension cable long enough to locate the antenna where it has a clear view of the sky. That means no trees, buildings, walls, vehicles, or concrete metally things between the antenna and the sky. Be sure to mount the antenna on a 4”/10cm metal ground plate to increase reception.

Connecting the GPS-RTK to a Correction Source

Before you go out into the field it’s good to understand how to get RTCM data and how to pipe it to the GPS-RTK. For this example we will show how to get correction data from the UNAVCO network, pull that data in using RTKLIB, and pipe it down over serial to the GPS-RTK.

Required Materials

  • 1x GPS-RTK
  • 1x L1/L2 GNSS Antenna
  • 1x Metal Plate of 4” or larger
  • 1x SMA extension cable (if needed to get a clear view of the sky)
  • 2x micro-B USB cable
  • 1x Serial Basic
  • A few jumper wires

Required Software

  • Credentials with a free RTCM provider such as UNAVCO
  • U-Center
  • Download and unzip RTKLIB. We will be using 2.4.2.

UNAVCO has fairly good coverage in the USA. Using their interactive map find a station that is near your location. It’s ok if it is more than 10km (6 miles) away, we’re just practicing.

Site P041 is pretty close to SparkFun HQ. We’ll be using it. To access UNAVCO data feeds you will need to send an email to rtgps@unavco.org to request credentials. Let UNAVCO know if you are affiliated with any business, school, or organization and if you are using the account for personal use. Access to UNAVCO is free; I believe they need this information for reporting on their grant funding.

Once you have your UNAVCO credentials open RTKLIB (in Windows run rtklaunch.exe). This small window allows you to launch the various RTK programs. For this tutorial we’ll be using RTKNAVI, the second button from the right.

RTKNAVI allows you to connect to RTCM feeds from various providers, including UNAVCO. Click on the small “I” button.

From the input stream window click the check box next to ‘Base Station’, select NTRIP Client from the dropdown, and the RTCM 3 format. Next click on the small three dots under Opt. this will open the NTRIP client configuration options.

Enter the UNAVCO domain, port, and credentials that you were issued. Next click on the Ntrip. button. This will launch the Ntrip browser so that we can locate the P041 station.

Ntrip browser allows you to connect to different providers and view what streams are available. I wish it was as simple as being able to search for ALL the RTCM streams near a given location but no option currently exists. Instead, we must connect to each provider and see what locations they provide, and what type of correction streams are produced by a given location. Remember, the NEO-M8P only works with RTCM 3.x.

This list is quite large and we’re looking for P041. Click on the Mountpoint column header to sort the list alphabetically.

Once we have P041 located, we want the RTCM feed. Copy and paste that mountpoint back into RTKNAVI into the ‘Mountpoint’ box. Once you’ve entered all your credentials and mountpoint, click OK to close the NTRIP Client Options window. You can also close the Ntrip browser.

The input stream should be configured so click OK in the Input Stream window to complete configuration. Click ‘Start’ from the RTKNAVI window to test the connection to the UNAVCO server.

Success! We are receiving a stream. Now we need to output this data. Click the L button for ‘Logging’.

We want to log the Base Station stream to the serial port so now is a good time to connect your Serial Basic or FTDI board. Once the board enumerates, you should have a new serial port. If you run into problems or need drivers checkout the Serial Basic Hookup Guide.

Click the ‘. ’ button to configure your serial port. Note that you’ll need to select the same baud rate as your GPS-RTK module is configured for. By default, the NEO-M8P communicates at 9600bps 8-N-1, so use this setting. Once you have things configured properly the TX LED on the Serial basic should blink once per second indicating the UNAVCO server is pushing data all the way down to the TX pin on the Serial Basic.

The RTCM pipe is complete. Now we need to connect the last inch to the NEO-M8P.

Time to power up up the GPS-RTK board. Attach a micro-B cable to the GPS-RTK board. The power LED should illuminate. Open the U-Center software from U-blox. Be sure to read Getting Started with U-Center if you haven’t already. Thankfully, the NEO-M8P’s default configuration allows it to receive RTCM correction data without any further changes. All you need to do is feed the NEO-M8P with serial data and it will begin calculating the high precision location solution.

Select the correct COM port and begin viewing the NMEA data. You should have a position lock very quickly. Once the PPS LED begins to blin0,k you are ready to start piping RTCM data to the GPS-RTK board.

The Serial Basic board should still be blinking once a second with RTCM data from the UNAVCO server. Using two jumper wires connect GND on the Serial Basic to GND on the GPS-RTK. Next, connect TXO to the MOSI pin on the GPS-RTK. The MOSI pin is the RX UART pin by default (when DSEL jumper is open). Jumper wires without solder are obviously a precarious setup but we’re just testing things out. Arrange things so the connection is semi-permanent. Within a few seconds you should see the RTK LED begin to blink.

Congratulations! Your GPS module has entered RTK float mode. When the RTK LED turns off completely then the module has solved the carrier ambiguities and entered RTK fixed mode and is outputting centimeter level positions!

Once you have the GPS-RTK receiving RTCM correction data successfully, you can begin planning how to obtain and deliver the RTCM data to the GPS-RTK. The options are vast and varied:

  • It is possible to pull get Ntrip data on an Android app and pipe it over a Bluetooth serial device like the Bluetooth Mate Silver. It’s trivial to connect a Bluetooth serial device to the GPS-RTK serial pins.
  • If you need maximum portability a radio link can be the lowest power, smallest footprint. SparkFun offers a variety of LoRa radios and antennas. With the help of a microcontroller these radios can pipe data from the LoRa backhaul over an Qwiic I2C port, serial, even SPI.
  • If your end application already requires an internet connection such as GSM or LTE-CAT, then a microcontroller could feasibly connect to an Ntrip server over the internet and pipe the RTCM data over a serial or an I2C connection on the GPS-RTK.

SparkFun u-blox Arduino Library

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

The GPS-RTK Arduino library enables the reading of NMEA data over I2C as well as sending binary UBX configuration commands over I2C. This is helpful for configuring advanced modules like the NEO-M8P-2.

The SparkFun u-blox Arduino library can be downloaded with the Arduino library manager by searching ‘SparkFun u-blox GNSS’ or you can grab the zip here from the GitHub repository:

Once you have the library installed checkout the various examples.

  • Example1: Read NMEA sentences over I 2 C using u-blox module SAM-M8Q, NEO-M8P, etc
  • Example2: Parse NMEA sentences using MicroNMEA library. This example also demonstrates how to overwrite the processNMEA function so that you can direct the incoming NMEA characters from the u-blox module to any library, display, radio, etc that you prefer.
  • Example3: Get latitude, longitude, altitude, and satellites in view (SIV). This example also demonstrates how to turn off NMEA messages being sent out of the I 2 C port. You’ll still see NMEA on UART1 and USB, but not on I 2 C. Using only UBX binary messages helps reduce I 2 C traffic and is a much lighter weight protocol.
  • Example4: Displays what type of a fix you have the two most common being none and a full 3D fix. This sketch also shows how to find out if you have an RTK fix and what type (floating vs. fixed).
  • Example5: Shows how to get the current speed, heading, and dilution of precision.
  • Example6: Demonstrates how to increase the output rate from the default 1 per second to many per second; up to 30Hz on some modules!
  • Example7: Older modules like the SAM-M8Q utilize an older protocol (version 18) whereas the newer modules like the ZED-F9P depricate some commands using the latest protocol (version 27). This sketch shows how to query the module to get the protocol version.
  • Example8: u-blox modules use I 2 C address 0x42 but this is configurable via software. This sketch will allow you to change the module’s I 2 C address.
  • Example9: Altitude is not a simple measurement. This sketch shows how to get both the ellipsoid based altitude and the MSL (mean sea level) based altitude readings.
  • Example10: Sometimes you just need to do a hard reset of the hardware. This sketch shows how to set your u-blox module back to factory default settings.
  • NEO-M8P: Examples specific for the NEO-M8P.
  • NEO-M8P Example1: Send UBX binary commands to enable RTCM sentences on U-blox NEO-M8P-2 module. This example is one of the steps required to setup the NEO-M8P as a base station. For more information have a look at the u-blox manual for setting up an RTK link.
  • NEO-M8P Example2: This example extends the previous example sending all the commands to the NEO-M8P-2 to have it operate as a base. Additionally the processRTCM function is exposed. This allows the user to overwrite the function to direct the RTCM bytes to whatever connection the user would like (radio, serial, etc).
  • NEO-M8P Example3: This is the same example as NEO-M8P’s Example2. However, the data is sent to a serial LCD via I 2 C.
  • ZED-F9P Example1: This module is capable of high precision solutions. This sketch shows how to inspect the accuracy of the solution. It’s fun to watch our location accuracy drop into the millimeter scale.
  • ZED-F9P Example2: The ZED-F9P uses a new u-blox configuration system of VALGET/VALSET/VALDEL. This sketch demonstrates the basics of these methods.
  • ZED-F9P Example3: Setting up the ZED-F9P as a base station and outputting RTCM data.
  • ZED-F9P Example4: This is the same example as ZED-F9P’s Example3. However, the data is sent to a serial LCD via I 2 C.

This SparkFun u-blox library really focuses on I 2 C because it’s faster than serial and supports daisy-chaining. The library also uses the UBX protocol because it requires far less overhead than NMEA parsing and does not have the precision limitations that NMEA has.

Setting Up A Base Station

Heads up! This section is a bit out of date. We’ve got a shiny new How to Build a GNSS Reference Station tutorial that provides up to date information. We plan to keep this section for reference.

If you’re located further than 20km from a correction station you can create your own station using the NEO-M8P-2. u-blox provides a great setup guide showing the various settings needed via u-center. We’ll be covering how to setup the GPS-RTK using I2C commands only. This will enable a headless (computerless) configuration of a base station that outputs RTCM correction data. You can watch a brief demo of this in the product video:

Before getting started we recommend you configure the module using u-center. Checkout our tutorial on using U-Center then read the u-blox datasheet on getting the NEO-M8P configured for RTK using U-Center. Once you’ve been successful controlling the module in the comfort of your lab, then consider heading outdoors.

For this exercise we’ll be using the following parts:

  • SparkFun GPS-RTK Board
  • SparkFun BlackBoard makes I2C easy
  • microB Cable if you need one
  • Antenna L1/L2 GNSS 3-5V Magnetic Mount
  • GPS Antenna Ground Plate
  • U.FL to SMA Cable
  • Two Qwiic Cables
  • 20×4 SerLCD with Qwiic Adapter soldered on
  • 1x 20ft SMA extension can be handy when first experimenting with base stations so you can sit indoors with a laptop and analyze the output of the GPS-RTK
  • A standard camera tripod

The NEO-M8P-2 can be configured using Serial, SPI, or I2C. We’re fans of the daisychain-ability of I2C so we’ll be focusing on the Qwiic system. For this exercise we’ll be connecting the an LCD and GPS-RTK to a BlackBoard using two Qwiic cables.

For the antenna, you’ll need a clear view of the sky. The better your antenna position the better your accuracy and performance of the system. We designed the GPS Antenna Ground Plate to make this setup easy. The plate has a ¼” threaded hole that threads directly onto a camera tripod. The plate thickness was chosen to be thick enough so that the threaded screw is flush with the plate so it won’t interfere with the antenna. Not sure why we’re using a ground plate? Read the u-blox white paper on using low-cost GNSS antennas with RTK. Mount your magnetic mount antenna and run the SMA cable to the U.FL to SMA cable to the GPS-RTK board.

There are only three steps to initiating a base station:

  • Enable Survey-In mode for 5 minutes (300 seconds)
  • Enable RTCM output messages
  • Begin transmitting the RTCM packets over the backhaul of choice

Be sure to grab the SparkFun u-blox GNSS Arduino Library. You can easily install this via the library manager by searching ‘SparkFun u-blox GNSS’. Once installed click on File-Examples-SparkFun_u-blox_GNSS_Arduino_Library.

The NEO-M8P subfolder houses a handful of sketches specific to its setup. Example3 demonstrates how to send the various commands to the GPS-RTK to enable Survey-In mode. Let’s discuss the important bits of code.

language:c response = myGNSS.enableSurveyMode(300, 2.000); //Enable Survey in, 300 seconds, 2.0m

The library is capable of sending UBX binary commands with all necessary headers, packet length, and CRC bytes over I2C. The enableSurveyMode(minimumTime, minimumRadius) command does all the hard work to tell the module to go into survey mode. The module will begin to record lock data and calculate a 3D standard deviation. The survey-in process ends when both the minimum time and minimum radius are achieved. u-blox recommends 300 seconds (5 minutes) and a radius of 2m. With a clear view of the sky, with a low cost GNSS antenna mounted to a ground plate we’ve seen the survey complete at 301 seconds with a radius of around 1.5m.

language:c response = myGNSS.enableRTCMmessage(UBX_RTCM_1005, UBX_RTCM_I2C_PORT, 1); //Enable message 1005 to output through I2C port, message every second response = myGNSS.enableRTCMmessage(UBX_RTCM_1077, UBX_RTCM_I2C_PORT, 1); response = myGNSS.enableRTCMmessage(UBX_RTCM_1087, UBX_RTCM_I2C_PORT, 1); response = myGNSS.enableRTCMmessage(UBX_RTCM_1230, UBX_RTCM_I2C_PORT, 10); //Enable message every 10 seconds

These four lines enable the four RTCM output messages needed for a second GPS-RTK to receive correction data. Once these sentences have been enabled (and assuming a survey process is complete) the GPS-RTK base module will begin outputting RTCM data every second after the NMEA sentences (the RTCM_1230 sentence will be output once every 10 seconds). You can view an example of what this output looks like here.

The size of the RTCM correction data varies but in general it is approximately 350 bytes every second (~500 bytes every 10th second when 1230 is transmitted).

language:c //This function gets called from the SparkFun u-blox GNSS 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_GNSS::processRTCM(uint8_t incoming) //Let’s just pretty-print the HEX values for now if (myGNSS.rtcmFrameCounter % 16 0) Serial.println; Serial.print( ); if (incoming

If you have a ‘rover’ in the field in need of correction data you’ll need to get the RTCM bytes to the rover. The SparkFun u-blox library automatically detects the difference between NMEA sentences and RTCM data. The processRTCM function allows you to ‘pipe’ just the RTCM correction data to the channel of your choice. Once the base station has completed the survey and has the RTCM messages enabled, your custom processRTCM function can pass each byte to any number of channels:

  • A wireless system such as LoRa or Cellular
  • Posting the bytes over the internet using Wi-Fi or wired ethernet over an Ntrip caster
  • Over a wired solution such as RS485

The power of the processRTCM function is that it doesn’t care; it presents the user with the incoming byte and is agnostic about the back channel.

Heads up! We’ve been experimenting with various LoRa solutions and the bandwidth needed for RTCM (~500 bytes per second) is right at the usable byte limit for many LoRa setups. It’s possible but you may need to adjust your LoRa settings to reach the throughput necessary for RTK.

What about configuring the rover? u-blox designed the NEO-M8P to automatically go into RTK mode once RTCM data is detected on any of the ports. Simply push the RTCM bytes from your back channel into one of the ports (UART, SPI, I2C) on the rover’s GPS-RTK and the location accuracy will go from meters to centimeters. The rover’s NMEA messages will contain the improved Lat/Long data and you’ll know where you are with mind-bending accuracy. It’s a lot of fun to watch!

NMEA and RTK

Can I Really Use NMEA with a High Precision GPS Receiver?

Yes! Except that NMEA sentences are right on the edge of enough precision. NMEA sentences look something like this:

language:bash GNGGA,012911.00,4003.19080,N,10416.95542,W,1,12,0.75,1647.1,M,-21.3,M,,4F

NMEA outputs coordinates in the ddmm.mmmmm format. So what is the weight of the least significant digit? Said differently, what is the impact of one digit change?

If we know 1 degree of latitude is 111.3km at the equator, we can glean the change of a fraction of a minute:

  • 1 degree = 60 minutes
  • 1 minute = 1 degree/60 = 111.32km / 60 = 1.855km
  • 1 minute = 1855m
  • 0.1min = 185.5m
  • 0.01min = 18.55m
  • 0.001min = 1.855m
  • 0.0001min =.1855m = 185.5mm
  • 0.00001min = 0.0185m = 18.55mm = 1.855cm

Using the NMEA sentence, the NEO-M8P will only be able to communicate a change of ~1.5cm location change for each digit in the 5th position. This is pretty close to the 2.5cm accuracy of the module. If you want additional precision, you should consider using the UBX protocol which can output up to 8 digits of precision in dd.dddddddd format which will get you down to 1.11mm of precision!

Ready to get hands-on with GPS?

We’ve got a page just for you! We’ll walk you through the basics of how GPS works, the hardware needed, and project tutorials to get you started.

Have fun with your new found super power: sub decimeter grade GPS!

For more on the GPS-RTK, check out the links below:

  • Schematic (PDF)
  • Eagle Files (ZIP)
  • Example RTCM output from the NEO-M8P-2
  • NEO-M8P-2 Datasheet (PDF)
  • Using U-Center to configure the NEO-M8P for base station RTCM output
  • NEO-M8P Hardware Integration Manual (PDF)
  • NEO-M8P Product Summary (PDF)
  • u-blox M8 Series Protocol
  • U-blox ECCN notice
  • GitHub
  • Arduino Library
  • Product Repo

Need some inspiration? Check out some of these related tutorials:

Building an Autonomous Vehicle: The Batmobile

Documenting a six-month project to race autonomous Power Wheels at the SparkFun Autonomous Vehicle Competition (AVC) in 2016.

arduino, lawn, mower, gps-rtk, hookup