GPS tracker



  • In this project I'm going to connect a GPS module and use it as a GPS tracker.

    Hardware

    For this project I'm using:

    • Onion Omega 2 plus

    • U-BLOX NEO-6M GPS module

    • PL2303HXD Serial to USB cable

    • Battery case with USB in and out (5V/2.1A max)

    • 4x 18650 (3.7V/6000mA) batteries

    • Breadboard and some cables

    0_1489248776187_upload-17df5aff-7e9f-4e08-bc3a-c601f3952ee3

    0_1489248827650_upload-d7f41c48-75df-4aaa-be4e-48ad6c102f7f

    0_1489322359470_upload-3bbbc547-7fe8-4faa-80c9-65fb096a4c76

    0_1489322419031_upload-7d8de46d-2fe8-45de-a7bc-e4787e332c1f

    The GPS module can be used on 3.3V or 5V. Connected to the battery pack it can be used for approximately 4.5 hours (not bad I think).

    Connect the GPS module as follow to the PL2303HXD:

    GPS - PL2303HXD
    VCC -  5V
    GND -  GND
    TX    - RXD (white)
    RX    - TXD (green)

    Connect PL2302HXD to Onion Omega 2+ USB

    Installation

    Step 1
    Use the latest firmware

    oupgrade
    Device Firmware Version: 0.1.10 b160
    Checking latest version online...
    Repo Firmware Version: 0.1.10 b160
    Comparing version numbers
    Device firmware is up to date!

    Step 2
    Update packages

    opkg update

    Step 3
    I prefer nano as an editor, but there is no default installation

    opkg install nano

    Step 4
    I want to expand the filesystem so I can write large tracker files. So I need the following utility:

    opkg install e2fsprogs

    Step 5
    To use the USB to serial I need the following installations:

    opkg install coreutils-stty kmod-usb-serial-pl2303

    Step 6
    Add a SD card (I use a 2GB SD card)

    Look for SD card:

    dmesg | grep mmc
    [ 4.786320] mmc0: new high speed SD card at address 1234
    [ 4.803969] mmcblk0: mmc0:1234 SA02G 1.85 GiB
    [ 4.896881] mmcblk0: p1
    ...

    Format and mount SD card

    root@Omega-5101:~# mkfs.ext4 /dev/mmcblk0
    root@Omega-5101:~# mkdir /mnt/mmcblk0
    root@Omega-5101:~# mount /dev/mmcblk0 /mnt/mmcblk0/

    Edit fstab

    root@Omega-5101:~# /sbin/block detect > /etc/config/fstab

    root@Omega-5101:~# uci show fstab
    fstab.@global[0]=global
    fstab.@global[0].anon_swap='0'
    fstab.@global[0].anon_mount='0'
    fstab.@global[0].auto_swap='1'
    fstab.@global[0].auto_mount='1'
    fstab.@global[0].delay_root='5'
    fstab.@global[0].check_fs='0'
    fstab.@mount[0]=mount
    fstab.@mount[0].target='/mnt/mmcblk0'
    fstab.@mount[0].uuid='5417dc6b-0135-4f71-8ea0-f81d0666989c'
    fstab.@mount[0].enabled='0'

    Enable mount

    root@Omega-5101:~# uci set fstab.@mount[0].enabled='1'
    root@Omega-5101:~# uci commit fstab
    root@Omega-5101:~# uci show fstab
    fstab.@global[0]=global
    fstab.@global[0].anon_swap='0'
    fstab.@global[0].anon_mount='0'
    fstab.@global[0].auto_swap='1'
    fstab.@global[0].auto_mount='1'
    fstab.@global[0].delay_root='5'
    fstab.@global[0].check_fs='0'
    fstab.@mount[0]=mount
    fstab.@mount[0].target='/mnt/mmcblk0'
    fstab.@mount[0].uuid='5417dc6b-0135-4f71-8ea0-f81d0666989c'
    fstab.@mount[0].enabled='1'

    Make it permanent

    root@Omega-5101:~# /etc/init.d/fstab enable
    root@Omega-5101:~# df -h
    Filesystem Size Used Available Use% Mounted on
    /dev/root 5.5M 5.5M 0 100% /rom
    tmpfs 61.4M 216.0K 61.2M 0% /tmp
    /dev/mtdblock6 25.1M 1.2M 23.9M 5% /overlay
    overlayfs:/overlay 25.1M 1.2M 23.9M 5% /
    tmpfs 512.0K 0 512.0K 0% /dev
    /dev/mmcblk0 1.8G 5.5M 1.7G 0% /mnt/mmcblk0

    Step 7
    Expand filesystem (overlay)

    root@Omega-5101:~# mount /dev/mmcblk0 /mnt ; tar -C /overlay -cvf - . | tar -C /mnt -xf - ; umount /mnt

    Edit fstab

    root@Omega-5101:~# nano /etc/config/fstab

    config 'global'
    option anon_swap '0'
    option anon_mount '0'
    option auto_swap '1'
    option auto_mount '1'
    option delay_root '5'
    option check_fs '0'

    config 'mount'
    option target '/mnt/mmcblk0'
    option uuid '5417dc6b-0135-4f71-8ea0-f81d0666989c'
    option enabled '0'

    Change to:

    config 'global'
    option anon_swap '0'
    option anon_mount '0'
    option auto_swap '1'
    option auto_mount '1'
    option delay_root '5'
    option check_fs '0'

    config 'mount'
    option target '/overlay'
    option uuid '5417dc6b-0135-4f71-8ea0-f81d0666989c'
    option enabled '1'

    Ctr+X --> Y

    Reboot

    root@Omega-5101:~# reboot
    root@Omega-5101:~# df -h
    Filesystem Size Used Available Use% Mounted on
    /dev/root 5.5M 5.5M 0 100% /rom
    tmpfs 61.4M 104.0K 61.3M 0% /tmp
    /dev/mmcblk0 1.8G 6.7M 1.7G 0% /overlay
    overlayfs:/overlay 1.8G 6.7M 1.7G 0% /
    tmpfs 512.0K 0 512.0K 0% /dev

    Step 8
    Set timezone.
    I'm living in the Netherlands so I choose the timezone for Amsterdam.
    The timezones list is on: Timezones

    We also need the corresponding NTP-servers. I'm using the dutch (nl) pool servers.
    The pool servers list is on: NTP pool

    Change timezone en ntp-servers to your choices

    root@Omega-5101:/# cd /etc/config
    root@Omega-5101:/etc/config# nano system

    config system
    #option timezone 'GMT0'
    option timezone 'CET-1CEST,M3.5.0,M10.5.0/3'
    option ttylogin '0'
    option log_size '64'
    option urandom_seed '0'
    option cronloglevel '8'
    option hostname 'Omega-5101'
    #
    config timeserver 'ntp'
    option enabled '1'
    option enable_server '0'
    list server '0.nl.pool.ntp.org'
    list server '1.nl.pool.ntp.org'
    list server '2.nl.pool.ntp.org'
    list server '3.nl.pool.ntp.org'

    Ctrl+X + Y

    root@Omega-5101:/etc/config# reboot

    Check date / time

    root@Omega-5101:~# date
    Fri Mar 10 17:15:02 CET 2017

    Step 9
    Install Python

    root@Omega-5101:~# opkg update
    root@Omega-5101:~# opkg install python
    root@Omega-5101:~# opkg install python-pyserial

    Step 10
    Check if GPS is connected

    root@Omega-5101:~# dmesg | grep pl2303
    [ 10.664492] usbcore: registered new interface driver pl2303
    [ 10.670369] usbserial: USB Serial support registered for pl2303
    [ 10.676466] pl2303 2-1:1.0: pl2303 converter detected
    [ 10.703003] usb 2-1: pl2303 converter now attached to ttyUSB0

    Getting data from GPS

    root@Omega-5101:~/gps# stty -F /dev/ttyUSB0 ispeed 9600 && cat </dev/ttyUSB0
    $GPRMC,154105.00,A,5315.64610,N,00601.92077,E,0.092,,030317,,,A*72
    $GPGGA,154105.00,5315.64610,N,00601.92077,E,1,08,1.00,-7.0,M,45.6,M,,*77
    ...
    Ctrl+Z

    Step 10

    Make tracker source

    root@Omega-5101:~# cd ~
    root@Omega-5101:~# mkdir gps
    root@Omega-5101:~# cd gps
    root@Omega-5101:~# nano tracker.py

    Source:
    tracker.py

    Step 11
    Test the tracker

    root@Omega-5101:~/gps# python tracker.py
    Start reading: /dev/ttyUSB0
    [1] Wait for GPS data 2017-03-10 17:22:37
    [1] GPS tracker alive at 2017-03-10 17:22:39
    [2] GPS tracker alive at 2017-03-10 17:22:44
    [3] GPS tracker alive at 2017-03-10 17:22:50
    [4] GPS tracker alive at 2017-03-10 17:22:55
    ...

    Ctrl+Z of Ctrl+C

    Show ublox file

    root@Omega-5101:~/gps# nano t20170310172237.ubx

    $GPGLL,5315.64852,N,00601.92650,E,162238.00,A,A*65
    $GPGGA,162239.00,5315.64882,N,00601.92671,E,1,06,2.13,1.6,M,45.6,M,,*59
    ...

    Step 12
    So I connected the GPS tracker to the battery pack and went for a bike ride and recorded the result.
    The ublox fileformat can be used with u-center

    This is the result:
    0_1489254754944_upload-10ff5ca5-c407-42f3-bdd4-e6d36e72e06d



  • Great project and write up!

    You can install nano if you add, I believe, the Lede package links to your opkg sources. There are plenty of others who have done this and I'm sure you can search to find them.

    I have the 6M-NEO from Onion Kickstarter and while the on-board antenna is not working well, I picked up an Active 28db Antenna off of eBay which locks on fast! I'll be thinking about mobile GPS related projects myself in the future and I'm sure will use your work as help or basis in the future.

    Cheers!
    ~Icky



  • Accomplishing a project is a great thing in and of itself, but I'm curious why a Linux router SoC like an Omega was chosen for this? Given the fairly high power draw, it would seem an odd choice compared to a slower clocked (and potentially sleeping at intervals) MCU for a portable and presumably battery powered project where the latter would seem sufficent. Ironically, an SPI flash as used on the Omega itself is probably better than an SD card for storing the logged data.



  • @Chris-Stratton no particularly reason. Just because it can. Also tried some other microprocessor controllers (raspberry pi, eps12 and arduino). Was just curious it would work on the omega 2. Using the battery pack with 4x 18650 (6000 mA) batteries gives a lifespan of approximately 4.5 hours.



  • Also tried some other microprocessor (raspberry pi, eps12 and arduino).

    Those are not microprocessors, but development boards or full embedded computers.

    Notably, none of them are designed for battery power.

    The ATmega off an Arduino could make sense in a battery application, but it would be better used on a board that did not add wasteful idle current draw, in the way that regulator and USB serial chip on an Arduino do.



  • @Oene-Bakker Nice Omega2+ project.

    Seems something is wrong with the battery lifespan for your 18650 - is 4.5 hours the actual run time?! - Chinese "Ultrafire" brand batteries are notoriously over-rated ... if yours are some inexpensive eBay cells then those actually seem to supply only 500 - 1,000mAh per cell, so the total power for low quality batteries could be only 4 x 500mAh = 2,000mAh. The power requirement of the Omega and GPS unit is ~250ma at 3v3 or 250mAh, suggesting you could run the Omega for at least 8 hours with 2,000mAh. Yes, the battery box steps-up the 3.X V of the batteries to 5V for the USB connection, then some Omega dock steps the power down to 3v3 for the Omega ... would those losses be ~800mAh? Seems it is a bad joke that those cells are marked "6,000mAh", when actually it is more like 400mAh! Or do you actually have a longer run time? If not, better lithium batteries would last all day or longer.

    If you could turn off the Omega's wifi then there would be a nice power savings. Perhaps reducing the wifi power output to near zero could do that.



  • @Ken-Conrad I tested it at home and it really was 4.5 hours active. So perhaps these Ultrafire batteries are of better quality(?)



  • @Chris-Stratton slip of the pen 😃 I meant microcontrollers....



  • @Oene-Bakker I see, 4.5 hours is the power run you got from your batteries and pack. Google "Ultrafire real capacity" to see what little power the "Ultrafire" branded batteries can actually yield. Apparently no truth in the labeling of some Chinese batteries!



  • @Oene-Bakker said in GPS tracker:

    @Chris-Stratton slip of the pen 😃 I meant microcontrollers....

    But they aren't microcontrollers. They are large embedded systems, or in the case of the Arduino, development boards with a lot of power-wasting components on them compared to using the microcontroller in a way that would be sensible for a battery design.



  • This Is too old but I want to add something, omega2 has 2 port uart, the first is used to communicate with a pc over expansion board, so you have one uart port free, you can do it without USB to serial adapter on RX1 an TX1



Looks like your connection to Community was lost, please wait while we try to reconnect.