Arduino M2X API Client


The Arduino library is used to send/receive data to/from AT&T's M2X service from Arduino based devices.

NOTE: Unless stated otherwise, the following instructions are specific to Arduino Uno board. If you are using other boards, the exact steps may vary. Arduino LilyPad and Arduino Redboard have specific tutorials.

Getting Started

  1. 1 Obtain your Master Key from the Master Keys tab of your Account Settings screen.
  2. 2 Create your first Device and copy its Device ID.
  3. 3 Review the M2X API Documentation.
  4. 4 Obtain an Arduino with built in wifi or ethernet, or a separate wifi or ethernet shield and set it up. This docs were written for an Arduino Uno with a wifi or ethernet shield but the instructions can be adapted for other Arduino models.

How to Install the Library

This library depends on jsonlite, the installation steps are as follows:

1. Clone the repository and sync submodules

$ git clone
$ git submodule update --init

NOTE:You might notice that we add jsonlite as a submodule, this is due to the fact that we are still using an older version of jsonlite now. We might remove this restriction once we migrate to latest version.

2. Open the Arduino IDE, click Sketch->Import Library...->Add Library..., then navigate to vendor/jsonlite/amalgamated/jsonlite folder in the cloned jsonlite repository. The jsonlite library will be imported to Arduino this way.

NOTE: If you cloned the jsonlite library, there will be 3 folders named jsonlite:

  • vendor/jsonlite: the repo folder
  • vendor/jsonlite/jsonlite: the un-flattened jsonlite source folder
  • vendor/jsonlite/amalgamated/jsonlite: the flattened jsonlite source for arduino

The last one here should be the one to use, the first 2 won't work!

3. Use the instructions outlined in Step 2 above to import the M2XStreamClient library in the current folder.

4. Now you can find M2X examples under File->Examples->M2XStreamClient

Board Setup

The Arduino website has a very good tutorial on setting up the Arduino board. It contains detailed instructions on how to install the Arduino IDE, sets up your board for initial testing. Feel free to proceed to the Arduino site to get a basic idea on Arduino.

Wifi/Ethernet Shield Setup

If you are using an Arduino Yun board instead of an Arduino Uno board, you can skip this section since the Yun board already has Wifi adapter on board.

To send data to the AT&T M2X service, or receive data from the AT&T M2X service, your Arduino board needs a connection to the Internet. Hence an Arduino Wifi Shield or Ethernet Shield is needed to give your board the power to connect to the Internet. To install the shield, hook the shield on your Arduino board — you can use the pins on the shield the same way as the real pins on the Arduino boards.