Quickly build a gps trajectory application based on traccar

0. Environment

- win10 + virtual machine ubuntu18
- i5 ubuntu22 notebook
- one USB-GPS module, such as BGI Beidou TAU1312-232 board
- dual notebook networking equipment: router, so that the win10 notebook IP: 192.168.123.x, and the i5 notebook IP It's 192.168.123.215.
- Android phone

1. Build traccar service

1.0 Environment


ubuntu22+i5 notebook

1.1 Install docker

$ sudo apt remove docker docker-engine docker && \
sudo apt update && \
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common && \
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - && \
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" && \
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io
$ sudo systemctl status docker
$ sudo systemctl restart docker
$ sudo docker run hello-world

1.2 Follow the tutorial to install docker traccar


1.2.1 Create work directories:

mkdir -p /opt/traccar/logs

1.2.2 Get default traccar.xml:

docker run \
--rm \
--entrypoint cat \
traccar/traccar:latest \
/opt/traccar/conf/traccar.xml > /opt/traccar/traccar.xml

1.2.3 Create container:

docker run \
--name traccar \
--hostname traccar \
--detach --restart unless-stopped \
--publish 80:8082 \
--publish 5000-5150:5000-5150 \
--publish 5000-5150:5000-5150/udp \
--volume /opt/traccar/logs:/opt/traccar/logs:rw \
--volume /opt/traccar/traccar.xml:/opt/traccar/conf/traccar.xml:ro \
traccar/traccar:latest

 

 

2. Mobile phone test results


Install traccar client on Android phone.
Open https://www.traccar.org/client/ on your mobile browser, download the apk and install it. The server address is changed to the i5 laptop IP with traccar service built, and the default port is 5055.

 

 

Log in to the web of the traccar server on your computer and add the mobile phone device code to your account.

After setting up, you can see that the phone is online. Note that the mobile phone and the server are under the same router. 

 

 

3. Win10 notebook as client


3.0 Environment


ubuntu18 virtual machine + gps machine

3.1 Verify gps


minicom -s configure ttyUSB0, the baud rate is 115200
and there is data before proceeding to the next step.

Note: If you do not receive GPS data, it may be caused by permission issues. Execute the following command to add the current user (non-root user) to the dialout user group, then restart the system and try again.
 

sudo usermod -a -G dialout $USER
reboot


 
3.2 apt directly installs gpsd

sudo apt install gpsd gpsd-clients


 
Start the gpsd service in systemd mode

sudo systemctl start gpsd

Stop the gpsd service in systemd mode. The reason is that the default configuration of gpsd is not normal and is not ttyUSB0.

sudo systemctl stop gpsd.socket

Check gpsd service status

sudo systemctl status gpsd

Start a new gpsd instance that redirects data from the correct serial port to the socket:

sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

Start cgps client observation data:

cgps

Start the gpsmon client to observe data:

gpsmon

3.3 Get the gpsd-traccar script

https://gist.github.com/linuxsocist/55e10998e88f61af9e6ec12c12bbb04e

3.4 Running tests


Change the IP to 192.168.123.215 as the computer IP where traccar is deployed.

Run tests

sudo apt install jd
chmod +x gpsd-traccar.sh
./gpsd-traccar.sh

Log in to the web and see the location.

 

traccar has a report function, which allows you to view the tracks and areas visited by customers.

However, if the database in docker has not undergone additional settings, the database data will be cleared after exiting docker.

4. Impressions

This service occupies a lot of ports. The 1C2G server last night was not enough for my deployment. The actual deployment occupied 2.5G of memory in the i5 laptop. This application is quite amazing. After using several short video apps, it will obtain the user’s location data information. My back is really cold.


reference:

如何在Raspberry Pi 4中使用GPS接收器模块,https://www.yiboard.com/thread-1381-1-1.html
Install Traccar on DigitalOcean VPS,https://www.traccar.org/install-digitalocean/
Traccar 记录你的足迹,https://zhuanlan.zhihu.com/p/98380567
[进阶教程] traccar从零开始到完美使用完全教程,https://bbs.hassbian.com/thread-7568-1-1.html
traccar从零开始到完美使用完全教程,https://bbs.iobroker.cn/t/topic/772


 

Guess you like

Origin blog.csdn.net/qq_27158179/article/details/132381638