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 8351 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

    Success:

    image

     

    The linker complained that I had 2 global variables called message.

    I fixed this by renaming the one in subscriber_task.c sub_message and the one in publisher_task.c pub_message.

    It now compiles and links.

     

    Not tested.

    • 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

    The git repository is adapted to reflect the 2.4 changes.

    If you're interested in the changes: https://github.com/jancumps/Nanodrone-II_PSoC6/commit/52ba091d477324e8d4c576b83f52076b890928ee

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

    The git repository is adapted to reflect the 2.4 changes.

    If you're interested in the changes: https://github.com/jancumps/Nanodrone-II_PSoC6/commit/52ba091d477324e8d4c576b83f52076b890928ee

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

    Thanks For working. that out.

    I'll check it out soon and let you know.

    • 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 haven't tested it, but I think you can switch to your board via the Library Manager:

     

    image

     

    image

     

    You will also have to adapt the TARGET in the makefile, or right-click on the new selection and select "Set Active"

    image

     

    edit: I have tested it, up to a successful build.

     

    Initializing build: NanodroneIIPSoC6 Custom CY8CKIT-062S2-43012 GCC_ARM

    image

     

    edit 2: you don't need to create the AnyCloud example first.

    Also: you can clone the Nanodrone-II_PSoC git repository directly under the root of your ModusToolbox workspace.

    Then use the Import ModusToolbox Application wizard, and select the <workspace>NanodroneII_PSoC6 directory, to get it registered in the IDE.

    From that moment on, the Library Manager is available to change the board / processor.

    This will prevent that there are 2 shared libraries.

     

    edit3: if you're not into version control, you can download the project: https://github.com/jancumps/Nanodrone-II_PSoC6/releases/tag/3.1.0

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

    hello Jan Cumps

    I followed your directions  above using the project at https://github.com/jancumps/Nanodrone-II_PSoC6/releases/tag/3.1.0

    II do not get the errors as before but it still does not build.'

    Now I get the following error.

     

    ----------------------------------------------------------------

    make: *** Build support for the target device not found. Run "make getlibs" to ensure all required build and code dependencies are present..  Stop.

    Nanodrone-II_PSoC6-3.1.0

    line 398, external location: C:\Users\skrug\ModusToolbox\tools_2.4\make\startex.mk C/C++ Problem

    --------------------------------------------------------------

    • 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 did this from a fresh ModusToolbox 2.4 install under windows 10 64 bits.

    With a fresh clone of the github repository.

     

    At this point, maybe  retry from start too? Or ask Infineon for support?

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

    Hi

    Yes I did the exact same thing fresh install Windows 10 64 bits.

    The only thing I can say is that I'm using a different board than you. I have a thread started on this error with the forum. I'll continue to try to build and let you know what I found out.

    Thanks so much for all your help thus far.

    Regards

    SteveK

    • 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