The first article in this two-part series, Understanding and Implementing the HC-12 Wireless Transceiver Module, uses the HC-12 to create long-distance data transmission between two Arduino Unos. This article uses a pair of HC-12 transceivers, a GPS module, an Arduino, and Google Maps to create a very simple tracking device.
HC-12 transceiver (x2)$4Datasheet GPS Receiver$16Datasheet
or Adafruit GPS Logger Shield$45Project Guide Arduino Uno R3 (or compatible)$45Reference

Part one of this two-part series discussed the HC-12 transceiver module and described how to hook it up to an Arduino and a power source.

In this article, we will create a remote GPS receiver that can be used to track nearby items without using a cellular network.

For further information on the transceiver module, please see the HC-12 datasheet (PDF).

The Global Positioning System (GPS) allows users to accurately determine the location of objects on or above the surface of the Earth. Both of the GPS receivers listed at the top of this article transmit National Marine Electronics Association (NMEA) sentences that provide information that includes latitude and longitude, altitude, time, bearing, speed, and a great many other variables at 9600 baud.

The HC-12s can transmit the information from a GPS receiver with no additional programming or circuitry.

You can transmit GPS coordinates to remote locations with as little as a GPS receiver, an HC-12 transceiver, and a battery. Remotely transmitted coordinates would have to be received by another HC-12 transceiver and then processed with a microcontroller or computer.

A simple setup such as the one above would allow you to create a small remote object tracker; it will alert you if the object leaves a predefined area, and then you will have a certain amount of time to track the object before the transmitter goes out of range. You could use this with a vehicle, a pet, or even—if you are concerned about theft—the giant pumpkin that you are growing for the state fair.

If you are in an area with clear line of sight, the transmitters will broadcast up to one kilometer, which is a 15-minute walk (or 5-minute run). The maximum range in urban areas will decrease but should remain adequate to alert you if your luggage is leaving the train station without you, or let you know where your dog ventures when he escapes from your yard.

We can refine this project by passing the GPS data to an Arduino instead of directly to the HC-12. Then, only selected strings can be transmitted to the HC-12. This is useful if you want to increase the range of the HC-12 communication by decreasing the over-the-air baud rate.

The $16 SparkFun GPS module has a default transmission rate of 9600 baud, and this corresponds to an over-the-air rate of 15000 baud. Sending the 9600 baud GPS data to the Arduino and then transmitting only selected information to the HC-12 at 2400 baud will reduce the over-the-air rate to 5000 baud. According to the datasheet, this improves receiver sensitivity by at most 5 dB, which provides a modest increase in range. The SparkFun GPS receiver provides six sentences at 9600 baud: GPRMCGPVTGGPGGAGPGSAGPGSV, and GPGLL. The GPS shield from Adafruit, which is significantly more expensive, can be programmed to transmit select sentences at all standard baud rates. This is an example data transmission from the receiver to an Arduino. You can decode your own strings with this online tool.$GPRMC,210154.00,A,3358.88969,N,11756.33387,W,0.824,,200916,,,A*6F
$GPVTG,,T,,M,0.824,N,1.527,K,A*2C$GPGGA,210154.00,3358.88969,N,11756.33387,W,1,05,1.67,254.3,M,-32.6,M,,*6E
$GPGSA,A,3,13,05,21,18,29,,,,,,,,3.15,1.67,2.66*01$GPGSV,3,1,11,05,20,044,23,10,10,223,,13,26,083,22,15,37,120,*70
$GPGSV,3,2,11,16,11,322,,18,45,224,23,20,76,043,,21,55,312,22*76$GPGSV,3,3,11,25,23,195,17,26,27,298,,29,72,108,17*47
$GPGLL,3358.88969,N,11756.33387,W,210154.00,A,A*74 Arduino libraries exist that enable decoding of NMEA sentences into the latitude & longitude pairs below: TypeUTC TimePositionSpeedAltitudeHDOP, VDOP, PDOPSatellites RMC2016-09-20T21:01:54Z 33°58'53.38''N, 117°56'20.03''W0.824 knots VTG0.824 knots GGA2016-09-20T21:01:54Z 33°58'53.38''N, 117°56'20.03''W254.35 GSA1.67, 2.66, 3.155 GSV11 GSV11 GSV11 GLL2016-09-20T21:01:54Z 33°58'53.38''N, 117°56'20.03''W RMC (recommended minimum information), GGA (3D location and accuracy), and GLL (latitude and longitude) all include latitude, longitude, and time. GGA provides altitude, and GSA provides the dilution of precision of the reading (lower numbers indicate greater precision). The following program is backward-compatible with the two programs presented in part one. It reads the NMEA sentences sent by the GPS to the Arduino, discards all but the selected sentence, and transmits the selected sentence to a remote Arduino when requested. It works with either the SparkFun GPS receiver or the Adafruit GPS logger shield, as shown below. This program allows users to remotely "ping" distant transceivers to determine their location. ##### GPS data from a remote transmitter received, via a pair of HC-12 transceivers, by a local Arduino ##### HC-12 transceiver paired with an Adafruit GPS shield ##### HC-12 transceiver paired with a SparkFun GPS module Connect the power supply, GPS, Arduino, and HC-12 as shown above. The SparkFun GPS receiver has only three wires; the fourth signal (GPS RXD) is not needed for basic functionality and is not made available to the user. However, if you use the Adafruit shield, the GPS RX pin is enabled, and you can change the refresh rate and which sentences the GPS transmits, eliminating the need for the portion of the Arduino code at the end of the file that simply deletes unwanted sentences. One potential problem with using the Arduino UNO for this program is that the SoftwareSerial library can only "listen" to one serial port at a time—data sent to a serial port when the software isn't "listening" on that port will be discarded. The program functions as intended during testing, but I would not consider it a robust solution. If you need multiple serial communication ports in your project, consider the Arduino Mega, or a separate chip such as the ATSAMD21. If you are tracking a single object near your house, it is sufficient to set upper and lower limits for expected latitude and longitude values. If you are trying to determine the distance between two GPS units, you might consider implementing Vincenty's formula on a 16-bit or 32-bit microcontroller  /* HC12 Send/Receive Example Program 3 By Mark J. Hughes for AllAboutCircuits.com This code will automatically detect commands as sentences that begin with AT and both write them and broadcast them to remote receivers when requested. Changing settings on a local transceiver will also change settings on a remote receiver. Connect HC12 "RXD" pin to Arduino Digital Pin 4 Connect HC12 "TXD" pin to Arduino Digital Pin 5 Connect HC12 "Set" pin to Arduino Digital Pin 6 Connect GPS GND and 3.3V to Arduino or separate supply Connect GPS "RX" to Arduino Digital Pin 7 (optional) Connect GPS "TX" to Arduino Digital Pin 8 Do not power over USB. Per datasheet, power the HC12 with a supply of at least 100 mA current capability, and include a 22 uF - 1000 uF reservoir capacitor. Upload code to two Arduinos connected to two computers. Transceivers must be at least several meters apart to work in default mode. */ #include <SoftwareSerial.h> //--- Begin Pin Declarations ---// const byte HC12RxdPin = 4; // "RXD" Pin on HC12 const byte HC12TxdPin = 5; // "TXD" Pin on HC12 const byte HC12SetPin = 6; // "SET" Pin on HC12 const byte GPSRxdPin = 7; // "RXD" on GPS (if available) const byte GPSTxdPin = 8; // "TXD" on GPS //--- End Pin Declarations ---// //--- Begin variable declarations ---// char byteIn; // Temporary variable String HC12ReadBuffer = ""; // Read/Write Buffer 1 -- Serial String SerialReadBuffer = ""; // Read/Write Buffer 2 -- HC12 String GPSReadBuffer = ""; // Read/Write Buffer 3 -- GPS boolean serialEnd = false; // Flag for End of Serial String boolean HC12End = false; // Flag for End of HC12 String boolean GPSEnd = false; // Flag for End of GPS String boolean commandMode = false; // Send AT commands to remote receivers boolean GPSLocal = true; // send GPS local or remote flag //--- End variable declarations ---// // Create Software Serial Ports for HC12 & GPS // Software Serial ports Rx and Tx are opposite the HC12 Rxd and Txd SoftwareSerial HC12(HC12TxdPin, HC12RxdPin); SoftwareSerial GPS(GPSTxdPin, GPSRxdPin); void setup() { HC12ReadBuffer.reserve(82); // Reserve 82 bytes for message SerialReadBuffer.reserve(82); // Reserve 82 bytes for message GPSReadBuffer.reserve(82); // Reserve 82 bytes for longest NMEA sentence pinMode(HC12SetPin, OUTPUT); // Output High for Transparent / Low for Command digitalWrite(HC12SetPin, HIGH); // Enter Transparent mode delay(80); // 80 ms delay before operation per datasheet Serial.begin(9600); // Open serial port to computer at 9600 Baud HC12.begin(9600); // Open software serial port to HC12 at 9600 Baud GPS.begin(9600); // Open software serial port to GPS at 9600 Baud HC12.listen(); // Listen to HC12 } void loop() { while (HC12.available()) { // If Arduino's HC12 rx buffer has data byteIn = HC12.read(); // Store each character in byteIn HC12ReadBuffer += char(byteIn); // Write each character of byteIn to HC12ReadBuffer if (byteIn == '\n') { // At the end of the line HC12End = true; // Set HC12End flag to true. } } while (Serial.available()) { // If Arduino's computer rx buffer has data byteIn = Serial.read(); // Store each character in byteIn SerialReadBuffer += char(byteIn); // Write each character of byteIn to SerialReadBuffer if (byteIn == '\n') { // At the end of the line serialEnd = true; // Set serialEnd flag to true. } } while (GPS.available()) { byteIn = GPS.read(); GPSReadBuffer += char(byteIn); if (byteIn == '\n') { GPSEnd = true; } } if (serialEnd) { // Check to see if serialEnd flag is true if (SerialReadBuffer.startsWith("AT")) { // Check to see if a command has been sent if (SerialReadBuffer.startsWith("AT+B")) { // If it is a baud change command, delete it immediately SerialReadBuffer = ""; Serial.print("Denied: Changing HC12 Baud does not change Arduino Baudrate"); } HC12.print(SerialReadBuffer); // Send local command to remote HC12 before changing settings delay(100); // digitalWrite(HC12SetPin, LOW); // If true, enter command mode delay(100); // Delay before writing command HC12.print(SerialReadBuffer); // Send command to HC12 Serial.print(SerialReadBuffer); // Send command to serial delay(500); // Wait 0.5s for reply digitalWrite(HC12SetPin, HIGH); // Exit command / enter transparent mode delay(100); // Delay before proceeding } if (SerialReadBuffer.startsWith("GPS")) { HC12.print(SerialReadBuffer); GPS.listen(); GPSLocal = true; } HC12.print(SerialReadBuffer); // Send text to HC12 to be broadcast SerialReadBuffer = ""; // Clear buffer 2 serialEnd = false; // Reset serialEnd flag } if (HC12End) { // If HC12End flag is true if (HC12ReadBuffer.startsWith("AT")) { // Check to see if a command was received digitalWrite(HC12SetPin, LOW); // If true, enter command mode delay(40); // Delay before writing command HC12.print(HC12ReadBuffer); // Send incoming command back to HC12 Serial.println(HC12ReadBuffer); // Send command to serial delay(1000); // Wait 0.5s for reply digitalWrite(HC12SetPin, HIGH); // Exit command / enter transparent mode delay(80); // Delay before proceeding HC12.println("Remote Command Executed"); } if (HC12ReadBuffer.startsWith("GPS")) { GPS.listen(); HC12.print("Remote GPS Command Received"); GPSLocal = false; } Serial.print(HC12ReadBuffer); // Send message to screen HC12ReadBuffer = ""; // Empty Buffer HC12End = false; // Reset Flag } if (GPSEnd) { // Options include GPRMC, GPGGA, GPGLL, etc... if (GPSReadBuffer.startsWith("$GPGGA")) {       // Look for target GPS sentence
if (GPSLocal) {
Serial.print("Local  GPS:");                // Send to local serial port
} else {
HC12.print("Remote GPS:");                  // Local Arduino responds to remote request
HC12.print(GPSReadBuffer);                  // Sends local GPS to remote
}
GPSReadBuffer = "";                           // Delete target GPS sentence
HC12.listen();                                // Found target GPS sentence, start listening to HC12 again
} else {
GPSReadBuffer = "";                           // Delete unwanted strings
}
GPSEnd = false;                                 // Reset GPS
}
}


Data that you collect can be converted into KML files for use in Google Maps using one of many free online converters.

The above image shows variations in the logged GPS coordinates of a stationary object. The error is rather large, even for the low-cost setup used in this project—the GPS receiver sold by SparkFun, for example, claims to provide positional accuracy of 2.5 m CEP. It is likely that multipath interference made a significant contribution to the additional error.

### Real-Time GPS Tracking in Google Earth

Now we will create a GPS tracker with the HC-12 and Google Earth Pro. Through experimentation, I found that tracking worked if at least the $GPGGA,$GPGSA, and $GPGLL strings were passed along to Google Earth. The program below transmits GPS data to a remote receiver for tracking of remote objects. It receives all sentences at 9600 baud from the computer and then transmits just the$GPRMC, $GPGGA, and$GPGGL sentences at 4800 baud through the HC-12. A separate HC-12/Arduino pair would be needed to receive the information and transmit it to the computer.

                    /*  HC12 Send/Receive Example Program 4
By Mark J. Hughes

Connect HC12 "RXD" pin to Arduino Digital Pin 4
Connect HC12 "TXD" pin to Arduino Digital Pin 5
Connect HC12 "Set" pin to Arduino Digital Pin 6

Connect GPS "TXD" to Arduino Digital Pin 7 (Optional)
Connect GPS "RXD" to Arduino Digital Pin 8

Do not power over USB.  Per datasheet, power the HC12
with a supply of at least 100 mA current capability, and
include a 22 uF - 1000 uF reservoir capacitor.

Upload code to two Arduinos connected to two computers.

Transceivers must be at least several meters apart to work in default mode.

*/

#include &let;SoftwareSerial.h>

//--- Begin Pin Declarations ---//
const byte HC12RxdPin = 4;                // "RXD" Pin on HC12
const byte HC12TxdPin = 5;                // "TXD" Pin on HC12
const byte HC12SetPin = 6;                // "SET" Pin on HC12
const byte  GPSTxdPin = 7;                // "TXD" on GPS (if available)
const byte  GPSRxdPin = 8;                // "RXD" on GPS
//--- End Pin Declarations ---//

//--- Begin variable declarations ---//
char GPSbyteIn;                              // Temporary variable
String GPSBuffer3 = "";                      // Read/Write Buffer 3 -- GPS

boolean debug = false;
boolean HC12End = false;                  // Flag for End of HC12 String
boolean GPSEnd = false;                   // Flag for End of GPS String
boolean commandMode = false;              // Send AT commands to remote receivers
//--- End variable declarations ---//

// Create Software Serial Ports for HC12 & GPS
// Software Serial ports Rx and Tx are opposite the HC12 Rxd and Txd
SoftwareSerial HC12(HC12TxdPin, HC12RxdPin);
SoftwareSerial GPS(GPSRxdPin, GPSTxdPin);

void setup() {
buffer3.reserve(82);                    // Reserve 82 bytes for longest NMEA sentence

pinMode(HC12SetPin, OUTPUT);            // Output High for Transparent / Low for Command
digitalWrite(HC12SetPin, HIGH);         // Enter Transparent mode
delay(80);                              // 80 ms delay before operation per datasheet
HC12.begin(4800);                       // Open software serial port to HC12
GPS.begin(9600);                        // Open software serial port to GPS
GPS.listen();
}

void loop() {
while (GPS.available()) {
buffer3 += char(byteIn);
if (byteIn == '\n') {
GPSEnd = true;
}
}

if (GPSEnd) {
// GPRMC, GPVTG, GPGGA, GPGSA, GPGSV, GPGLL
if (buffer3.startsWith("$GPRMC")||buffer3.startsWith("$GPGGA")||buffer3.startsWith("$GPGLL")) { HC12.print(buffer3); // Transmit RMC, GGA, and GLL sentences buffer3 = ""; // Clear buffer } else { buffer3 = ""; // Delete GSA, GSV, VTG sentences } GPSEnd = false; // Reset GPS flag } }  Here are the steps you'll need to follow: 1. Open Google Earth 2. Select Tools -> GPS 3. Select the Realtime tab and click Start. Google Earth will cycle through available serial ports looking for NMEA sentences. When NMEA data is found, it will provide a location on the map. ##### Three separate screenshots were combined in order to show all the steps simultaneously Note: An Arduino (or any other microcontroller) is not strictly required for this to work. A GPS module (such as the Adafruit logger shield) that can be programmed to transmit the desired sentences at 4800 baud can be connected directly to an HC-12. Data can then be sent to Google Earth using a separate HC-12 that is connected to a computer's serial port via a logic-level-to-RS232 converter. ### Conclusion This two-article series demonstrates that the HC-12 is a versatile and easy-to-use RF transceiver module. It is similar to the nRF24L01, but it offers the important advantage of longer range. The straightforward UART interface facilitates integration into a wide variety of systems—microcontrollers and PCs can directly communicate with the HC-12. As this article has shown, the HC-12 is a simple solution for logging GPS data and for real-time GPS tracking. Featured image courtesy of SpaceX. Give this project a try for yourself! Get the BOM. #### Learn More About: ### Comments #### 50 CommentsLogin • Darius Petrulis 2016-11-21 Nice project, to use this GPS tracker for almost unlimited distance you need to replace HC-12 transceiver to GSM module e.g.SIM800, just need some code changes • Mark Hughes 2016-11-25 Hello Darius, That is true—however, the purpose of parts one and two of this series were to use a serial transceiver for communication. Also, using a cellular device would incur a fee—these are free after purchase. Thanks—and consider registering an account with us and joining the community. Mark • ronsoy2 2016-11-25 Very cute project! Thing to keep in mind is that it REQUIRES a proper number of satellites be received during the measurement period. The horrible accuracy shown above possibly is because not enough satellites were being picked up at the time. This is seriously affected by GPS antenna module orientation and overhead obstruction. • Mark Hughes 2016-11-25 That’s entirely possible. I live in a relatively steep canyon that limits my view of the sky, although I can usually get at least four satellites. I also suspect multipath signal propagation errors—signals bouncing off of things on the canyon walls or the houses on the ridgeline, adding that much more length to the signal path. • Kilili 2016-11-25 The 4 links below are bogus: HC-12 Getting Started HC-12 Sending Remote Commands Realtime TrackGPS GPS Transmit Location • tania123 2017-06-23 Hi, can I use a Bluetooth Hc-06 instead? thank you • Mark Hughes 2017-06-23 The HC-06 has enough similar features that you should be able to get it to work—but the range will be a fraction of what the HC-12 is capable of. (The range of the HC-12 is 1000 m, the HC-06 will be between 1 m - 10m) • giachou_s 2017-09-03 great article plz some question.can i use one hc 12 rxd with multiple rxds? to make it work i will only need hc12-battery-gps module? do i need to conect external ant to get 1km range? thx! • Mark Hughes 2017-09-03 Hi @giachou_s, Yes, you can use a single transmitter with multiple receivers without any issue. And yes, for the maximum range you need an external antenna (the higher off the ground the better). Mark • giachou_s 2017-09-04 sorry Mark i belive i AM total wrong about my question.i want to make multiple transmitters to go in one receiver.can the one handle about 7 trasmitters? thx again for your time • Mark Hughes 2017-09-04 Hi @giachou_s, Yes, that will work too. However, you need to ensure that only one is transmitting at a time. Depending on what you’re doing you might be able to accomplish this by sequentially transmitting according to a time-table—one transmitter every second. If (Mod[seconds, 7]==n) then transmit, where n=(1,2,3,4,5,6,7), one for each transmitter. Good luck. Mark • Amit Yungerman 2017-10-07 I would like to ask what adaptations I would have to do in order to use other common cheap generic modules of GPS ? Thanks in advance. • Mark Hughes 2017-10-07 Which module did you have in mind? • Amit Yungerman 2017-10-20 Sorry about the delay! not sure , prefer something that will be compatible to your tutorial but a generic one from the ebay which will be cheaper! • Mark Hughes 2017-10-20 @Amit Yungerman, My best guess is that you can get that working with the sketch. I mean for$6, you almost have to try it.

• Amit Yungerman 2017-10-25

Thank’s man!

• SpearlikeTag2 2017-10-16

Hello, I tried to use Example Program 3 with an Arduino 101, but it seems to not be transmitting and whenever I type a command, such as “AT+RX”, nothing appears on the serial monitor. However, from example program 2 on your previous article “Understanding and Implementing the HC-12,” I was able to transmit successfully with 2 HC-12 transceivers and was able to send commands. For example, when I sent “AT+RX” using Example Program 2, I got this back on the serial monitor:
AT+RX
OK+B9600
OK+RC001
OK+RP:+20dBm
OK+FU3
Remote Command Executed

• Mark Hughes 2017-10-16

Hi @SpearlikeTag2,
Let me preface my answer by saying I’ve never seen or used a 101, and up until your post, I wasn’t aware that they existed—so I might not be able to satisfactorily answer your question.

Example 3 attempts to integrate the GPS into the sketch by creating a second software based UART port for the GPS.  Since that sketch was written, the 101 was released and it appears to handle UART communication differently.  Perhaps it requires you to create separate classes for the two ports, I’m not entirely certain.
I would recommend the following steps.
1)  Use an oscilloscope to ensure that the GPS is transmitting data to the Arduino 101 and it is at the proper voltage level.  If the voltage levels of the serial data appear too low, you can try a strong pull up resistor.
2)  Read the documentation for the 101.  It’s possible that not all of the pins are compatible (e.g. you cannot receive on pin 4, but you can on pin 0).  It’s also possible that there are different programming techniques for the 101, and the libraries might have changed—commands I used for the Uno with an older compiler might not work on the 101 and the new compiler.
3)  Forget about the GPS and the HC12 for a moment and focus on establishing two UART channels—find an Arduino 101 forum and sketch that implements two additional UARTs (Your computer is one, the HC12 is two, and the GPS is three).  You can use your computer for the primary, program your second 101 to output a sting of text (that’s two), and use the GPS as three.  If you can get strings two and three into your serial monitor (one), then you at least know it is possible with your hardware.

Sorry, I can’t be of more help.  Consider starting a forum topic and asking our community—I’m sure we have 101 users out there.

Good luck,
Mark

• Dzikra Amri 2017-11-26

HOW trying to determine the distance between two GPS units

• FauxFenix 2017-12-17

Okay, I am completely new to arduino and these things but would I be wrong to think that there would be a way to use something from a gps unit (the kind that gives you directions, not the gps on a smartphone) to get more range for this project?

• Mark Hughes 2017-12-17

@FauxFenix,
The range of this project is limited by the HC12, not the GPS unit used..
Mark

• Agir 2017-12-30

Hi,
Thanks for the information. This is a great project. I fly hang gliders and often cover distances of over 100kms from launch. The areas I fly often have no or weak GSM signals so communication between the car and hang glider is best done through a two way radio. I carry a UHF radio that can easily transmit over 100kms as we have a clear line of sight in the flat-lands where I fly. I would like to link my UHF radio to a GPS tracker to send a radio signal back to a base station that could interpret the signal and convert it to a position on Google maps for my wife to find me. Is this possible? And if so, do you know how to make such a device/s?

• Mark Hughes 2017-12-31

Good luck,
Mark

• paulkotis 2018-02-28

Hi Mark,  Thanks for the details.

When the GPS is transmitted can I receive it on my cell phone/tablet or it has to be a HC 12 at the other end?

• Mark Hughes 2018-02-28

Hi @paulkotis,
HC12s can only communicate with other HC12s. It should be possible to use an IC such as Texas Instruments CC2640 (Bluetooth LE) to act as an intermediary between your HC12 and the cell phone, but at that point, it might just make sense to hook the GPS up to the CC2640 and do away with the HC12 altogether.
Hope this helps.
Mark

• Riaz Sulaimi 2018-04-20

Hi bro!,  This is an awesome project. Are there any schematics/fritzing diagram for the hooking up of HC12 with the gps logger? Thanks!

• Mark Hughes 2018-04-21

Hi @Riaz Sulaimi,
I’m glad that you enjoyed the project.  The two pictures with the orange-colored rounded-rectangles and numbers are the hookup diagram/schematic.  There is no fritzing diagram perse, but if you buy the shield, it’ll plug directly into the arduino and solve half of your problems.  It’s only an additional four or five wires to add the HC12, so it shouldn’t be too difficult a task.  If you need help, please post in our forums and ping me and I’ll try to jump in to help out.

• Riaz Sulaimi 2018-05-13

Thanks much bro! will give it a try!

• Riaz Sulaimi 2018-05-13

Sorry for noob qustions but if i use adafruit gps shield do i still need the capacitors because in the picture i saw that you have added some capacitors to the setup for the gps shield. Actually its the capacitor connection that i am not too sure about. Thanks!

• Mark Hughes 2018-05-13

Riaz,
The only way to tell for sure is by using an oscilloscope to track the voltage while the device is operating under a variety of situations.  Sometimes you can get away without them, and sometimes not using one will instantly and permanently damage your component.  It’s not going to hurt anything, and it can certainly help mitigate any transient voltage drops during transmission of the HC12.
In general, any recommendations that come from a datasheet should be followed strictly.
Just to be clear—the reservoir cap is for the HC12, not the GPS.  Using the GPS shield or the standalone GPS shouldn’t make a difference.
Best,
Mark

• Riaz Sulaimi 2018-05-13

Hi Mark,
I just re-read everything and saw your Part1 and read that as well and I think i have figured it out and will give it a try. Sorry for the trouble and many posts. Thanks!

• sjp187 2018-05-18

Hi Mark,
This is a really neat little project, and thank you for still engaging with people’s questions on it (including mine, I hope!). I’ve followed your initial guide on connecting two HC12s to send messages back and forwards, and completed that no issues.

I’m now trying this set up, where one unit has the Arduino, GPS shield, and HC12, and the receiver is just an Arduino and HC12. I’ve checked the GPS shield in standalone mode and it works (as in I can see full NMEA sequences coming through on Port Monitor), but as soon as I upload your code to make it transmit via the HC12, it runs maybe a line and a half of NMEA code (visible on the Port Monitor) before stopping, and nothing at all is received by the other HC12.

Have you any suggestions as to what I may be able to try to debug it? Thanks very much!

• Mark Hughes 2018-05-19

Hi @sjp187,
Thanks for joining the site.  You sure you don’t want to start with an easier question?  That’s a tough one!
First—this is probably going to require a bit of back-and-forth, and I’d love to get some other site expert’s opinions as well.  Could you start a forum post in https://forum.allaboutcircuits.com/ and ping me (use the @ followed by username).
I wonder if you’re experiencing a power-related problem?  Perhaps the reservoir capacitor wired to the HC12 is not of sufficient capacity?  And just to confirm—you saw the warnings to not power the Arduino over USB alone—you need an external power supply.  Any chance you have an oscilloscope, or at least a multimeter that you can put on the HC12’s power pins to see if the voltage is dropping?  It’s possible that your computer is seeing a power surge over the USB port and shutting down/resetting the port.
Hope this helps—see you in the forums!
Mark

• D Rieger 2018-05-19

New to this site. What would be needed to transmit just the speed and be able to read it without a computer hooked up. I sail remote control sail boats and would like to see the speed changes when I sheet in the sails
Thanks
Doug

• Mark Hughes 2018-05-19

Hi @D Rieger,
Welcome to the site!  Yes—that is absolutely possible, and not too difficult to do.  However, we’ll need to discuss it in a forum-post—as it will involve code and a few back and forth exchanges.  See you in the forums http://forum.allaboutcircuits.com

• knete 2018-05-25

Hi Mark,
thank you very much for the detailed project description.
I was just wondering if it is possible to use the HC-12 to set up a simple mesh network to forward messages and extend the range. Ok, I know it is possible, but the question is how.
Do you have any references or sites where I can get started?
My idea is to set up multiple nodes on an area to track a device with HC-12+Arduino+GPS from another mobile device with the same configuration.
Marc

• Mark Hughes 2018-05-25

Hi Marc @knete,
This really can become something of a complicated issue.  I’d recommend posting this comment in our forums to see what others have to say.
When you create your post—can you explain a bit more about your project?  Are you just tracking one target?  Is the receiver always centrally located?  What is the overall area of coverage you need?

You might be able to create a simple repeater network that blends two HC12s (on different channels) with a power supply (No Arduino—Rx of one to Tx of another).
Create a forum post and then ping me with the @ symbol and I’ll see if I can’t help you get started.
Best,
Mark

• Riaz Sulaimi 2018-07-04

Hi Mark,

This has been one awesome project that my primary school students are trying out. So far they have managed to get everything to work except for the real time tracking with Google Earth Pro. If they were to collect the NMEA data from the serial monitor and save it to a kml file, the movement of the tracker shows up nicely. However trying out using realtime via google earth, the usb and com port gets detected but no data is showing up.

Any ideas why such an error occurs?  They have been doing some research and were wondering if it has anything to do with the carriage return and new line at end of each nmea line?

Thanks!

Riaz

• Craig Peterson 2018-08-20

Is it also able to do the reverse and transmit a GPS signal to an Android or Iphone using Google Maps or Pokemon Go any other maps to trick the device into thinking it is someplace else?

• Mark Hughes 2018-08-20

Hi Craig,
Sorry—no.  You’d have to integrate a bluetooth transceiver for that to work.

• volthauslab 2018-09-22

The Links in the above article are links to zipped files so if you them right click the link and then select “save as” to download the files.
The HC-12 Getting Started
HC-12 Sending Remote Commands
Realtime TrackGPS
GPS Transmit Location

• sgoemans 2018-10-27

I went through all your examples and I’ve learned a lot. Thank you.
Your last sketch (Example Program 4) seems to have a few bugs, though:
1) #include &let;SoftwareSerial.h>
2) GPSbyteIn and GPSBuffer3 not defined
3) The comment “Connect GPS “RXD” to Arduino Digital Pin 8” must change to “TXD”.

• GiorgosK 2018-12-15

Hi Mark. Sorry for my english.

First of all, you are very kind answering all our questions.

I see that it is possible to pair the HC-12 with an android (enabled gps) smartphone via a bluetooth module (no need to use arduino or gps module,right?).
Having two smartphones, what kind of software do I need to make one of them show the location of the other in Google Maps or a kind of app that uses Google Satellite?

• Seth Petersen 2019-02-27

Hello I was wondering if you think the data collected from the GPS transmission could be interpreted by an Arduino to command motors to drive a vehicle to the position that the GPS module indicated.

• Mark Hughes 2019-02-27

It is certainly possible, but personally I would choose a more powerful MCU.  You might find as you experiment that you need to create some obstacle detection and avoidance, or implement the Haversine or Vincenty formula, and an 8 bit microcontroller will be too hard to work with.  Use at least a 16 bit or 32 bit…..maybe check out what the folks over at ArduPilot are doing.
It isn’t impossible.  But it is easier with more powerful tools.