Sinotrack ST-901 config issues

obelix8 years ago

hi,

I'm trying to use a Sinotrack ST-901 with traccar, but I'm running into several issues here. I hope someone is around who also uses this tracking device and can give some hints, what I do wrong...

Problems / what I did already:
I already know the device uses the H02 Protocol. So I opened the port 5013 on my traccar server. Also the H02-protocol is enabled in traccars config file.

I also configured the ST-901 with SMS-Commands to update every 5 seconds (from what I understand that's the shortest time period the device can handle). I also switched on the GPRS mode. The RCONF SMS-command reports back from the ST-901 as follows: "ST-901,ID:.UP:0000,U1:,U2:,U3:,MODE:GPRS,DAILY:OFF,POWERALARM:OFF,ACCSMS:OFF,ACCCALL:OFF,GEO FENCE:OFF,OVER SPEED:OFF,VOICE:ON,SHAKE ALARM:OFF,SLEEP:OFF,APN:internet,,,IP:...**:5013,GPRS UPLOAD TIME 1:5,GPRS UPLOAD TIME 2:5,TIME ZONE:00" (replaced ID and server IP with *)

Now I'm powering up the device again and starting to monitor the LEDs and also the tracker.log on the Server. First the orange/yellow LED stops blinking and stays lit - I assume GPRS connection is ok. Blue GPS-LED stops blinking shortly after the orange one and stays lit - I assume GPS fix is ok as well.

But now the interesting part: the device only reports roughly after 10-15 minutes (!) a position to the server once, but from all I see, that position data is decoded correct. After that one position is rceived - no further position messages seem to reach the server until I power cycle the ST-901. Only thing I see is every 20 minutes a disconnect / connect message in the log.

So anyone around who ran into same issue and can help me? I'm still not sure where to search for the problem, but I rather suspect the tracking device to be the culprit, since the server seems to operate well with a self made tracking device based on a raspberry pi.

Thanks in advance for any help - I hope it's not too much off topic for this forum.

obelix

Anduriño8 years ago

"...I also configured the ST-901 with SMS-Commands to update every 5 seconds (from what I understand that’s the shortest time period the device can handle)..."

That is the fault. Although the user manual says a range between 5-480 seconds, with 5 fault, try using a minimum of 10 seconds

My setting:

805XXXX 10
809XXXX 30
SLEEPXXXX 5

(XXXX = your password)

obelix8 years ago

yup - looks like that solved the problem. Thanks!
thumbs up

you have any idea if it's somehow possible to store a hostname instead of an IP in the configuration of the ST-901? I run my traccar server at home (on a raspberry pi - I like those devices :)) but my ISP assigns a new IPv4 address every 24h. So I made the server available on a dynamic ip name (say myhomeserver.org for example). Funny thing is: the ST-901 accepts that name in the configuration SMS, but seems to DNS-lookup the name when it's processing the SMS and stores the current IP address instead. So when the address changes the next time, it's wrong again in the tracker...

Any idea if that's an issue that can be solved in the device (instead of writing a script which kicks in and updates the tracker every time a new IP is assigned by sending a SMS from command line)?

Anduriño8 years ago

"...but seems to DNS-lookup the name when it’s processing the SMS and stores the current IP address instead..."

Yes, that does not sound strange to me. I have it checked with the RCONF command... And unfortunately I have not found a solution

Anduriño8 years ago

@@obelix would appreciate the code if you get to run a script to solve it...
Thanks!

obelix8 years ago

I'll do that - as soon as there is time...

the main problem is to find a cheap SMS service that also provides an email2sms gateway. Since nowadays SMS becomes more and more obsolete, finding such a provider is going to be an ...interesting task ;)

Anduriño8 years ago

@obelix RCONF cached ????

1/ The ST-901 accepts our domain name in the 804 command.

2/ RCONF command shows "current IP"

3/ Now the ISP assigns a "new IPv4" address.

4/ RCONF command shows the "old IP"

5/ Test the RESTART command.

6/ RCONF command shows the "new IP" !!!.

obelix8 years ago

okies - really looked like a caching issue. I just power cycled the router (for a new IP address) and also the tracker (to "refresh" the IP there) and the device reports back location data.

No clue why it did not work in the first place. but well - now it does. :D

Thanks for the help!

obelix8 years ago

This is a script for either sending a new server IP address to the ST-901 every time the router between server and the internet gets a new public IP. It's untested so far, since I did not find a free or cheap email to SMS provider for Germany. The script was more or less hacked together from snippets I use in other bash scripts for various purposes, so it might have still errors in it. Whoever wants to use it, is on it's own there. ;)

This script and components will work with a router "AVM Fritz!Box 7490" (I use some specific code there for the detection of the external / public IP). Other router models might either have their own iterface to read the external IP or you want to rely on an external service like http://my.ip.fi

Since I want to be dependant of as less external services as possible, I took the (a bit more complex) way of reading the IP from my router with the help of two more scripts :D

But from the beginning. What is needed:

  • ST-901 configured with the 804-Command to your dynamic IP name
  • Raspberry Pi (I did the test on an old RPi model B, first generation - but you can use any other linux system, where you can install the needed packages)
  • have the sendemail package installed (on raspbian OS with "sudo apt-get install -y sendemail", or by getting the official release from here: http://caspian.dotconf.net/menu/Software/SendEmail/ )
  • have the curl package installed
  • you need a email2SMS gateway provider, which will then forward your email with commands as an SMS to your ST-901 tracker
  • have the following scripts available on your raspi pi in /home/pi/script/tracker :

file 1 named external_ip.xml

<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" />
  </s:Body>
</s:Envelope>

file 2 named external_ip.sh

#!/bin/bash
curl -s "http://192.168.178.1:49000/igdupnp/control/WANIPConn1" -H "Content-Type: text/xml; charset="utf-8"" -H "SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress" -d "@/home/pi/script/tracker/external_ip.xml" | grep -Eo "\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>"

let's get started with the script for the tracker update / restart. I've added explanations in the #comments
the script should be placed in /home/pi/script/tracker - otherwise the paths in the script need to be adjusted

#!/bin/bash

#first let's add some path variables
MAILSENDER="/usr/bin/sendemail"
IPFILE="/home/pi/script/tracker/IP.tmp"
EXTIPSCR="/home/pi/script/tracker/external_ip.sh"	#uncomment this line if you have a Fritz!Box 7490 router (other Fritz!Box router with current firmware might work too)
#EXTIPSCR="curl http://my.ip.fi"					#uncomment this line if you don't have a Fritz!Box router 
WORKDIR="/home/pi/script/tracker"

#some other needed variables
ROUTERIP="192.168.0.1"
CHECKURL="google.com"                           #to check if there is an internet connection... I assume if google isn't available, it's the end of the internet either :D
TRACKERCOMMAND="RESTART"                        #RESTART for ...restarting the ST-901, or the 804-Command with pin and IP-Name for setting the IP name
MAIL2SMSGWADDR="mailto@invalid.inv" 		#you need to enter your email2SMS gateway email address here 
MAILFROM="from@invaild.inv" 			#you need to enter the email address you are sending from here
MAILSRVR="mail.invailid.inv:587" 		#enter the mail server and port you use to send with $MAILFROM
MAILUSER="johndoe" 						#login credentials for the mail server - your username
MAILPASS="topsecret" 					#login credentials for the mail server - your password
TLSOPTION="-o tls=no"					#needs to be changed when outbound mailserver uses TLS

MAIL2SMSSUBJECT="$TRACKERCOMMAND"		#subject for the email to your email2sms gateway, needs to be adjusted to your specific provider
MAIL2SMSMAILBDY="$TRACKERCOMMAND"		#mail body for the email to your email2sms gateway, needs to be adjusted to your specific provider

#some PID-magic to do checks for only one instance of the script running same time
#this part of the script I "borrowed" here: http://www.nullpointer.at/2012/04/22/mit-bash-prufen-ob-das-eigene-script-gerade-lauft/
PID=$$
SCRIPTNAME=$(basename $0)
PIDFILE=/tmp/$SCRIPTNAME.pid

ENDSCRIPT=0	#if set to 1, script will be stopped

if [ -f "$PIDFILE" ] ; then
    RUNNINGPID=$(cat "$PIDFILE")
    PROGRAMPID=$(ps -e | grep "$SCRIPTNAME" | grep -v grep | awk '{print $1;}')
    for PIDEL in $PROGRAMPID 
    do
        if [ "$PIDEL" == "$RUNNINGPID" ] ; then 
            ENDSCRIPT=1
            break
        fi
    done
fi
if [ "$ENDSCRIPT" == "1" ] ; then
    echo "Current script '$SCRIPTNAME' already running (pid $RUNNINGPID) - stopping now"
    exit 1
fi
echo $PID > $PIDFILE

#now change the working directory to $WORKDIR
cd $WORKDIR

#check for presence of $IPFILE, and create it with default value of 0.0.0.0 if it's not there
if [ \! -f $IPFILE ] ; then
    echo "0.0.0.0" > $IPFILE
fi

#now - wait for the router to be available - the script won't make sense without the router responding
RETCODE=2
while [[ $RETCODE != 0 ]] ; do
        ping -c1 $ROUTERIP > /dev/null 2>&1 && sleep 2
        RETCODE=$?
done

#now that we know the router is available, check if there is also a connection to the internet. If not - wait for it. Again - the script does not make sense without... 
RETCODE=2
while [[ $RETCODE != 0 ]] ; do
        ping -c1 $CHECKURL > /dev/null 2>&1 && sleep 2
        RETCODE=$?
done

#now get the external (public) IP address of the router
EXTIP=$($EXTIPSCR)
OLDIP=$(cat $IPFILE)

if [[ "$EXTIP" != "$OLDIP" ]] ; then
    #looks like the external IP changed since we ran this script the last time.
    #the tracker needs to update / restart, so invoke $MAILSENDER with the fitting commands
    $MAILSENDER -t $MAIL2SMSGWADDR -f $SENDFROM -u "$MAIL2SMSSUBJECT" -m "$MAIL2SMSMAILBDY" -o message-charset=utf-8 $TLSOPTION -s "$MAILSRVR" -xu "$MAILUSER" -xp "$MAILPASS"
    #write the current IP into the temp file
    echo "$EXTIP" > $IPFILE	
fi


#clean up and delete the pidfile
rm $PIDFILE
exit 0
obelix8 years ago

forgot to mention: you might want to run the script every few minutes via crontab

(can't edit the previous post anymore, guess I confuesd the forum software a little bit gg)

Anduriño8 years ago

Try one thing ... just power cycle the router, not the tracker, and wait patiently. The tracker will wake automatically from sleep (not exactly every 24h) and then report the location to the "new" IP

obelix8 years ago

@Arturo: Misunderstanding... ;) The Tracker now works flawlessly, for some reason it did not when I tried first, but now it seems to report to whichever IP my dynamic hastname points at.

But since you asked for the script code to send a text message to the tracker whenever the external IP of the server changes, I hacked together some lines of bash code during my break ;)
It should work, but I did not test it since there is no need for it atm.

imarinkovic7 years ago

Hi guys...I'm facing the following problem with that device: Power Cut alarm and ignition detection not working...any idea?

Anduriño7 years ago
  • Red cable to +12V ("+"battery)
  • Black cable to ground ("-" battery)

and confirm your problem:

  • The 3 cable ACC (yellow or orange, depends your seller) to +12V/0V ignition key switch
imarinkovic7 years ago

Arturo, that's the way its supposed to work, but device seem to not sending nothing to server. Device just sends position data normally.