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 8361 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
  • Jan Cumps
    Jan Cumps over 4 years ago

    Progress:

     

    The configuration for TLS is in file Nanodrone-II_PSoC6/configs/mbedtls_user_config.h

    I replaced the Nanodrone one with the contents of the new AnyCloud MQTT Client project (found at the same location in the imported example).

     

    image

     

    The mbedtls lib now compiles OK.

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

    It errors with the same issues as you have:

    image

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

    After refreshing the QuicPanel:

    image

    Now I should update some files with my certificates and Wifi settings, but I'm going to skip that.

    I'm not going to run the example. Goal is to see if it builds...

    • 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
  • Jan Cumps
    Jan Cumps over 4 years ago

    I installed ModusToolbox 2.4, and now can install and compile the AnyCloud MQTT Client example:

    image

     

    I also downloaded Enrico's repo, in a separate folder.

    image

     

    I imported the Nanodrone-II.

    For some reason, ( the behaviour is different than in previous ModusToolbox version2.3 I'm not sure anuymore), it created a new shared folder while dong that.  (edit: I think this is because my project folder is outside of the workspace folder tree).

    • 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 © 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