I recently attended a developer program put on by AT&T for their M2X Data Service, which is a cloud based time series data system. The course was pretty handy and I'd recommend it to anyone working in the IOT sphere. The course covered the basics of using a M2X connected device, and I'd like to devote this blog post to my first attempt at using M2X to create a simple, real-time data plot that can be displayed here on my website. So first things first (I hate this part)- you will need to sign up for yet another online account. Click here to create a M2X account: https://m2x.att.com/signup Once you have an M2X account, you will need to set up a device on your new account. 1: From the "Setup your Device" page choose "Device" (as opposed to "Virtual Device"). 2: You will then be guided through the (hopefully straight forward) steps to set up your device. 3: Once you have your device set up, you will be given a unique Device ID and API key associated with your device. You will need these two items for setting up your Arduino sketch later. 4. Next you will need to set up a "stream", which allows for a series of time stamped data points routed through the MX2 cloud. Scroll down to the bottom of the device page and hit the "Add Stream" button. Follow the steps to set up your stream. 5. Once you have a stream, we can now start pushing our data around. But to easily publish the real-time data onto a personal website, the last thing you will need to do is to set up a widget (found under the dashboard tab). Once you attach your stream to a widget, you will be given a link (a few lines of html code) that you can paste into a website allowing for a real-time plot of your data stream. The dev program course used the Texas Instruments Launch Pad dev board. I liked the Launch Pad hardware itself, but the Launch Pad uses an IDE called Energia which looks exactly like the Arduino IDE....... except it's a red colored background (as opposed to Arduino's blue). But the two IDE's use completely different libraries, so unless I hear some compelling evidence to switch over, I'm going to stick with the Arduino hardware. Plus M2X has a few pre-written code files for Arduino, so I'll be ditching the launch pad and port over what I learned in the class to my ESP8266. For this project I've chosen to monitor the temperature in a climate controlled room, and luckily for me M2X has a good Arduino code for doing this. But first you will need to download the M2X library for Arudino from GitHub. https://github.com/attm2x/m2x-arduino I've attached the code I used for the ESP board. The code itself is almost entirely lifted from the M2X example, I just changed a few things to work with the 3.3volt logic of the ESP.
I've used a rudimentary TMP35 temp sensor for this project. Left Leg -> 3.3v Right Leg -> GND Center Leg -> AO So the hardware setup is pretty simple. But the TMP35 sensor I'm using is cheap and I don't have a lot of faith in it's accuracy. So I wouldn't use it for anything you really cared about. Once you have the sketch loaded onto your board, it should connect to your M2X stream and start sending data to your website. Granted, as of now I don't see a lot of options for customizeability of the of the data (playing around with x and y axis, graphical parameters, cleaning data and removing outliers, ect). But what you gain in ease of use, you often loose in the ability to tailor to your needs. Though there are few parameters you can customize by changing the actual code behind the widget. For my plot I chose to specify a start time, as well as expanding the window of data displayed (the default is only 100 points of data). You can find directions on how to change these parameters here:
https://m2x.att.com/developer/documentation/v2/widgets All in all, it's a pretty easy and straight forward way to hop on board the IOT train and play with your data. I will update this blog as I find more ways to customize and play with this data stream. Next post- setting up a trigger to alert me when certain conditions are met.
1 Comment
|
AuthorAn electronics enthusiast looking for a place to gather his thoughts, ideas, diagrams, and code Archives
October 2016
Categories |