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
Low Power IoT Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Low Power IoT Design Challenge
  • More
  • Cancel
Low Power IoT Design Challenge
Blog Low Power IoT Design Challenge - MQTT Implementation
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 22 Sep 2021 3:53 AM Date Created
  • Views 1427 views
  • Likes 2 likes
  • Comments 4 comments
  • node red
  • mqtt
  • low_power_iot
  • anycloud_mqtt_client
  • cy8ckit-psoc62s2-43012
  • cypress modus toolbox 2.3
Related
Recommended

Low Power IoT Design Challenge - MQTT Implementation

ralphjy
ralphjy
22 Sep 2021

I plan to use MQTT messages to communicate between the PSoC 62S2 and a local MQTT broker that I have running on an RPi4.

 

The PSoC 62S2 will subscribe to detection messages from the remote microwave sensor and publish classification and recognition messages.

 

The first thing that I need to verify is that I can send and receive messages (publish and subscribe to topics) to/from the broker.

 

Modus Toolbox includes an example to do that using an AWS broker - AnyCloud_MQTT_Client.  I am running on my LAN with a private broker, so I need to make some minor tweaks to their example.

 

image

 

I just need to modify 2 configuration files:

     wifi_config.h to add my wifi network name and password

     mqtt_client_config.h to add the broker ip address and port and any TLS information

 

image

 

I thought this would be very easy because I don't run TLS when operating within my private LAN, so I wasn't going use TLS and didn't need to generate any certificates (I'll probably switch to that at some point).  So, basically all I needed to do was indicate that I'm not using TLS and also switch the port number from (8883 to 1883).

 

There are 2 lines in the mqtt_client_config.h file:

     #define MQTT_SECURE_CONNECTION            ( 0 )   // change from 1 to 0

     #define MQTT_PORT                         1883                   // change from 8883 to 1883 -> 8883 is the default TLS port

 

Of course, nothing is that easy.  Just simply changing the MQTT_SECURE_CONNECTION to "0" would cause the build to fail (I had verified it would build with "1").

 

Here is the build error message:

     source/mqtt_client_config.c:118:38: error: conflicting types for 'security_info'

       118 | struct cy_awsport_ssl_credentials_t *security_info = NULL;

 

     In file included from source/mqtt_client_config.c:44:

     ./configs/mqtt_client_config.h:192:39: note: previous declaration of 'security_info' was here

       192 | extern cy_awsport_ssl_credentials_t  *security_info;

 

I needed to delete the "struct" declaration so that line 118 in mqtt_client_config.c became

     118 | cy_awsport_ssl_credentials_t *security_info = NULL;

 

That fixed the build error.

 

Application demo

 

In this particular application, the PSoC 62S2 both publishes and subscribes to the topic "ledstatus" which creates a message loopback.  When the user button (SW2) is pressed the published message alternates between "TURN ON" or "TURN OFF" to the topic "ledstatus".

 

Since the board is also subscribed to the "ledstatus" topic, it responds to the message by turning the user LED on or off.

 

Here is the USB serial output in a PuTTY terminal window.

image

 

And a short video showing the interaction.

 

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

 

 

My next steps are to add the microwave sensor and the capability to display received messages on the E-Paper Display (EPD).

  • Sign in to reply
Parents
  • Jan Cumps
    Jan Cumps over 3 years ago

    Ralph, have you considered to enable security on the MQTT server instead of disabling it on the client?

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

    Ralph, have you considered to enable security on the MQTT server instead of disabling it on the client?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • ralphjy
    ralphjy over 3 years ago in reply to Jan Cumps

    Hi Jan,

     

    When operating on my local LAN, I tend not to enable security for MQTT so that I don't have to generate certificates for each device that I add.  Just laziness I guess.  I should be more disciplined.

     

    Ralph

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

    I blame the early MQTT tutorials, that learned the developers how to turn off security instead of how to embrace it.

    The ModusToolbox AnyCloud examples are good exceptions. They  show how a client application can do safe IoT.

     

    (fun fact: I turned the light on in ipv1's baby bedroom, and took over one of the Hackaday finalists' designs in a contest)

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

    I'll have to remember that when I see strange things going on image....

     

    More seriously, I agree with your comment about security.  I'm glad to see the Trust hardware being deployed for IoT devices.

    • 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