MQTT on the TI CC3200 LaunchPad thanks to Paho embedded client

What I really like with MQTT and CoAP is that they both are very simple protocols. When dealing with MQTT, the client itself has almost no state to maintain (at least when you stick to QoS 0 communications) and granted that you have an MQTT packet serializer/unserializer, it’s very simple to stuff such MQTT packets into TCP sockets using the networking APIs that your IoT microcontroller is providing.

I’ve had the opportunity to play with the TI CC3200 LaunchPad platform recently, and thought it would be a good candidate to try out the Paho embedded C Client.

The tutorial below, split into two parts (publishing and subscribing), gives a complete overview on how you can very easily port MQTT to the CC3200 and should probably be useful if you’re targeting another kind of platform, as it walks you through the process of tying in with the networking API of the underlying platform (TI SimpleLink™ in CC3200’s case)

By Benjamin Cabé

Benjamin is a technology enthusiast with a passion for empowering developers to build innovative solutions. A long-time open source advocate, he co-founded Eclipse IoT in 2011 and is currently working at Microsoft on Azure IoT.

26 replies on “MQTT on the TI CC3200 LaunchPad thanks to Paho embedded client”

One problem I ran into is that the CC3200 out-of-box (oob) demo does not automatically connect to my office network and therefore the MQTT packets never make it out to the broker. I removed the P58 jumper (which forces the demo into AP mode) but when I run the code, it seems like it’s connecting to some other AP (i.e. LED D7 flashes rapidly then stays lit) but I never see an IP assigned in the serial UART output (last output is “CHIP ID: 0xf8”). Any suggestions on how to force the demo to always come up and wait for configuration – preferably via SmartConfig (i.e. the SimpleLink Wi-Fi Starter app)?

Great stuff! I like the video that show how do you “merge” the Paho code into the example. Would be nice to not retype everything, the code you modify in the video is upload somewhere? Thank you!

Great Video and example how to import Paho embedded MQTT C library another project. I just publish my first MQTT message over STM32 with GSM Module.

Hi there
I am trying your example MQTT SUB code and while it starts ok after a few received messages it just seems to stall, this would be roughly 6 messages, I am sending out the received messages to UART_Print

If I try to run two task one to publish and one to subscribe (Basically both your examples in the videos, the subscribe will not work giving errors about unable to transmit all data, the publishing of the temperate will continue to function however

I spin up both tasks with the same parameters in the task create , that being each task is given 2K stack and the same priority with different names of course

Have you tried this scenario and can you provide any advise as to what may be going wrong

Excellent videos by the way, easy to follow and use

I followed your Part 1 video, but I got no output at MQTTLens. The only part I changed is the IP address of my CC3200 Launchpad.

Hi! Great tutorial!

I have a problem with my code stuck on
int mysock = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, 0);
Do you or anyone else have a clue?

Hi Mr.Benjamin,
Iam working with cc3200 and executing Mqtt example,it was working fine but now iam getting this below error, could you please help me to fix this.i have reformatted and updated the latest firmware.

Thanks in advance.
CC3200 MQTT_Client Application

Host Driver Version:
Build Version
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: Vprints , BSSID: c:d2:b5:21:a0:e8
[NETAPP EVENT] IP acquired by the device

Device has connected to Vprints
Device IP Address is

Version: Client LIB 1.0.3, Common LIB 1.1.1.
C: FH-B1 0x10 to net 17, Sent (45 Bytes) [@ 103]
C: Net 17, no RX MSG in reasonable time
C: RX closing Net 17 [-1]
C: Cleaning session for net 17
C: Net 17 now closed

Broker connect fail for conn no. 1

Exiting the Application
[SOCK ERROR] – close socket (17) operation failed to transmit all queued packets

Thanks and Regards

Hello when I follow your first tutorial and try to run it within Code composer … nothing happens and I see nothing … So I took the .bin flile from the oob release and used uniflash to try and see the output in tera term…. The only thing I see there is a welcome screen saying ” CC3200 Out of Box Application” and a cursor keeps blinking on the console. But nothing happens … Then I use MQTT.fx and connect and publish and subscribe but no messages …Can u help me where am i wrong ?

Dear friend I need your help,

I am new in field of IoT and after read lot of documentation and watch videos in youtube, I try wrote my first MQTTClient project programming in C in compiled in Ubuntu 12 LTS, but without sucessfull.

Please help me found my mistake:

I following the installation steps recomended by the paho web site.


When I try compile the project it gvaesrc/SSLSocket.h:27:25: fatal error.

Sorry for my language, i’m really interest in MQTT and i find your tuitorial helpful, but the quality of the video not so good, i couldn’t follow all the tuitorial. Can i get your code via email, that would be nice. Thanks in advance.

hi! i tried a lot but cannot send or receive any messages with mqtt. device can connect to the internet but not connect to the broker. i used your code, just changed the ip address. what could be the problem? i’ve also tried the new cc3200 library but it has a lot of errors and i couldn’t fix it. and i saw a few comments like mine on your youtube channel and other sites, can you help? thank you!

Hi Benjamin
Thanks a lot for your work and your presentation!
It is rather difficult to read and type in all changes. Is your code available as download?

Thanks again and Best Regards

Hi Ben , I just want to thanks you for this tutorial, really help me to make MQTT work in my ST32F4. I manage to plot live data on a web site from ECG signals adquiered in my Embebed sistem. ( i’m not very good in english, hope you can understandme)

Hello Ben

Thank you for your post. These two videos are really helpful for learner warms up.

Here is my question hope you can help.

To your receive code, I could receive couple messages however it died after couple times.
What should we do in order to re-connect to broker?

Thanks .

I have been trying to use the paho mqtt library with my stm32 with a gsm module. I have been having trouble sending the mqtt packet. Was wondering if there was a source I could look at where this has been implemented with a stm32.

Thanks a lot for posting this video. Without your help I wouldn’t be able to run MQTT. Thanks a lot

Leave a Reply

Your email address will not be published. Required fields are marked *