Hi,
I recently got the Wavesahre GPRS/GPS HAT for a project to create a realtime or near realtime gps logger. There are not many tutorials using this HAT. So here is what i found helpful:
The easiest way to establish an internet connection is with the PPP configuration. The PPP configuration handles all the necessary AT commands. I used this tutorial to make my project work:
https://www.digikey.com/en/maker/projec ... c5c1dc2ff0.
It's written for a different SIM modem (SIM808) but it works also with the one on the Waveshare HAT (SIM 868). Just follow the steps form "Part 2: Connecting the FONA."
You need the APN of your SIM provider. In my case it looks something like "gprs.myProvider.com". For the Serial port i used
/dev/serial0. This worked on 3B+ and Zero W.
I disabled the pin code of my SIM before i put it into the Waveshare HAT. If you don't want to do this uncomment
AT+CPIN=1234 in:
The tutorial provides also the code to make a GPS logger that sends the data over the PPP connection. In my experience the code works well. I used it as a basis for my project.
To power on the HAT via a script rather than the power button i found this shell script:
Code: Select all
#!/bin/bash
if [ ! -e /sys/class/gpio/gpio4 ]; then
echo "File exists."
echo "4" > /sys/class/gpio/export
fi
echo "out" > /sys/class/gpio/gpio4/direction
echo "0" > /sys/class/gpio/gpio4/value
sleep 2
echo "1" > /sys/class/gpio/gpio4/value
Credit:
https://raspberrypi.stackexchange.com/a/83621
To automate it at startup create a new file, copy & paste the code from above and save it with a
.sh ending. Then open
. At the end of the file,
before the exit 0 statement, write sudo and the file path to the shell script. It should look like this:
Code: Select all
sudo /home/pi/gipo4onoff.sh
exit 0
.
To power it off at shutdown go to
and create a new empty file. Copy & paste the following code:
Code: Select all
[Unit]
Description=runs only upon shutdown
Conflicts=reboot.target
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/home/pi/gipo4onoff.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Change the file path under
ExecStop to your shell script. Save the file with a .
service file extension. Now we need to enable it:
Code: Select all
systemctl daemon-reload
systemctl enable yourServiceFile.service
systemctl start yourServiceFile.service
Credit:
https://www.unix.com/red-hat/272693-whe ... tdown.html
Keep in mind that you can only have one connection over the serial port. With the PPP connection on, you can't send
AT+CGNSINF to the HAT to get the actual gps location.
Hope this helps somebody save some time...