element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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 In The Air [IoT_Healthy] #Post 3: BBB/Pi to Airvantage via MQTT using Paho python client
  • 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: ravi_butani
  • Date Created: 8 Nov 2014 7:44 AM Date Created
  • Views 832 views
  • Likes 5 likes
  • Comments 4 comments
  • mqtt
  • m2m
  • airvantage
  • iot_healthy
  • in_the_air
  • raspberry-pi
  • texas_instruments
  • wurth_elektronik
Related
Recommended

In The Air [IoT_Healthy] #Post 3: BBB/Pi to Airvantage via MQTT using Paho python client

ravi_butani
ravi_butani
8 Nov 2014

Table of contents

<< Previous

Next >>


Introduction :

 

In this post I will provide Step by step guide for communicating your BBB/Pi with Airvantage over MQTT.

I have used Paho - Open Source messaging for M2M , this guide to install Paho Python MQTT Client on My Raspberry Pi B+. As have not received my BBB so far. I am very much sure that the same steps will also work with BBB.

 

DIY Guide :

 

Step1 : Setup System with MQTT Support on Airvantage M2M cloud..

 

I have used https://doc.airvantage.net/display/USERGUIDE/Using+MQTT+with+AirVantage this guide to setup System with MQTT Support on Airvantage Cloud.

 

Step2 : Test the system using MQTT Client..

I have used MQTTLens Google Chrome extension as easy to use MQTT Client for Test my system on Airvantage cloud from https://chrome.google.com/webstore/detail/mqttlens/hemojaaeigabkbcookmlgmdigohjobjm

 

here is screenshot of connection setup to Airvantage system on MQTTLens... Here username is system serial no and Password is system password...

image

image

First subscribe to <username>/messages/json topic then send json string with data....

image

 

here is screen shot of my System working on Airvantage cloud..

image

once airvabtage start responding to your MQTT pulish message then move to next step...

 

Step3 : install paho MQTT Python client on your Pi... from this guide http://www.eclipse.org/paho/clients/python/

once installed creat new python file with your system credential...

 

import paho.mqtt.client as paho




host="na.airvantage.net"
port=1883


def on_connect(pahoClient, obj, rc):
# Once connected, publish message
        print "Connected Code = %d"%(rc)
        client.publish("<username>/messages/json", "{\"machine.temperature\": 23.2, \"machine.humidity\": 70}", 0)




def on_log(pahoClient, obj, level, string):
        print string


def on_publish(pahoClient, packet, mid):
# Once published, disconnect
        print "Published"
        pahoClient.disconnect()


def on_disconnect(pahoClient, obj, rc):
        print "Disconnected"


# Create a client instance
client=paho.Client()


# Register callbacks
client.on_connect = on_connect
client.on_log = on_log
client.on_publish = on_publish
client.on_disconnnect = on_disconnect


#Set userid and password
client.username_pw_set(<userID>, <password>)


#connect
x = client.connect(host, port, 60)


client.loop_forever()

 

name this file say airvantage.py or any thing of ur choice..run this file by command

python airvantage.py

 

U will see update on Airvantage cloud with your latest data....

 

In next post I will explore Airvantage API and creat real time python appilication on RaspberryPi with external inputs ... and will show this data on Airvantage cloud...

  • Sign in to reply

Top Comments

  • fvan
    fvan over 11 years ago +1
    This will come in handy once I start with AirVantage! Thanks for sharing
  • tomaja
    tomaja over 11 years ago +1
    Well explained, Ravi. Will be useful to everyone! I hope you will get your kit soon
  • shabaz
    shabaz over 11 years ago

    Hey Ravi,

     

    Great post!!

    You might want to put a few sentences in the introduction on what Airvantage and MQTT is (just at a very high level for a newcomer), because this post deserves a lot of attention since it shows how to get started with a very useful cloud service, and is explained very well with nice screen-shots too.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • tomaja
    tomaja over 11 years ago

    Finally found the time to try this out (also using RPi). Your Python sample worked nice, thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • tomaja
    tomaja over 11 years ago

    Well explained, Ravi.

    Will be useful to everyone! I hope you will get your kit soon image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 11 years ago

    This will come in handy once I start with AirVantage! Thanks for sharing image

    • 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 © 2026 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