geoloc-cellules.ino
Without GPS, the radio cell is often enough: the MKR NB 1500 reads its TAC, cell identity and signal level, then ships them to a cell-based geolocation service. Ideal for tracking a stationary asset or validating coverage.
Hardware
An Arduino MKR NB 1500 (SAMD21 microcontroller, u-blox LTE-M/NB-IoT modem, external antenna, LiPo power on J6 or USB). IoT SIM registered on the network, antenna; a free OpenCelliD account for the conversion step.
Wiring
No wiring; runs as a bare board, in slow motion (pedestrian, container).
How it works
CEREG exposes the Tracking Area Code and CellIdentity of the serving cell; CESQ details RSRP/RSRQ. These pairs match the keys of cellular tower databases.
Running it
Install the Arduino SAMD Boards package and the MKRNB library, select the board, upload. Plan for an activated IoT SIM (LTE-M or NB1) and good reception: attaching to the network can take several minutes.
Variants
Add a neighbour-cell scan (CEREG option 2) to refine the fix, or fit a small I2C GPS when accuracy becomes critical.
geoloc-cellules.ino
// Geolocalisation par cellule : LAC/CI + RSSI via le modem SARA-R4.
// Utile quand le GPS n'est pas alimente/couvert : precision 100 m - km.
#include <MKRNB.h>
const char PIN_SIM[] = "0000";
NB nb;
void setup() {
Serial.begin(9600);
while (!Serial);
if (nb.begin(PIN_SIM) != NB_READY) while (true);
while (nb.getStatus() != NETWORK_JOINED) delay(2000);
}
void loop() {
// Le core MKRNB expose l'operateur ; les infos fines de cellule
// passent par les commandes AT dediees du SARA-R4 :
nb.sendCheckConfig("COPS?"); // operateur + MCC/MNC
nb.sendCheckConfig("CEREG?"); // LAC/TAC + CellId enregistree
nb.sendCheckConfig("CESQ?"); // RSSI/RSRP detailles
// CEREG renvoie par ex : +CEREG: 0,1,"812F","0A3B5C2",7
// -> TAC 0x812F, CellID 0x0A3B5C2, niveau 7
// Transmettez ce couple a un service de localisation par cellules
// (OpenCelliD, Google Geolocation) pour obtenir lat/lon.
Serial.print(F("RSSI module : "));
Serial.println(nb.signalQuality());
delay(300000); // un point toutes les 5 min
}