RuggedBOARD DevWiki
  • RuggedBOARDs Developer Wiki
  • RB-A5D2x
    • Contents
    • Download BSP and Documents
  • G1: Getting Started
    • RB-Quick Start Guide
    • Test all the RB interfaces in 10 mins in command Line
    • Example Program for Interfaces Using Python 3
  • G2: Programming Guide
    • Software Architecture on RB (Software Stack Diagram)
    • RB Interface/Bus Programming using MRAA
    • RB Peripherals programming using UPM
  • G3: How to Do?
    • Modbus on RB
    • RB as Tiny Web Server
    • MQTT Client on RB
    • SQL Lite DB
    • AWS Green Grass on RB
    • Microsoft Azure on RB
  • G4: Use Cases / Application Notes
    • Smart Energy Meter with AWS cloud
    • IoT Based solution for Plants Water monitoring
    • Weather Monitoring Stations
    • FAQ
  • G5: System development Guide
    • Advance Host setup
    • Flash a Bootable SD Card for Rugged board
    • Flash a NOR with Bootable SD Card For Rugged Board A5d2x
    • Flash the NOR using tftp For Rugged Board A5d2x
    • Yocto Compilation For Rugged Board A5d2x
    • Download the Toolchain for Rugged Board A5d2x
    • How to Add New Package in Yocto(root file system)
    • Generate the SDK(toolchain) using YOCTO
    • How to compile the U-Boot for Rugged Board A5d2x
    • How to compile the kernel for Rugged Board A5d2x
  • RB-i.MX6UL
    • Contents
    • Download BSP and Documents
  • G1: Getting Started
    • RB-Quick Start Guide
    • Test all the RB interfaces in 10 mins in command Line
    • Example Program for Interfaces Using Python 3
  • G2: Programming Guide
    • Software Architecture on RB (Software Stack Diagram)
    • RB Interface/Bus Programming using MRAA
    • RB Peripherals programming using UPM
  • G3: How to Do?
    • Modbus on RB
    • MQTT Client on RB
  • G4: System development Guide
    • Advance Host setup
    • Flash a Bootable SD Card for Rugged board
    • Flash a NAND with Bootable SD Card For Rugged Board i.MX6UL
    • Flash the NAND using tftp For Rugged Board i.MX6UL
    • Yocto Compilation For Rugged Board i.MX6UL
    • Download the Toolchain for Rugged Board i.MX6UL
    • How to Add New Package in Yocto(root file system)
    • Generate the SDK(toolchain) using YOCTO
    • How to compile the Barebox for Rugged Board i.MX6UL
    • How to compile the kernel for Rugged Board i.MX6UL
  • G5 : Help Desk
    • FAQ
Powered by GitBook
On this page
  • Objective:
  • Materials:
  • Hardware:
  • Software:
  • Procedure:

Was this helpful?

  1. G3: How to Do?

MQTT Client on RB

PreviousRB as Tiny Web ServerNextSQL Lite DB

Last updated 4 years ago

Was this helpful?

Objective:

This guide describes the testing method of mqtt client for the .

Materials:

Hardware:

  • Rugged Board A5d2x

  • ubuntu pc

Software:

  • Not Require

Procedure:

Step 1: Add the below additional packages in yocto and use compiled rootfs.

  • mosquitto

  • tcpdump

Step 2: Download the source from below link and cross compile it.

$ git clone https://github.com/eclipse/paho.mqtt.c.git
$ cd paho.mqtt.c/
$ git reset --hard 7e9b814bfb81d1edc32d8cef3594d5265ffb2395

Step 3: Edit the publish and subscribe files of mqtt applications as below

$ vi src/samples/MQTTClient_publish.c +22

→ Here give the ip address of board as below and save the file.

#define ADDRESS     "tcp://192.168.1.39:1883"

→ Same for subscribe file too

$ vi src/samples/MQTTClient_subscribe.c +22

→ Here give the ip address of board as below

#define ADDRESS     "tcp://192.168.1.39:1883"

Step 4: Save and compile using below commands

$ make clean
$ make

Step 5: After compilation, copy the libraries from below path to usr/lib in the board

$ build/output/libpaho-mqtt3*

→ Copy the these two applications with name of "MQTTClient_subscribe", "MQTTClient_publish" from below path to "home/root" of the board.

$ build/output/samples/

Step 6: Edit the mosquitto configuration file as below in the board

$ vi /etc/mosquitto/mosquitto.conf

→ Add below lines in and save the file.

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
listener 1883 192.168.1.39

Note: here 1883 is port and 192.168.1.39 is board ip address.

Step 7: Run the below command in the board.

$ mosquitto -c /etc/mosquitto/mosquitto.conf &

→ And run the below binary to get the data

./MQTTClient_subscribe

→ Then run the below binary to sent the data in other terminal(do ssh to the board)

./MQTTClient_publish

Below are the test logs for above commands:

Output logs of ./MQTTClient_subscribe:

root@rugged-board-a5d2x-sd1:~# ./MQTTClient_subscribe
Subscribing to topic MQTT Examples
for client ExampleClientSub using QoS1
 
Press Q<Enter> to quit
 
Message arrived
     topic: MQTT Examples
   message: Hello World!

Output logs for ./MQTTClient_publish:

root@rugged-board-a5d2x-sd1:~# ./MQTTClient_publish 
Waiting for up to 10 seconds for publication of Hello World!
on topic MQTT Examples for client with ClientID: ExampleClientPub
Message with delivery token 1 delivered
root@rugged-board-a5d2x-sd1:~#

Output logs of mosquitto -c /etc/mosquitto/mosquitto.conf command:

root@rugged-board-a5d2x-sd1:~# mosquitto -c /etc/mosquitto/mosquitto.conf 
1325381603: mosquitto version 1.4.14 (build date 2020-11-04 14:08:01+0000) starting
1325381603: Config loaded from /etc/mosquitto/mosquitto.conf.
1325381603: Opening ipv4 listen socket on port 1883.
1325381610: New connection from 192.168.1.39 on port 1883.
1325381610: New client connected from 192.168.1.39 as ExampleClientPub (c1, k20).
1325381611: Client ExampleClientPub disconnected.

→ Run the to cross compile the application source.

→ ssh to the board ip address as "ssh " from your PC.

Rugged Board A5d2x
How to add new package in yocto.
toolchain of rugged board a5d2x
root@192.168.1.39