Cell Locate - Example Sketch


#1

Here’s a quick sketch I pulled together for the NEW Cell Locate API. It finds the physical location of a Dash (longitude and latitude, + altitude) based on cell tower data. It’s pretty awesome – activates / locates quickly, and found my location to within 2,500 ft on a very weak cell signal (RSSI = 9). Here’s the code – feel free to criticize / optimize / legitimize / right-size / Simonize.

/* Dash Cell Locate Example.
*  Uses cell tower data to estimate physical location of Dash unit.
*/

int alt;
String LAT;
String LON;
int UNCERTAINTY;

void setup() {
  Serial.begin(9600);
  HologramCloud.attachHandlerLocation(my_location_handler);
  HologramCloud.connect(true);   // Data connection needed for Cell Locate to function.
  delay(10000); // Give your system 10 seconds to find a celltower and connect.
  
}


void loop(){

HologramCloud.getLocation(500,30);
Serial.print("Connection Status = "); Serial.println(HologramCloud.getConnectionStatus());
Serial.print("altitude = "); Serial.println(alt);
Serial.print("latitude = "); Serial.println(LAT);
Serial.print("longitude = "); Serial.println(LON);
Serial.print("Uncertainty = "); Serial.println(UNCERTAINTY);
delay(10000);
  
}


void my_location_handler(const rtc_datetime_t &timestamp, const String &lat, const String &lon, int altitude, int uncertainty) {
   alt = altitude; //take action on the location data
   LAT = lat;
   LON = lon;
   UNCERTAINTY = uncertainty;
}

#2

Thanks for sharing this. :sunglasses:


#3

You are very welcome indeed, and I certainly owed you one after your awesome remote start sketch.

I was pretty amazed at how well the cell locate function works – definitely well enough to be able to used as a “poor man’s asset tracker” – where is my truck, trailer, luggage, etc. to the nearest half-mile or so. Not exactly geo-cache level stuff, but it has the huge advantage of not needing to see the GPS satellites / install a GPS antenna.


#4

And it works in places where a GPS won’t like in a building or parking garage.


#5

I have found similar accuracy with the getLocation() feature. The documentation states that the default requested accuracy is 10 meters. I have not been able to get anywhere close to that even in a downtown metropolitan area.

My signal strength is usually in the 20s.

So I have the following questions:
Does this work as intended, when the accuracy is on the order of 100s to 1000s of meters even in densely populated areas?
Can the accuracy be improved with a better antenna?


#6

The cell locate feature works in conjunction with a database that UBlox maintains and it’s possible that this database doesn’t have solid data for your area. We’ll reach out to them about how to go about submitting issues and getting the results improved.


#7

DASH is getting UNCERTAINTY 300++ meters deviation even if at default 10m accuracy setting.

Signal strength registered by the board is for 1 cell tower only… Cellsite triangulation needs at least 3 towers, and location is computed based on the distance and signal strength of each tower.

Aside from UBlox Cell locate, I’m also using the services of OpenCellID. Execute Ublox’ AT+UCELLINFO commands and you’ll see details of all cell towers that your board can detect. Feed the details to the OpenCellID and see if result is more useful in your usecase.

Comparing these two methods, I find the DASH getLocation method always returning the same location. It’s either the result is cached in Ublox server… or their celltower database is not as robust.

In the case of OpenCellID, if you do a very good data algorithm on the results of AT+UCELLINFO for a 7-day period, you can derive a distance variation of <10 meters from 10++ cell towers for a fixed-position device.

OpenCellID has an API (free use) which makes it all programatically possible to do everything in the server side.


#8

Matches what I’m seeing.