Today we are going to see how we can serve gps location from SIM7600 module to a port in raspberrypi through daemon.
- SIM7600 (Connected to /dev/ttyS0, i.e., pi's serial port)
- Putty in your laptop/desktop for communication with raspberrypi.
This post does not cover on how to integrate SIM7600 module with raspberrypi.
Minicom is a serial communication program that connects to devices through a GNU/Linux PC's serial ports.
Before installing minicom, serial port has to be enabled from raspberry-configuration.
Go to Interface Options-> P6 Serial Port -> No -> Yes.
This will enable the serial port communication.
I have connected SIM7600 module with raspberrypi through UART (ttyS0). If you have a GPS module of connector type usb, you might need to find its address.
One easy way to find the address is by connecting only the gps module with pi and execute following command
ls -l /dev/ttyS0
If the port is correct then you will get an message as above.
By default GPS will be off. We need to perform following operations
AT+CGPS=1,1 Returns OK AT+CGPS? _Returns_ +CGPS:1, 1 OK
Enter below AT command to turn on GPS automatically whenever the module is turned on.
AT+CGPSAUTO=1 _Returns_ OK
Enter below AT command to feed the gps nmea sentence every 1 second in the serial port out.
AT+CGPSINFOCFG=1,31 _Returns_ OK
Exit from minicom terminal and restart pi and SIM7600. To confirm everything went well.
Don't worry, if nothing gets print on the screen. This is because minicom stops writing data once you exit from its terminal.
You try again the above command in a different terminal session without closing minicom.
Next, create a minicom script to execute AT+CGPSINFOCFG=1,31
Content of the script is as shown below.
Save the file in /home/pi/start-gps.sh
You can see nmea sentence printing in minicom terminal once you execute
minicom -S start-gps.sh
Still this is not enough, we have to create a bash script to execute above command during system startup automatically.
Create minishell.sh with below content in /home/pi/.
#!/bin/bash minicom -S start-gps.sh
Make it executeable
chmod u+x minishell.sh
bashrc is a program which can execute other scripts on startup.
Edit ./bashrc file and add
#start minicom gps echo "turning gps on" sudo ./minishell.sh
at the end of the file.
Install gpsd and gpsd-clients from apt.
sudo apt-get install gpsd gpsd-clients python-gps
Again edit ./.bashrc file to add below script at the end of the file.
sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock