element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • 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
Sudden Impact Wearables Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Sudden Impact Wearables Design Challenge
  • More
  • Cancel
Sudden Impact Wearables Design Challenge
Blog EasyConfigure - MQTT test setup
  • Blog
  • Forum
  • Documents
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: tomaja
  • Date Created: 11 Mar 2015 11:30 PM Date Created
  • Views 165 views
  • Likes 1 like
  • Comments 2 comments
  • mqtt
  • easy_configure
  • sudden_impact
  • qt
  • bash
  • raspberrypi
  • paho
  • c++
  • mosquitto
Related
Recommended

EasyConfigure - MQTT test setup

tomaja
tomaja
11 Mar 2015

Previous posts:

EasyConfigure - Modular/Configurable System Intro

EasyConfigure - Hardware Components

EasyConfigure - BASH scripting

 

1. Introduction

I still didn't receive Analog Devices kits but hopefully I will very soon. This is due to alternative route complications.

My time was used for software development. I managed to make an application to test performance of MQTT based solution.

 

2. MQTT broker

I'm using a Raspberry Pi model B as hardware platform for my MQTT broker.

RPi is connected to ethernet but I plan to switch to WiFi later.

 

My RPi is running Debian and mosquitto MQTT broker and clients are available from main repositories so installation was trivial:

pi@malina ~ $sudo apt-get install mosquitto

 

New MQTT user (monitor01) was added using mosquitto_passwd (used similarly to regular passwd)

pi@malina ~ $sudo mosquitto_passwd -c /etc/mosquitto/passwd monitor01

 

After users were added, I restarted mosquitto but I'm not sure I had to:

pi@malina ~ $sudo /etc/init.d/mosquitto restart

 

OK, at this point I had a working MQTT broker! You can test the broker and credentials using mosquitto_pub


3. Test MQTT publisher

Instead of sending some real sensor data, I created a small Bash script that's publishing some dummy (random floating point number in 0.0-15.0 range) data to the broker.

#!/bin/bash

for (( c=1; c<=1200; c++ ))

do

    v=$[100 + (RANDOM % 100)]$[1000 + (RANDOM % 1000)]

    v=$[RANDOM % 15].${v:1:2}${v:4:3}

    echo $v

    mosquitto_pub -t readings/unit-123456 -u monitor01 -P sddnmpct -h 192.168.1.99 -m $v

done

 

This script sends 1200 data values with no delay except for the delay that comes from executing bash script and mosquitto_pub within.


4. Test MQTT client (subscriber)

Test client was written in C++ using Qt framework and QCustomPlot (Qt Plotting Widget QCustomPlot - Introduction charting library + Paho C MQTT library (https://eclipse.org/paho/clients/c/).

I built the test application for Mac and it seems to work fine. Stability still needs to be tested over a longer time interval.

This application subscribes to a hardcoded MQTT topic name and plots the received data in real time:

Figure 1. Test application screenshot

 

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

Testing monitor application

 

5. Performance assessment

This test showed the following:

I was able to display~80(~70) samples per second. CPU usage for mosquitto was around 16% for single publisher and single subscriber but adding more publishers increased the CPU usage - for three publishers and a single subscriber I got a little less than 40%. I think that this is fine while I test the system but to be able to support a larger number of remote sensor units I would have to switch to something more powerful than original RaspberryPi model B (something like Gizmo or even a regular PC).

 

6. Next steps

I will continue working on monitoring client application. Test application will be used as a starting point for my monitoring application that will run on coach's or assistants device(s), be that tablets, mobile phones or even laptops.

Monitor application will be able to trigger device discovery and will provide a way to select device (player) that's currently monitored.

 

Currently only OS X build is tested but other platforms should be straight forward to support too.

 

Dragan

Anonymous

Top Comments

  • DAB
    DAB over 7 years ago +1

    Nice update,

     

    70 samples per second should be reasonable for your testing.

    Short of solid data from impacts, it should be a good place to start.

    Have you contacted any of the safety organizations to see the…

  • tomaja
    tomaja over 7 years ago in reply to DAB

    Thanks, no but that's a good idea. I will try to find some information.

    Anyway, I rechecked my sample rate estimate, it's ~80 samples per second (1200 samples in 15s) but I think that my Bash script is to blame. It will probably be faster when I start sending real data.

     

    Dragan

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • DAB
    DAB over 7 years ago

    Nice update,

     

    70 samples per second should be reasonable for your testing.

    Short of solid data from impacts, it should be a good place to start.

    Have you contacted any of the safety organizations to see the rates they sample at for automobile impacts?

     

    Just a thought,

     

    DAB

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
Element14

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 © 2022 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube