element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
In the Air Design Challenge
  • Challenges & Projects
  • Design Challenges
  • In the Air Design Challenge
  • More
  • Cancel
In the Air Design Challenge
Blog HAB monitoring Post#5 ( BBB to AirVantage using Python with REST API )
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: rmlab
  • Date Created: 24 Nov 2014 5:48 AM Date Created
  • Views 1006 views
  • Likes 2 likes
  • Comments 2 comments
  • iot_algal
  • python
  • rest
  • sierra_wireless
  • airvantage
  • in_the_air
  • xbee
  • cloud
  • bbb
  • BeagleBone
  • uart
  • iot
  • shield
  • beagleboard
  • arduino
  • iot_water
Related
Recommended

HAB monitoring Post#5 ( BBB to AirVantage using Python with REST API )

rmlab
rmlab
24 Nov 2014

This is a continuation of Post#4 , data received through UART in Beaglebone board is displayed in terminal. My problem the last time is that I can't send data to AirVantage using MQTT since my Beaglebone is behind university proxy. MQTT is using default port 1883 as reserved with IANA. To avoid this problem, I will be using REST API instead.

In this post, data will be sent to AirVantage using Python with REST API.

 

About AirVantage:

 

image

 

Sierra Wireless AirVantage M2M Cloud provides a seamless connection between devices, M2M cloud and the enterprise. Devices include Sierra wireless' modules and gateways but third party hardware like Beaglebone may be used instead which may communicate to AirVantage Cloud using standard protocols like MQTT and HTTP. AirVantage platform offers secure big data storage and management with good features like data and communication monitoring. Stored data may be retrieved and integrated with multiple backend systems, web and mobile application. All of this can be tried for six months with up to 5 connected devices through this link Sierra Wireless - AirVantage Enterprise Platform (AVEP)

 

Connecting Beaglebone to AirVantage Cloud with Python using REST:


Here are some guides on how to setup system on AirVantage:

1. Video Link: Building IoT Projects on the AirVantage M2M Cloud

2. To interface with AirVantage: Using REST API for devices

 

Command to access Beaglebone serial number:

# hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/0-0050/eeprom -s 16 -n 12 2>&1

 

After AirVantage setup is to write a code in Beaglebone for publishing data. You will need to install "requests" to use example code below:

# pip install requests

 

Edited version of post#4 Python code ( added sending data to AirVantage )

import serial
import time
from xbee import XBee
import json
import requests

serial_port = serial.Serial('/dev/ttyO2', 9600) #UART2 of Beaglebone
host = "https://na.airvantage.net"
url = "{}/device/messages".format( host )

def print_data(data):
  if 'source_addr' in data:
  hex_data = data['rf_data']
  sensor_data = map(ord, hex_data)
  doxy = sensor_data[1]
  data = [
  {
    "algal.doxy": [
      { "value" : doxy }
    ]
  },
  {
    "algal.threshold": [
      { "value" : "30" }
    ]
  }
  ]
  requests.post( url,
  auth=("XXXXXXXX", "1234"), #replace XXXXXXXX with Beaglebone serial number
  data=json.dumps(data),
  headers={'Content-type': 'application/json'}
  )
  print 'D.O. = %d'%sensor_data[1]

xbee = XBee(serial_port, callback = print_data)

while True:
  try:
      time.sleep(0.01)
  except KeyboardInterrupt:
      break

xbee.halt()
serial_port.close()

 

Run the python code in Beaglebone and monitor updates in AirVantage cloud.

image

 

Data History: D.O. chart for last 3 hours


image


Next post: Since I have already tested Beaglebone and AirVantage, I might shift my work on CC3200 and post my experience with it next week.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 10 years ago +1
    Good step by step approach. The Python code looks simple enough. Its on my todo list. Thanks DAB
  • amgalbu
    amgalbu over 10 years ago +1
    Nice post Thanks!
  • amgalbu
    amgalbu over 10 years ago

    Nice post

    Thanks!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 10 years ago

    Good step by step approach.

     

    The Python code looks simple enough.  Its on my todo list.

     

    Thanks

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube