Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

SIM800L problem again, sending location via SMS

Status
Not open for further replies.

fezder

Well-Known Member
Hey people, this time I have problem with this scenario:
I'm making an location tracker for my brother's motorbike, surely you know how wanted stuff those can be.
Idea is simple; when module is called on, it sends location data (google map would be awesome, but that should be done easily after getting raw data) via text message to number that is pre-set on code (so it doesn't send message to whoever calls it, only number that has been set on.
Trouble currecntly is that location data is also asked from SIM800 with AT commands, so that must be asked BEFORE entering SMS-state (all data that is written after switching to sms is sent in that message)
I thinked that solution would be that location data is first asked->save data (as string) to array->send that location data via SMS.
currently working code that I can use to send normal , simple data like millis, temperature, you get the idea:
I think that issuea is that I understand string bit wrong...
C:
#include <SoftwareSerial.h>
SoftwareSerial SIM800(10, 11); // RX, TX
String a;
String b;


void setup()
{
  Serial.begin(9600);  //harware serial, debugging purposes
  SIM800.begin(9600);  //SIM800 module, for sending AT-commands
  SIM800.print("ATE0\r\n"); //echo off
}




void loop()
{
  a = SIM800.readString();  //data from SIM800
  if (a == "\r\nRING\r\n")
  {
  SIM800.print("AT+CMGF=1\r\n"); // Set the shield to SMS mode
  SIM800.print("AT+CMGS=\"**********\"\r\n");
  delay(200);
  SIM800.print(millis()); //here is what data is to be sent
  //SIM800.print((String)
  SIM800.print("\r\n");
  delay(500);
  SIM800.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)
  delay(100);
  SIM800.print("\r\n");
  }
}
 
Nigel, SIM800 can give coordinates as location data, here's procedure for it:
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","your apn here"
AT+SAPBR=1,1
AT+CIPGSMLOC=1,1 (this command gives location codes, response is string of text containing lon-lat as well as date stamp. True GPS would be better of course since it would give speed also. I do have external GPS module, well actually shield)
That thing you linked looks neat, thanks for it.
The reason I decided to use SIM800 over pre-made models is that SIM800 can be programmed to do anything with arduino, so learning it's use would be benefitical for many automation applications, if there is no WLAN available (yes, esp8266 is on-learn list also.....)
 
Nigel, SIM800 can give coordinates as location data, here's procedure for it:
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","your apn here"
AT+SAPBR=1,1
AT+CIPGSMLOC=1,1 (this command gives location codes, response is string of text containing lon-lat as well as date stamp. True GPS would be better of course since it would give speed also. I do have external GPS module, well actually shield)

Presumably you are aware that the 'location' data using that method is EXTREMELY inaccurate?, and bears no resemblance to where you might be. I don't see much use in a 'tracker' that gives location data that could be kilometres away :eek:

That thing you linked looks neat, thanks for it.
The reason I decided to use SIM800 over pre-made models is that SIM800 can be programmed to do anything with arduino, so learning it's use would be benefitical for many automation applications, if there is no WLAN available (yes, esp8266 is on-learn list also.....)

I've ordered three of these to play with:

https://www.banggood.com/GSM-GPRS-S...SMS-Module-DIY-Kit-For-Arduino-p-1043437.html

Basically because they are so cheap and small - you can also find even smaller ones on AliExpress.

My previous GSM project used a Wavecom chip, a WISM0218.
 
What? Well that makes sense then why location is indeed quite a lot off, didn't know that.....bugger! Sometimes It's pinpoint accurate (luck probadly) and sometimes about hundred meters but I thought It's because I test it indoors.
I'll try to play with external GPS module, thanks for info.
I did make some progress, althought this progress is in "vain" now that you mentioned inaccurateness (<-is that even word?) of GPRS location method (no location data, but live data still directly from SIM800, signal quality):
C:
#include <SoftwareSerial.h>
SoftwareSerial SIM800(10, 11); // RX, TX
String a;
String b;


void setup()
{
  Serial.begin(9600);  //harware serial
  SIM800.begin(9600);  //bluetooth module, for sending AT-commands
  SIM800.print("ATZ\r\n");
  SIM800.print("ATE0\r\n");
}




void loop()
{
  if (SIM800.available())
  {
  a = SIM800.readString();  //data from bluetooth
  SIM800.print("AT+CSQ\r\n");
  if (a.indexOf("+CSQ") > 0)
  {
  b = SIM800.readString();
  }


  if (a == "\r\nRING\r\n")
  {
  SIM800.print("AT+CMGF=1\r"); // Set the shield to SMS mode
  SIM800.print("AT+CMGS=\"*\"\r\n");
  delay(200);
  SIM800.print(b); //kunhan jotain dataa
  SIM800.print("\r\n");
  delay(500);
  SIM800.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)
  delay(100);
  SIM800.print("\r\n");
  }
  }
}
Thanks for help Nigel!
 
What? Well that makes sense then why location is indeed quite a lot off, didn't know that.....bugger! Sometimes It's pinpoint accurate (luck probadly) and sometimes about hundred meters but I thought It's because I test it indoors.
I'll try to play with external GPS module, thanks for info.
I did make some progress, althought this progress is in "vain" now that you mentioned inaccurateness (<-is that even word?) of GPRS location method (no location data, but live data still directly from SIM800, signal quality):

As there's no way it can know your location, it's just a 'wild guess' based on signal stength and triangulation (where you can receive 3 or more cell towers).

If you can only receive one (common round here), the best it can do is tell you the location of the cell tower.
 
Nigel, I'm quite sure issue was begin with that I confused this SIM800 module with SIM808 that does have GPS built-in:
https://www.adafruit.com/products/2637

I've just ordered one of the trackers from Bangood, just to have a play with - I've been 'dithering' about oredring one for the last week or two :D

If you look on the Bangood website, and enter GSM in the search box, there are a good number of different options, including many non-GPS 'trackers' - which get absolutely destroyed in the customer comments section (and most have labels on saying GPS as well!).
 
Some cheap phones use the towers but it's useless and too slow GPS is only way to go I have a tablet that uses towers to tell where it is its been off 100 miles or more if you don't just set it in one place and leave it my s7 could hit a Nats butt but even GPS needs fast cpu to be dead on.
That's if the bike is moving.
 
OK pounder this then I'm driving 35 miles and hour my GPS with a 8 core cpu can tell me where I'm at at any point in time.
But the slower one can't keep up with where you are at and they both have same GPS module in them
I'm sure faster is better we use GPS tracking in are work vans the older slower hardware from same maker same module just slower cpu places the vans at the wrong place but the faster newer ones you see the van move in real time
 
Last edited:
OK pounder this then I'm driving 35 miles and hour my GPS with a 8 core cpu can tell me where I'm at at any point in time.
But the slower one can't keep up with where you are at and they both have same GPS module in them
I'm sure faster is better we use GPS tracking in are work vans the older slower hardware from same maker same module just slower cpu places the vans at the wrong place but the faster newer ones you see the van move in real time

I doubt it's anything to do with processor speed, the location data comes from the GPS module and isn't anything to do with the processor speed.

How is your data transferred?, presumably not via SMS text messages?.
 
Nigel, I'm quite sure issue was begin with that I confused this SIM800 module with SIM808 that does have GPS built-in:
https://www.adafruit.com/products/2637

See Adafruit do a complete Sim808 module but its quiet expensive if you add on all their extras.

Apart from them, seems its only Ebay /Far East sellers doing it at the moment though some of the Ebay ones are complete with encased Antenna.
Seems as well as a GPS module it also does Bluetooth.
This bare module only e25 delivered
https://www.electrodragon.com/product/sim808-dev-board-gsmgprsgps-replacing-sim908/#prettyPhoto

A fair bit of info already around for it.
https://wiki.iteadstudio.com/SIM808_GSM/GPRS/GPS_Module

Think I would get a sim808 to complete the project properly rather than rely on gsm towers.
 
The data is sent on G3 network the older ones used G2 and can't send fast enough to track you in real time. It would be a simple matter to use a newer cheap cell phone that's on LTE light It has everything you need to track a car or bike and you can get a good fast one for less then $40 some times less then $20 at most
 
The data is sent on G3 network the older ones used G2 and can't send fast enough to track you in real time. It would be a simple matter to use a newer cheap cell phone that's on LTE light It has everything you need to track a car or bike and you can get a good fast one for less then $40 some times less then $20 at most

How much data does it need to send?, longitude and latitude isn't much at all.

It sounds more likely the problem is the network, with 2G far too slow to do the data, and nothing to do with the processor.

Just did a quick google - 2G is only a MAXIMUM of 40kbps :eek:

3G isn't as clear cut though, with varying specs, all MUCH faster than 2G though.
 
Think Fezder need to let us know if he means real time journey tracking or when the bike is stopped, eg parked, stolen, accident etc.

If in real time can it be practical with a typical sim card, surely it would run out quickly or are there some better deals on 2G sims these days.

Think fitting an angular sensor would also be good, to indicate if the bike was on its side.
 
Currently lon/lat would be enough, last time I chekced location was off about 100m, adafruits GPS shield even more, several tens kilometers, which is odd.
Real-time would be great, say 5 minutes or 10 minutes update rate, maybe activated if bike is started before pressing button or some other automated process
 
Currently lon/lat would be enough, last time I chekced location was off about 100m, adafruits GPS shield even more, several tens kilometers, which is odd.
Real-time would be great, say 5 minutes or 10 minutes update rate, maybe activated if bike is started before pressing button or some other automated process

According to the research I did earlier, 100m is classed as very accurate for non-GPS GSM tracking, did you try it over a wide range of locations?.

'Real time' wouldn't be 5/10 minutes, but continuous - and of course for SMS 5/10 minute updates you need to ensure the card has enough credit on it.

You also need to be aware that SIM cards are deleted if they don't connect occasionally, so you need to arrange for the GSM modem to 'wake up' and connect to the network every now and again. In my previous project the time was adjustable, by sending a text message to the modem during it's initialisation period - as I recall once a month is probably plenty (I also took the opportunity to send the battery voltage as well, plus how many texts had been sent it total).
 
Last edited:
You also need to be aware that SIM cards are deleted if they don't connect occasionally, so you need to arrange for the GSM modem to 'wake up' and connect to the network every now and again
Never knew that either. As for credit issue, it's monthly fee of 3.3€/month+usage. I'll see if I can source proper GPS's somewhere, to counter accuracy....thanks for those links Nigel!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top