Source link for the below listed commands: uConsole: How to enable 4G extension
A guide for setting up GNSS for your uConsole from scratch, including finding GNSS antennas for connecting to your uConsole, along with information on how to decode the output from the GNSS receiver.
For this HOWTO, you need the uConsole 4G Extension module to use GNSS, but you do not need SIM card or cell subscription installed on the 4G extension module in order to use GNSS
Just to repeat, so there's no misunderstanding, you can use the all of the commands listed below without a SIM card installed into the 4G Extension module.
You could also design your own GNSS Extension module for the uConsole, in which case, this guide may be of some help, or may not be of any help whatsoever, depending on your design and the components you use.
You need some kind of GNSS antenna connected to the 4G Extension module in order to receive GNSS radio signals. The only way to get signals to the 4G Extension module is to use an antenna. Period.
- Opening up the back of the case and giving the 4G extension module "thoughts and prayers" in order to receive GNSS signals won't work. Nice try, you need a "real" antenna though.
- Don't run the GNSS module without an antenna for long periods of time (See "Standing Wave Ratio" below").
DO NOT purchase a "GSM" or "WiFi" antenna for connecting to the GNSS port on the 4G module, GSM/WiFi antennas are for use with a different set of frequencies than what GNSS uses. You want an antenna with a low Standing Wave Ratio at 1.5GHz.
- All of the GNSS systems use the radio frequency spectrum at around 1.5GHz
- GSM uses various frequencies, depending on what country you live in
- WiFi/Bluetooth use the radio frequency spectrum at around 2.4GHz
Search terms to use for finding the "correct" GNSS antenna are provided in the next section, don't panic.
I found a $2 "active" GNSS (GPS) antenna on FleaBay, it shipped from China to the US, but it arrived pretty quickly.
You can use these search terms on FleaBay, Aliexpress, Amazon, etc.
- IPEX(UFL) Ceramic Active GPS Antenna <-- This set of terms got me the "ribbon" style antennas.
- GPS Internal Antenna IPEX <-- lots of good hits too
- GPS antenna ufl <-- I originally bought 2 of these, and used "Command strips" to stick it to the top of my uConsole
- GPS antenna u.fl
Another possiblity is to buy a "U.FL to SMA" adapter, at which point you can use GNSS antennas with SMA connectors, which would allow you to use dedicated car or whip antennas, for example.
For what it's worth, I was using the "active" board antenna with a "U.FL" connector with the antenna stuck to the top of the uConsole with "Command Strips", then I switched to a "U.FL to SMA" adapter in order to use a magnetic car GNSS antenna that I received with a (separate) SDR kit. This way, I can have the uConsole on my desk and put the antenna by the window, instead of setting the uConsole on the window sill so it can try and get a signal.
The GNSS board installed on the 4G extension is a "SimCom SIM7600".
You can verify this using the following command:
$ echo -en "AT+CGMM\r\n" | sudo socat - /dev/ttyUSB3,crnl
SIMCOM_SIM7600G-H
OK
The SIM7600 board accepts "AT" commands to change the configuration of the board. There's literally a whole PDF document full of them.
To find the correct PDF document on the web, search for:
- SIM7500 SIM7600 Series AT Command Manual
Once you download the "AT Command Manual" use bookmarks in the PDF file to save things you want to come back to later. You're welcome.
The "most recent" version of the "AT Command Manual" that I could find on the 'net was 3.00, from November 18th, 2021.
The GNSS receiver uses the "NMEA" format for outputting everything... position information, available GNSS satellites, literally everything. More info on NMEA can be found on their website
You can find older versions of the "NMEA Manual" on the web, but if you want the latest and greatest, be prepared to pay. Latest and greatest currently is 4.11, but I was able to find older versions of the manual for free with some judicious searching.
You can also just read the NMEA output text directly from the receiver, and "figure it out" or "search the web" for other people and/or Open Source projects that have decoded a given NMEA message already.
The cellular modem lives on the system as device filename /dev/ttyUSB2
when it is plugged in and turned on.
The GNSS receiver lives as device filename /dev/ttyUSB3
when it is enabled using the below commands.
Enable the GNSS receiver
sudo bash uconsole-4g-cm4 enable
Check firmware version:
echo -en "AT+CUSBPIDSWITCH?\r\n" \ | sudo socat - /dev/ttyUSB2,crnl
Turn on GPS:
echo -en "AT+CGPS=1\r\n" | sudo socat - /dev/ttyUSB3,crnl
The first time you apply power and use this command, the time to initial fix could be up to 10 minutes, depending on where your antenna is located and what it can "see".
Subsequent starts of the module will take up to one minute from the time you run gnss_start
before a GNSS position will be available using gnss_get_pos
.
Get current position:
echo -en "AT+CGPSINFO\r\n" \ | sudo socat - /dev/ttyUSB3,crnl
Until the initial fix has been obtained, the receiver will output this text when the `AT+CGPS:
+CGPSINFO: ,,,,,,,,
OK
Once the receiver "knows" where it is located, the above command will output the current location, in "NMEA 0183" format.
Get the GPS position every 10 seconds:
echo -en "AT+CGPSINFOCFG=10,255\r\n" \ | sudo socat - /dev/ttyUSB3,crnl
Get the list of visible GPS satterites:
echo -en "AT+CGPSINFOCFG=10,8\r\n" \ | sudo socat - /dev/ttyUSB3,crnl
Use SSH to connect to your uConsole and create the below shell scripts, preferrably in a directory that is already in your $PATH
environment variable. I placed all of thes scripts in $HOME/bin
on my uConsole. That way, if you are using the keyboard on the uConsole, you can run these scripts to get GNSS up and running, instead of typing out the commands in full.
I also symlinked the uconsole-4g-cm4
script into my $HOME/bin
directory to make it easier to access.
FIXME rewrite these scripts into a single script that parses output and polls for changes in status.
Script order:
uconsole-4g-cm4 enable
; wait about 10-15 seconds before running the next scriptgnss_mm_reload
: RestartModemManager
after enabling the 4G extension modulegnss_modem_chk
: Check to see if the modem is available; you should see/org/freedesktop/ModemManager1/Modem/0 [SIMCOM INCORPORATED] SIMCOM_SIM7600G-H
in the outputgnss_fw_ver
: (Run as needed, not every time) Check firmware version after the modem is enabledgnss_start
: Start looking for satellites and fixing positiongnss_get_pos
: Get the current position of the devicegnss_stat
: Check the status of the GNSS receiver
The first time you apply power and use the gnss_start
command script, the time to initial fix could be up to 10 minutes, depending on where your antenna is located and what it can "see".
Subsequent starts of the module will take up to one minute from the time you run gnss_start
before a GNSS position will be available using gnss_get_pos
.
sudo systemctl restart ModemManager
mmcli -L
echo -en "AT+CUSBPIDSWITCH?\r\n" | sudo socat - /dev/ttyUSB2,crnl
echo -en "AT+CGPS=1\r\n" | sudo socat - /dev/ttyUSB3,crnl
echo -en "AT+CGPSINFO\r\n" | sudo socat - /dev/ttyUSB3,crnl
echo -en "AT+CGPS?\r\n" | sudo socat - /dev/ttyUSB3,crnl
The gpio
command is how you set the "pins" on the Raspberry PI CM4 to "talk" to the 4G extension module. The gpio
command does not have a man
page. Use sudo gpio -h
to view the help output from the command.