Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

arduino-nbiot-sdk

This is a SDK by AllThingsTalk that provides connectivity to their cloud through NB-IoT radios.

Hardware

This library has been developed for:

Installation

Download the source code and copy the content of the zip file to your arduino libraries folder (usually found at /libraries) or import the .zip file directly using the Arduino IDE.

Setting device credentials

You can either set them globally, using the same credentials for all sketches using the sdk.
Or you can set them locally in a specific sketch, overriding the global settings.

You can find these credentials under your device at AllThingsTalk in the SETTINGS > Authentication tab.

Depending on how you initialize the device object in your sketch, the global or local credentials will be used.

  • ATT_NBIOT device("your_device_id", "your_device_token"); will use the provided local credentials.
  • ATT_NBIOT device; will use the global credentials from the keys.h file

Open the keys.h file of the arduino-nbiot-sdk on your computer and enter your deviceid and devicetoken.

/****
 * Enter your AllThingsTalk device credentials below
 */
#ifndef KEYS_h
#define KEYS_h
const char* DEVICE_ID = "";
const char* DEVICE_TOKEN = "";
const char* APN = "starter.att.iot";
#endif

Payloads and sending data

There are three ways to send your data to AllThingsTalk

  • Standard json
  • Cbor payload
  • Binary payload

Standard json will send a single datapoint to a single asset. Both Cbor and Binary allow you to construct your own payload. The former is slightly larger in size, the latter requires a small decoding file (example) on the receiving end.

Single asset

Send a single datapoint to a single asset using the send(value, asset) functions. Value can be any primitive type integer, float, boolean or String. For example

ATT_NBIOT device;
  device.send(25, "counter");
  device.send(false, "motion");

Cbor

ATT_NBIOT device;
CborBuilder payload(device);  // Construct a payload object
  payload.reset();
  payload.map(1);  // Set number of datapoints in payload
  payload.addInteger(25, "counter");
  payload.send();

Binary payload

Using the AllThingsTalk ABCL language, you can send a binary string containing datapoints of multiple assets in a single message. The example below shows how you can easily construct and send your own custom payload.

Make sure you set the correct decoding file at AllThingsTalk. Please check our documentation and the included experiments for examples.

ATT_NBIOT device;
PayloadBuilder payload(device);  // Construct a payload object
  payload.reset();
  payload.addInteger(25);
  payload.addNumber(false);
  payload.addNumber(3.1415926);
  payload.send();

Examples

Basic example showing all fundamental parts to set up a working example. Send data from the device, over NB-IoT to AllThingsTalk.

  • counter This example shows how you can send over a simple integer counter using either json, cbor or a binary payload.

Simply uncomment your selected method for sending data at the top of the sketch.

// Uncomment your selected method for sending data
#define JSON
//#define CBOR
//#define BINARY

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published