Using GPS – ESP32 Gateway with Simcom Modem

Locating IoT devices can be very useful in applications like agricultural automation and data acquisition or monitoring. ESP32 can get you an approximate position based on nearby Wi-Fi networks using geolocation APIs, but that is often not possible.
Using built-in GPS, ESP32 Gateway devices that we make can acquire accurate time and location information. This article contains notes on using the GPS on gateways that contain a Simcom modem (focus on the SIM7600 GPS).

The hardware used for the tests mentioned here is the PCB Artists ESP32 4G Gateway (Gen.1).

Choosing GPS Antenna for ESP32 Gateway (Simcom modem)

This might not seem like a big deal at first, however, GPS receivers can be very difficult to use if you are using an incorrect antenna type. There are several GPS antenna available in the market and not all of them work equally well.

Here are some GPS antenna types that we used with the ESP32 4G Gateway and notes on how well they performed.

active passive gps antenna comparison teardown
Left: active GPS antenna (source: EDN) and Right: passive antenna

Passive Ceramic Patch Antenna

A truly passive GPS antenna contains no amplifier circuits inside. It is very easy to confuse between passive and active ceramic GPS patch antenna. I noticed numerous listings on the internet that falsely claimed the antenna type or did not specify at all. The definitive method to tell is to see what is inside the patch antenna. If there is no active circuit with an LNA in there (like the one on the left), it is a passive antenna (one on the right).

A passive GPS antenna will only work if the Gateway is in open outdoor space with unobstructed and wide view of the sky. Simcom, like most other modem makers, does not recommend using a passive antenna with SIM7600. I tested with a passive antenna anyway, test results are included in the following sections.

Active Ceramic Patch Antenna

An active patch antenna contains an LNA that actively amplifies signals acquired by the patch antenna. You will not see an external difference between active and passive antenna types because the amplifier circuit is usually concealed inside the RF shield on the lower side of a patch antenna.

Here is an article on the teardown of a common active GPS patch antenna used with dashcams.

active gps antenna for gps sim7600
Active antenna we recommend for ESP32 4G Gateway

The active patch antenna shown above is ideal for use with the PCB Artists 4G Gateway and similar devices because it can be mounted inside the enclosure with a double sided tape or hot glue and it will work just fine in most conditions

If you would want to enhance the performance of the GPS by locating the antenna somewhere better, you can always use a long cable GPS antenna. Note that you will need an u.FL to SMA converter cable to attach this antenna to the Gateways.

gps active antenna with long cable
A patch antenna for outdoor use

ESP32 GPS Example Program - IoT Location Logger

To investigate how well each antenna option works with the 4G Gateway, I used a simple position logger program written in ESP-IDF to see how long it took the SIM7600 GPS to obtain a location fix. To make the tests as comparable as possible, the GPS is always started in a cold start configuration using AT+CGPSCOLD.

// Note that modem should be in command mode
// Start the GPS (cold start, unassisted after power cycle)
err = esp_modem_at (dcehandle, "AT+CGPSCOLD", resp, 1000);
ESP_LOGI (TAG, "AT+CGPS=1");
if (err != ESP_OK)
    ESP_LOGW (TAG, "AT+CGPSCOLD resulted in error [err %d]", err);

// Fetch latest location information every 5 seconds
while (1)
{
    err = esp_modem_at (dcehandle, "AT+CGNSSINFO", resp, 1000);
    if (err != ESP_OK)
        ESP_LOGW (TAG, "AT+CGNSSINFO resulted in error [err %d]", err);
    else
        ESP_LOGI (TAG, "%s", resp);

    vTaskDelay (5000/portTICK_PERIOD_MS);
}

Nothing fancy, the test code simply polls the GPS for coordinates using the AT+CGNSSINFO every 5 seconds and prints out the response in the terminal. When a fix is obtained, the logs start showing the acquired latitude and longitude information.

cold start gps position fix on sim7600 modem
GPS position fix after a cold start

Notes on GPS working - outdoors, near window, and indoors

testing gps antenna with esp32 4g gateway sim7600
Testing GPS on PCB Artists 4G Gateway (SIM7600 modem)
  • Placing the active antenna or the passive antenna outside in clear skies worked very well. A fix was obtained in about 30 seconds with the active antenna and about 45 seconds with the passive antenna.
  • I placed the active antenna (with a long cord) near a window (within 1 foot of the glass window, clear view of the sky outside, no tall buildings in view). The location fix was obtained by the SIM7600 within 100 seconds of a power cycle.
  • Shifting over to another window, this time with a rather obstructed view with another building about 3 meters away from the window – location fix was obtained in about 150 seconds with cold start using an active antenna. A passive antenna did not obtain a fix and only worked a couple times out of several power cycles.
  • Moving indoors was a different story. Both antennas stopped working after moving about 4 feet from the nearest window. In other words, if the GPS patch is not pointing towards the sky, you may not get a fix. Tilting the antenna towards a nearest window obtained a fix sometimes – but was not reliable.

Have Something to Say?

Feel free to ask away via the Live Chat, drop us a message using the Quick Contact form in the sidebar, or leave a comment below.

Change Log

  • 11 March 2023
    – Initial release

You may also like

Leave a Comment

19 − 7 =