Tiny PHP endpoint for collecting telemetry + GPS position from IoT devices,
originally used to receive Data to Server payloads from
Teltonika RUT955
industrial LTE routers.
index.php— acceptsPOSTrequests with a JSON body containing device telemetry (voltages, power, temperature, GSM data, GPS coordinates, AC plug state, device ID). Performs reverse geocoding via OpenStreetMap Nominatim to enrich the row with a human-readable address, then stores everything into a MySQL table.json.php— returns the latest measurement per device as JSON, suitable for a small dashboard or map view.
This code was extracted from a Teltonika RUT955 fleet tracking setup.
The router's "Data to Server" feature is configured to POST a JSON payload
to index.php at a regular interval (typically every 5-60 minutes).
Example payload sent by the router:
{
"V1": 43.49,
"V2": 40.32,
"POW": 92.00,
"TEMP": 22.50,
"R1": 0.00,
"GSM_DATA": "signal:-71dBm rsrp:-99 rsrq:-11",
"SERIAL_DATA_LATITUDE": 50.605344,
"LATITUDE": 50.605344,
"LONGITUDE": 4.335859,
"ACPLUG": 0,
"disc": "DISC03"
}Fields are freely customizable per the RUT955 Data to Server template.
- Database: run
schema.sqlon a MySQL 5.7+ / MariaDB 10.3+ instance. - Configure: copy
.env.exampleto.env(or export the variables in your web server config) and adjust:DB_HOST,DB_PORT,DB_NAME,DB_USER,DB_PASSWORD
- Deploy: drop
index.phpandjson.phpinto any PHP 7.4+ / 8.x capable webroot (Apache/nginx+PHP-FPM). Requires themysqliandcurlPHP extensions. - Configure your RUT955: in Services -> Data to Server, point a JSON collection at your server's URL. Set the format to raw JSON containing the fields shown above.
| Method | Path | Description |
|---|---|---|
| POST | /index.php |
Ingest a telemetry payload (returns OK on success) |
| GET | /json.php |
Returns the latest measurement per device (JSON array) |
index.php calls the free OpenStreetMap Nominatim service. Please respect
their usage policy:
- One request per second maximum
- Provide a valid User-Agent
- No heavy or bulk usage
For higher volumes, self-host Nominatim or use a paid geocoding service.
- The
check_discSQL view provided inschema.sqlreturns the latest row per device server-side.json.phpuses an equivalent inline join to remain self-contained. ADRESSEstores the enriched address returned by Nominatim.DISCis a free-form device identifier chosen at RUT955 configuration time (e.g.DISC03,VALISE07).
MIT