element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog PSoC 6 and ModusToolbox: FreeRTOS to AWS MQTT
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 28 Mar 2021 7:10 PM Date Created
  • Views 8365 views
  • Likes 2 likes
  • Comments 33 comments
  • mqtt
  • aws
  • psoc_6
  • freertos
  • aws_iot
  • cypress
Related
Recommended

PSoC 6 and ModusToolbox: FreeRTOS to AWS MQTT

Jan Cumps
Jan Cumps
28 Mar 2021

In this post we react on a message on the RTOS queue and publish its payload on Amazon's AWS IoT MQTT service.

image

 

Together with the two previous posts, this one describes a hardware component in the NanoDrone II project of balearicdynamics

Scenario: receive 16 bytes of payload from an Arduino over serial, and forward it to AWS cloud.

The summary of the flow:

  • 2 main tasks, one for the UART with Arduino, one for MQTT with AWS.
  • all tasks sleep.
  • when Arduino sends 16 bytes, a trigger fires, and it wakes up the UART task.
  • UART task copies payload from UART buffer, and puts it on a RTOS queue as a message.
  • UART task back to sleep.
  • When a message is on the queue, the MQTT task wakes up
  • gets the message data from the queue and publishes a new message on AWS MQTT service with that data as payload.
  • MQTT task back to sleep
  • repeat

The two tasks run and sleep independently. The queue has 10 positions and can act as a UART data buffer if there's a slowness in publishing the message on AWS cloud.

 

Instead of showing the whole exercise, I'm going to point you to the AnyCloud MQTT Client example that this firmware borrowed from.

What have we changed:

  • the MQTT topic. It was "ledstatus". we use "nanodrone"
  • the trigger: a button press in the PSoC example. We use a message on the queue as trigger
  • subscribe: the original example subscribes to the same message as posted, then toggles the user led. We don't subscribe. One way traffic.
  • We introduced a queue to interact between the UART and MQTT client.
  • Changed power modes in the RTOS config. To keep the UART reactive.

 

The firmware is available on github: https://github.com/alicemirror/Nanodrone-II_PSoC6 .

Before cloning the project, check out the original AnyCloud MQTT Client example in ModusToolbox.

It serves two purposes: you have an example, and it takes care that the dependencies are all available in your workspace.

Follow its instructions to connect you to AWS MQTT. You'll need to do the exact same steps with our project. If you know it works with the standard example, it makes the next steps easier.

 

After cloning and importing the project into your workspace, perform these activities in the Quick Panel:

  • open the Library Manager and click Update. Close when finished.
  • click Refresh Quick Panel.
  • update mqtt_client.h with your Amazon certificates, and wifi_config.h with your WiFI settings, as you'd do for the AnyCloud MQTT Client example.
  • click Build Nanodrone-II_PSoC Application

 

Then connect  a 3.3 V Arduino. GND to PSoC 6 GND, TX with PSoC 6 pin 10.0.

Program this example on the Arduino: a simple program that will send 16 bytes once every time the Arduino resets.

 

void setup() {
  // start serial port at 9600 bps and wait for port to open:
  Serial1.begin(9600);
  establishContact();
}


void loop() {
    delay(100000);
}

void establishContact() {
    Serial1.print("{\"a\":-122,\"b\":3}");   // send a fixed lenght string
}

 

If all is well, you should get a message on your MQTT Cloud account each time you press the Arduino reset button.

 

image

 

PSoC 6 series
PSoC 6 and ModusToolbox: Create a Project with its own Board- and Module configurations
PSoC 6: Low Power Management - Power consumption without WiFi or Bluetooth
PSoC 6 and ModusToolbox: Create a FreeRTOS 10.3 Project
PSoC 6 and ModusToolbox: UART receiver with FreeRTOS
PSoC 6 and ModusToolbox: FreeRTOS message queue
PSoC 6 and ModusToolbox: FreeRTOS to AWS MQTT
PSoC 6 and ModusToolbox: Break the Debugger from the Proto Board
  • Sign in to reply
Parents
  • Jan Cumps
    Jan Cumps over 4 years ago

    These were the instructions I wrote down. Before executing them, import the Anycloud MQTT example in the same workspace and check if it builds and works.

     

    Then:

    After cloning and importing the project into your workspace, perform these activities in the Quick Panel:

    • open the Library Manager and click Update. Close when finished.
    • click Refresh Quick Panel.
    • update mqtt_client.h with your Amazon certificates, and wifi_config.h with your WiFI settings, as you'd do for the AnyCloud MQTT Client example.
    • click Build Nanodrone-II_PSoC Application

     

    We didn't make lib changes to the makefiles. These are the only modifications: https://github.com/alicemirror/Nanodrone-II_PSoC6/commit/c188050f788979f10cb1cc1b133634a1848d97eb#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52

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

    Hi Jan Cumps

    I performed steps 1 and 2 above after cloning and importing the project. I then built it. When I get the Anycloud MQTT client example to work, I'll try and build your code after updating mqtt_client.h.

     

    I'll let you know What I come up with.

    Thanks so much for your blogs.

    Steve K

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

    I'll go and try to do an exercise from fresh.

    Create a new empty worksapce for ModusToolBox

    image

    Download a fresh github clone

    try to get the project built.

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

    Well, that ended fast. The version of ModusToolbox that I have errors when creating an example project. A certificate expired.

     

    image

     

    ERROR: --ABORTING--

      : Script : D:/Infineon/Tools/ModusToolbox/tools_2.3/make/getlibs.bash

      : Bash path : /usr/bin/bash

      : Bash version: 4.4.12(3)-release

      : Exit code : 1

      : Call stack : trap_exit error perform_git process_mtb extract_data find_mtbs main

     

    fatal: unable to access 'https://git.savannah.nongnu.org/git/lwip/': SSL certificate problem: certificate has expired

    make: *** [D:/Infineon/Tools/ModusToolbox/tools_2.3/make/getlibs.mk:126: getlibs] Error 1

    Project "AnyCloud_MQTT_Client" failed to create.

    "make getlibs" failed.

    Failed to create and export "AnyCloud_MQTT_Client" application.

     

     

     

    I'll see if I can update my ModusToolbox install. I stopped using the PSoC6 a few months ago.

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

    I also got this as well early on.

    there is a fix on the forum from markgsaunders in the ModusToolboxAnyCloundSDK.

    I'll see if I can get the link?

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

    skruglewicz  wrote:

     

    I also got this as well early on.

    there is a fix on the forum from markgsaunders in the ModusToolboxAnyCloundSDK.

    I'll see if I can get the link?

    Don't worry. I uninstalled 2.3. It works in 2.4

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

    skruglewicz  wrote:

     

    I also got this as well early on.

    there is a fix on the forum from markgsaunders in the ModusToolboxAnyCloundSDK.

    I'll see if I can get the link?

    Don't worry. I uninstalled 2.3. It works in 2.4

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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 © 2026 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