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
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog 1958 Turntable from the Black Forest - Grande Finale: Paho MQTT Client on the SAMA5D4
  • 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: Jan Cumps
  • Date Created: 18 Jun 2015 4:58 PM Date Created
  • Views 1857 views
  • Likes 5 likes
  • Comments 14 comments
  • sama5d4
  • mqtt
  • enchanted_player
  • enchanted_objects
  • eclipse
  • eclipse_paho
  • atmel
Related
Recommended

1958 Turntable from the Black Forest - Grande Finale: Paho MQTT Client on the SAMA5D4

Jan Cumps
Jan Cumps
18 Jun 2015

image

 

As a dramatic closing exercise to the Enchanted Objects parade, I chose to try and build a C MQTT client for the SAMA5D4.

It turned out to be not dramatic at all. It was rather easy. Here's my log of the activities.

 

 

image

 

My ToolSet

 

I'm cross-building the library and executable on a Windows machine.

I used Eclipse for DS-5 - Community Edition as my IDE, and used the built-in ARM GCC 4.x toolchain.

My telnet client is PuTTY, and WinSCP does the file transfer.

I used the GIT command line to retrieve the Paho client code.

The Paho MQTT client utility was my testbed.

 

I've made a how-to on using these tools as part of my blog series.

 

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

 

Building the MQTT Shared Library

 

The source code for the eclipse Paho libraries is available from github.

You can find the instructions on eclipse's MQTT C Client for Posix and Windows.

Because I'm using DS-5 for the build (and also because the makefile didn't work on my Windows PC), I've only followed the steps to download the code.

 

C:\Users\Jan\Documents\elektronica\atmel\mqtt_lib\paho_from_source>git clone http://git.eclipse.org/gitroot/paho/org.eclipse.paho.mq
tt.c.git
Cloning into 'org.eclipse.paho.mqtt.c'...
remote: Counting objects: 1719, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 1719 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1719/1719), 787.24 KiB | 31.00 KiB/s, done.
Resolving deltas: 100% (1177/1177), done.
Checking connectivity... done.

 

Then I created a new Shared Library project in DS-5. I've used the makefile source as guideline to check what files to compile and what command line options to pass to the toolchain.

 

image

 

I carefully studied the makefile to understand what files to include/exclude from build, and what settings to port from make to DS-5.

I'm building the async lib version without SSL, so I took over the settings from that lib's make commands.

 

image

 

I excluded the files listed in this variable from compilation, just like in the make script.

 

SOURCE_FILES_A = $(filter-out $(srcdir)/MQTTClient.c $(srcdir)/MQTTVersion.c $(srcdir)/SSLSocket.c, $(SOURCE_FILES))

 

image

 

I also checked where this particular makefile variable was used:

 

MQTTASYNC_INIT = MQTTAsync_init

 

and incorporated it in the linker flags:

image

 

Then I built the project. That gave me a compiled .so library.

 

Build the MQTT Subscriber App

 

I used the  async subscription example that's available in the same git extract. MQTTAsync_subscribe.c

 

I created a new project in DS-5, and added the source  to that project.

I took care that the async shared library was available to the linker:

image

 

I modified the source to connect to eclipse's mqtt sandbox, and to listen to my turntable's topic:

 

#define ADDRESS     "tcp://iot.eclipse.org"
#define CLIENTID    "1cfee8dd0afc_SAMA5D4"
#define TOPIC       "PerpetuumEbnerSpectrum"

 

Build, and done!

 

Load and Run

 

I deliberately didn't do all the steps to properly register the shared library.

 

I handled the part of setting the lib search path on the command line when invoking my executable.

There's a nice article on how to do a full-fledged install of a .so here: Shared Libraries.

 

I moved both the .so and the executable to root's home on the SAMA5D4 with WinSCP,

made both the program objects executable:

$ chmod +x Enchanted_Player_MQTT_Client

 

note to self: does an .so really need the exex flag set?

answer to self: no; explanation updated

 

and invoked the whole chebang using:

$ LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./Enchanted_Player_MQTT_Client

 

Nothing more to say. Success. It just worked. My audio spectrum, sampled by the Yún inside my turntable, arrives nicely on the SAMA5D4.

 

image

 

 

Table of Contents
Chapter 1: Fix the turntable
1: Perpetuum Ebner Musical 1
2: A Time to Kill and a Time to Heal
3: Preparation for Motor Drive
4: Motor control with Infineon Motor Shield and Arduino UNO
5: Turntable speed sample testbed with Arduino UNO
6: Turntable Speed Sensor design
7: Control Theory - End of Chapter 1
Chapter 2: First Enchantments
8: Digital Light Organ Enchantment
9: Autonomous Servo Lift
10: SMD Time - Solder the IR Speed Sensor PCB
11: Yelp - who can Help me to Compile and Run my First SAMA5D4 C Program
12: Son et Lumiere - End of Chapter 2
Chapter 3: Taming the Board
13: Breakthrough - Run my own C++ Program on the SAMA5D4
14: Digital Light Organ Input Buffer
15: SAMA5D4 Blinky
16: Scope Creep
17: Audio Sampling with 16-bit ADC ADS8343
18: Sending Files to SAMA5D4 over USB
19: Port my Light Organ from Arduino to SAMA5D4
20: Fast Fourier Transform on the SAMA5D4 - End of Chapter 3
Epilogue: Reaching for the Clouds
21: Right-Sizing my Plans
22: My Own C++ Buffered Sampler on the SAMA5D4
Interlude
23: Building In the Motorized Light Organ
24: Up to the Clouds with Yún
25: Publish or Perish
26: Turntable Finished
Stretch & Boni
Bonus 1a: Remote Light Organ with WiFI pt. 1
Bonus 1b: Remote Light Organ with WiFI pt. 2
Grande Finale: Paho MQTT Client on the SAMA5D4
Related blog
Vintage Turntable repair: Can I fix a Perpetuum Ebner from 1958
Review 1: Atmel SMART SAMA5D4 Xplained Ultra Unboxing and First Steps
Review 2: Atmel SMART SAMA5D4 Xplained Ultra - Building the Libraries from Source
Review 3: Digital Continuous Rotation (360°) Servo Part 1
Review 4: Digital Continuous Rotation (360°) Servo Part 2
Review 5: Atmel SMART SAMA5D4 Xplained Ultra - TCP/IP running
Review 6: Atmel SMART SAMA5D4 Xplained Ultra - LINUX Distro with SSH support
poem
Enchanted Objects: Let's work together to tame the ATMEL SMART SAMA5D4 Xplained Ultra kit
17 bis: Off South...
Review 7: Atmel SMART SAMA5D4 Xplained Ultra - C++ ADC Example on Linux
Review 8: Atmel SMART SAMA5D4 Xplained Ultra - Product Review
Review 9a: Atmel SMART SAMA5D4 Xplained Ultra - Set up ADC Buffer with Hardware Trigger Part 1
Review 9b: Atmel SMART SAMA5D4 Xplained Ultra - Set up ADC Buffer with Hardware Trigger Part 2
Review 10: Atmel SMART SAMA5D4 Xplained Ultra - New Content on AT91.com
1958 Turntable from the Black Forest - Summary of the Enchanted Player Story
  • Sign in to reply

Top Comments

  • fvan
    fvan over 10 years ago in reply to Jan Cumps +4
    Either that, or a ninja checking his shuriken inventory ...
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to fvan +3
  • balearicdynamics
    balearicdynamics over 10 years ago +2
    Yeee !!! Many many thanks! I like this project very much When I moved from Italy to Ibiza, five years ago, the transporter lost all my vinyls, not a great collection but there was '60 phase4 stereo and…
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to fvan

    image

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 10 years ago in reply to Jan Cumps

    Either that, or a ninja checking his shuriken inventory ...

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Jan Cumps

    Photo almost looks like a tricopter, doesn't it?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Workshopshed

    I see your adapters and raise you:

     

    image

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

    You might be interested in these

    https://www.thingiverse.com/thing:119393

    I printed some for a friend the other day

    image

    • Cancel
    • Vote Up 0 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