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 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 In the Air Design Challenge - Pollen & Allergen Sensing – Post 2
  • 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: tomaja
  • Date Created: 21 Nov 2014 12:32 AM Date Created
  • Views 570 views
  • Likes 1 like
  • Comments 0 comments
  • iot_pollen
  • in_the_air
Related
Recommended

In the Air Design Challenge - Pollen & Allergen Sensing – Post 2

tomaja
tomaja
21 Nov 2014

Previous posts:

In the Air Design Challenge - Pollen & Allergen Sensing

In the Air Design Challenge - Pollen & Allergen Sensing – Post 1 (Pollen Sensor)

 

Introduction

Since I had problem with customs and still waiting for my kits (Christian is very helpful and hopefully we will sort it out soon) I decided to spend some time in preparing software part of my project, both BeagleBone Black and remote clients.

 

Development platform

In order to make one code base that will run on multiple platforms (desktop and mobile) I decided to use Qt | Cross-platform application & UI development framework. Qt framework is packed with features that make life easier for developers. I have some experience with Qt but not too much so this will also be a fun way to get more into the Qt framework and development tools.

As we got free AirVantage MQTT access, I decided to use the C version of open source Paho MQTT library (Paho - Open Source messaging for M2M). This library provides versions for use in many popular programming languages (Java, C/C++, Python, Go, JavaScript and C#). There’s also a version called C(Embedded) suitable for microcontrollers if you plan to publish data from a LaunchPad or if you plan to send some commands directly to it (via subscription).

Additionally, I chose to use the AnalogWidgets library for Qt (nice gauges design in my opinion).

image

This library provides some nice gauges that can easily be customized for my project. I will use it for both apps (clients and BBB dashboard).

 

BeagleBone Black

BeagleBone Black will serve as a central house unit that’s responsible for communication with AirVantage cloud service and on the other side for communication with CC3200 LaunchPad. It will also serve as a system dashboard – I ordered a 4.3” resistive touchscreen for BeagleBone Black to be used for that role. There are tutorials and even YouTube videos on Qt development for BeagleBone black so I will just provide some links:

  • https://www.youtube.com/watch?v=eLr35wUrz6Q
  • https://www.youtube.com/watch?v=QmJlHJ1REbM
  • Tutorial: Creating Qt-Embedded Projects for Beaglebone with Visual Studio

Project specific code is the part that’s in charge of MQTT publishing and here’s how it looks like. It’s pretty much out-of-the-box example with a small addition to connection options – username and password must be provided for AirVantage. Additionaly QoS parameter had to be set to 0 for data to be published successfully.

 

Code:

#define ADDRESS  "tcp://na.airvantage.net:1883"
#define CLIENTID  "BBB_Client"
#define TOPIC  "123456789/messages/json"
#define TOPICSUB  "123456789/tasks/json"
#define PAYLOAD  "{\"machine.temperature\":39.2, \"machine.humidity\":86, \"machine.pollen\":3 }"
#define QOS  0#define TIMEOUT  10000L

QTTClient client;
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
MQTTClient_message pubmsg = MQTTClient_message_initializer;
MQTTClient_deliveryToken token;
int rc;

MQTTClient_create(&client, ADDRESS, CLIENTID, MQTTCLIENT_PERSISTENCE_NONE, NULL);

conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.username = "123456789";
conn_opts.password = "supersecret";
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
      printf("Failed to connect, return code %d\n", rc);
}

pubmsg.payload = (void*)PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
pubmsg.qos = QOS;
pubmsg.retained = 0;

MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);
printf("Waiting for up to %d seconds for publication of %s\n on topic %s for client with ClientID: %s\n", (int)(TIMEOUT/1000), PAYLOAD, TOPIC, CLIENTID);

rc = MQTTClient_waitForCompletion(client, token, TIMEOUT);
printf("Message with delivery token %d delivered\n", token);

MQTTClient_disconnect(client, 10000);
MQTTClient_destroy(&client);


I plan to add the history charts to the dashboard but I still didn’t manage to get the historical data back from AirVantage. There seems to be a REST API for getting raw historical data (https://na.airvantage.net/develop/apiDocumentation/apiDocumentation?page=API+-+System+v1.html) but I didn’t find anything like it in AirVantage MQTT Docs.

I’m not sure if this is even possible with MQTT.

UPDATE: No, it's not. We have to use the REST API to get historical data. Please read the following post for more details: In the Air Design Challenge - Pollen & Allergen Sensing – Post 3 (AirVantage Intro)

 

Optionally, depending on sensor inputs or AirVantage commands, BeagleBone Black should also control actuators (if I get enough time for it). I’m not sure I will fit this task into given timeframe, might be done later.

 

Remote clients (desktop and mobile)

As I said, Qt will also be used for remote clients, both mobile and desktop. It will also be able to show readings history when I sort out how to get it from AirVantage using MQTT.

Additionally, I will support direct actuators control once I get to the point that I can add them - not necessary in the given timeframe.

I’ve come up with an initial application design that runs on Desktop(Windows, Linux and Mac), and mobile (Android, iPhone and BlackBerry) but still not good enough to be presented here so give me a week or two for screenshots.

  • Sign in to reply
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