AT&T M2X Electric Imp Library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
lib
.gitignore
CONTRIBUTING.md
LICENSE
README.md

README.md

Electric Imp M2X API Client

The Electric Imp client library is used to send/receive data to/from AT&T's M2X service from an Electric Imp agent.

If you are new to the Electric Imp platform, it's recommended that you work through the Getting Started Guide.

Getting Started with M2X and Electric Imp

  1. Signup for an M2X Account.
  2. Obtain your Master Key from the Master Keys tab of your Account Settings screen.
  3. Create your first Device and copy its Device ID.
  4. Review the M2X API Documentation.
  5. Obtain an Electric Imp.

Please consult the M2X glossary if you have questions about any M2X specific terms.

How to use the library

  1. Log into the Electric Imp IDE.
  2. Create a New Model for your project, and assign your device to it.
  3. Copy the M2XDevice class to the top of your agent code.
  4. Create a Device object:
    device <- M2XDevice("_Master Key_", "_Device ID_");
  1. Post data to a Stream in the Device:
    device.updateStreamValue("device ID", "stream_name", value);
  1. Read data from a Device:
    streams <- device.listStreams("device ID");
    // look for a particular stream
    foreach(stream in streams.streams) {
        if (stream.name == "stream_name") {
            // do something
        }
    }

How to Build the Example

The provided example is based on the TempBug Instructable

  1. Create a New Model (we called ours M2X TempBug)
  2. Create the following circuit with a 10KΩ resistor, and a 10KΩ NTC thermistor: Example Circuit
  3. Copy thermistor-tempbug.device.nut to the device code window.
  4. Copy tempbug-m2x.agent.nut to the agent window.
  5. Hit "Build and Run"

Your Imp should start reporting the current temperature to M2X every 15 minutes.

LICENSE

The code and images in this repository are released under the MIT license. See LICENSE for the terms.