RPMA Backhaul + Arduino Yun – Part 3

RPMA Backhaul + Arduino Yun – Part 3 © MIT

RPMA Backhaul + Arduino Yun – Part 3 of 3

  • 570 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

In the third and final part of this blog series, I’ll focus on building a parser to grab our data from Intellect and send it on up to AT&T’s M2X platform.

So now that our Arduino is pulling some measurements and sending them to a properly configured RPMA DevKit board (rACM), it’s time to pull that data out of Intellect and send it on to M2X. This part got pretty tricky for me, as it was my first real foray into Python. Plus, M2X is really picky about the data you feed it.

Our Starter Pack includes a handful of REST examples that you can use to read device data, send data downstream to a device from the cloud, and so on. The readmeConsole.txt doc is surprisingly helpful here. Read it! Our engineers have crafted a few parsers that work with M2X, but the serial example is limited to a single value. Since we’re sending two values in one string, we’ll have to split it up with a custom parser before sending it up to M2X. There are three files that we’re going to modify in our M2M_REST_Examples folder:  createDevices.py, parsers.py, and restm2x.py.

createDevices.py

First, let’s update createDevices.py with our device info and some API keys from M2X. You created an account on M2X, right? Open createDevices.py with the editor of your choice (I just use TextEdit.app on my Mac). You’ll likely be greeted by a bewildering array of various devices. Time to add ours to the mix! Delete all but one, which we’ll modify to meet our needs.

view raw createDevices.py_segment hosted with by GitHub

Make yours like mine. Your nodeId can be found by running that GET_DEVICE_STATUS command from Part 2, or peering at the top of your development board. It’s the many-digits-long value under MAC on the module sticker.

After creating an M2X account, you’re offered the chance to create a device. Make yours numerical! If it prompts you to create your first stream, name it temp_f and then name a second stream humidity. Then copy-paste Device ID and Primary API keys from M2X into createDevices.py. Save your changes and you’re done there. Take care throughout this whole process that your text editor doesn’t change apostrophes and quotation marks from straight-up-and-down marks to fancy curved open and close marks. TextEdit.app does this by default and it is absolutely maddening.

parsers.py

Next up we’ll need to add our new parser to parsers.py. I ended up modifying the existing Serial Uplink parser to handle an additional sensor, and it did the trick. The changes I made should be pretty self-explanatory. I’m not going to get into the different sensorIds and sensorTypes: they’re explained over in readmeConsole.txt. Go ahead and add the following code somewhere amongst the existing parsers and save the document.

view raw parsers.py_addition hosted with by GitHub

rest2m2x.py

Modifying rest2m2x.py was kind of a beast for me, but I’m going to put most of the blame on M2X for being such a stickler about the data it can process. I began the whole thing by modifying the existing serial example provided in the script. I’m absolutely sure that someone with more experience could have handled parsing the Arduino’s string into two separate numerical values more efficiently than I. Bear with me, please.

view raw rest2m2x.py_addition hosted with by GitHub

While this script is running, it pulls data from Intellect and parses data from our device, and then sends the data up to M2X. Since the Arduino is transmitting a text string with an underscore ‘_’ between the two values, we need to split the string up and send each value separately to M2X. Since M2X is particular about the sort of stuff we send over, I also have each string segment run through a filter that removes any hidden non-numerical characters, leaving the pure data behind. Then we send each value to separate M2X streams; in this case humidity and temp_f.

Running a Script, Parsing Data

We’re almost there! You have to update ATT_Devices.json by running the following command: ‘python createDevices.py’ which will populate ATT_Devices.json with your RPMA DevKit’s info. Now, if everything has been inputted correctly, you should be able to run rest2m2x.py and have your data kicked up into M2X. Log in to M2X and watch the data pour in!

That’s it! You’re done! What are you still doing here? Well, yes, I did learn a bunch of things from this exercise. Developing a sensor solution with RPMA connectivity in mind turns out to be super easy. Pair an Arduino or Raspberry Pi to one of our RPMA DevKits and you get a surprisingly potent proof of concept for your IoT application that doesn’t take a lot of technical know-how to get going. Request an RPMA DevKit below and start cracking!

Request an RPMA DevKit

Share This :

Tags :

RPMA Technology

Code

Gist
https://gist.github.com/maxgibbons/0c2aeb72e85c715cf08f5e88e4b12b2c.js
Gist
https://gist.github.com/maxgibbons/db3dd583a634e29611a1ab511ec19003.js
Gist
https://gist.github.com/maxgibbons/d0d91523132040083400ed6627a6d50a.js

Comments

Created by

Max Gibbons

Are you Max Gibbons? Claim this project and add it to your profile.

This is mine

Posted by

Default
Darrick Hatch
  • 0 projects
  • 0 followers

Additional contributors

  • Max Gibbons

Published on

April 14, 2017
See similar projects
you might like

Similar projects you might like

RPMA Backhaul + Arduino Yun – Part 1

by Max Gibbons

  • 640 views
  • 0 comments
  • 0 respects

RPMA Backhaul + Arduino Yun – Part 2

by Max Gibbons

  • 517 views
  • 0 comments
  • 0 respects

IoT Arduino YUN Ambient Sensor Adafruit I/O MQTT

Project tutorial by Giovanni Gentile

  • 2,277 views
  • 2 comments
  • 2 respects

Ultrasonic Map-Maker using an Arduino Yun

Project tutorial by Satyavrat Wagle

  • 63,501 views
  • 38 comments
  • 169 respects

Arduino Yun Controller

Project showcase by Team TATCO Inc

  • 3,703 views
  • 5 comments
  • 13 respects

Arduino YUN IoT for Home monitoring

by Rafa Juárez

  • 3,024 views
  • 1 comment
  • 2 respects
Add projectSign up / Login