Getting Cellular Data Usage for Boron

I’m running into problems with getting cellular data usage for the Boron. I’ve written the following example application:

// Logging
SerialLogHandler logHandler(LOG_LEVEL_ALL);

// Particle system stuff
SYSTEM_THREAD(ENABLED);

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    uint32_t freeMem = System.freeMemory();
    Log.info("Free memory: %ld", freeMem);

    if (Cellular.ready())
    {
        CellularData data;
        if (!Cellular.getDataUsage(data))
        {
            Log.error("Error! Not able to get data.");
        }
        else
        {
            Log.info("CID: %d SESSION TX: %d RX: %d TOTAL TX: %d RX: %d",
                     data.cid,
                     data.tx_session, data.rx_session,
                     data.tx_total, data.rx_total);
            Serial.println(data); // Printable
        }

        CellularSignal sig = Cellular.RSSI();
        Log.info("Cell quality: %d (%d)\n", sig.qual, sig.rssi);
    }
    else
    {
        Log.info("Cell not ready yet...\n");
    }

    delay(5000);
}

getDataUsage always returns an error. I get the following output:

0000116280 [app] INFO: Free memory: 64200
0000116281 [app] ERROR: Error! Not able to get data.
0000116428 [app] INFO: Cell quality: 31 (27)

0000121429 [app] INFO: Free memory: 64200
0000121431 [app] ERROR: Error! Not able to get data.
0000121578 [app] INFO: Cell quality: 31 (27)

I haven’t been able to get any data from Cellular.getDataUsage. Am I missing something?

me too,
¿did you solve it?

I can’t help with Cellular.getDataUsage , but you can check the daily usage through the Web API

[copy/paste from another thread]

You can easily track daily cellular data with:
https://api.particle.io/v1/sims/XXXX/data_usage?access_token=YYYY
Where:
XXXX= Electron’s ICCID (go to Console.particle.io , View Device)
YYYY = Personal Access Token (go to Build.particle.io, Settings)

Bookmark the link once you add your credentials and you can check daily usage quickly.

1 Like

Nice one.

Does this work for the Boron LTE devices?

The u-blox SARA-R410M-02B modem in the Boron LTE, E Series LTE, and Electron LTE does not support the commands used to implement getDataUsage and setDataUsage so they do not work on LTE devices. This is missing in the docs; I’ll add it next week.

1 Like

How about the Boron 2G/3G? That’s the board that I’m having troubles with. I’m on DeviceOS v1.2.1 so I’m hoping v1.4.0 fixes this issue. I haven’t had a chance to try it yet.