Markus Tacker
Senior R&D Engineer
Nordic Semiconductor
Markus.Tacker@NordicSemi.no
Twitter: @coderbyheart
Typical IoT Data Protocol Configuration
Because the latest state should be immediately visible: buffer data in a Digital Twin.
Cellular IoT devices need to send data about past events: they will be offline most of the time.
{
"v": {
"lng": 10.414394,
"lat": 63.430588,
"acc": 17.127758,
"alt": 221.639832,
"spd": 0.320966,
"hdg": 0
},
"ts": 1566042672382
}
“default” data protocol for IoT (AWS, Azure, Google Cloud)
👍 human readable
👍 schema-less (self-describing)
👎 overhead
GPS location message
02 36 01 37 51 4b 73 2b
d4 24 40 09 68 06 f1 81
1d b7 4f 40 11 68 cd 8f
bf b4 20 31 40 19 e6 5d
f5 80 79 b4 6b 40 21 1a
30 48 fa b4 8a d4 3f 29
00 00 00 00 00 00 00 00
09 00 e0 cf ac f6 c9 76
42
JSON
114 bytes
without newlines
Protocol Buffers
65 bytes (-42%)
source
GPS location message
A2 61 76 A6 63 6C 6E 67
FB 40 24 D4 2B 73 4B 51
37 63 6C 61 74 FB 40 4F
B7 1D 81 F1 06 68 63 61
63 63 FB 40 31 20 B4 BF
8F CD 68 63 61 6C 74 FB
40 6B B4 79 80 F5 5D E6
63 73 70 64 FB 3F D4 8A
B4 FA 48 30 1A 63 68 64
67 00 62 74 73 1B 00 00
01 6C 9F 6A CC FE
JSON
114 bytes
without newlines
CBOR
86 bytes (-24%)
source
Look into denser data protocols!
JSON is for Humans.
common protocol for “ecommerce” cloud vendors
(AWS, Azure, Google Cloud)
Use AT%XCONNSTAT=1
to tell the modem to start collecting connectivity statistics
Use AT%XCONNSTAT?
to read the current connectivity statistics
static struct k_delayed_work connstat_work;
static int query_modem(const char *cmd, char *buf, size_t buf_len) { ... }
static void connstat_work_fn(struct k_work *work)
{
query_modem("AT%XCONNSTAT?", connStatBuffer, sizeof(connStatBuffer));
// NOTE: k_uptime_get_32() cannot hold a system uptime time
// larger than approximately 50 days
printk("Connection stats: %s | Uptime: %d seconds\n",
connStatBuffer, k_uptime_get_32() / 1000);
// Schedule next run
k_delayed_work_submit(&connstat_work, K_SECONDS(60));
}
k_delayed_work_init(&connstat_work, connstat_work_fn);
k_delayed_work_submit(&connstat_work, K_SECONDS(60));
You can see a full diff of how I added this to one of my applications here.
Connection stats: %XCONNSTAT: 0,0,14,16,748,134 | Uptime: 5041 seconds
%XCONNSTAT: <SMS Tx>,<SMS Rx>,<Data Tx>,<Data Rx>,<Packet max>,<Packet average>
Do not use the connectivity statistics in applications which use the LwM2M carrier library.
This library manages the collection of connectivity statistics and will turn them on and off on its behalf. If your application interferes with this statistics collection it will result in incorrect measurements in the carrier’s device management solution.
for medium throughput applications requiring low power, low latency and/or mobility
for static, low throughput applications requiring low power and long range
Carl Richard Fosse
“Power Consumption modeling of TCP and UDP over low power cellular networks for a constrained device”
Hardware: nRF9160DK v0.8.5
SDK: v1.2.0
Measurement unit: Otii ARC
Network provider: Telenor LTE-M and NB-IoT
Power measurement setup will be more thoroughly covered in our webinar the 9th of December.
Connection
RRC inactive timer
Reception quality
Additional parameters - see the Online Power Profiler
rather than small amounts often.
Please share your feedback!
Latest version: bit.ly/nwiotp