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 Sump Well Water Level Monitoring #6 - Send Water Level to AWS IoT
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: cmelement14
  • Date Created: 10 Nov 2021 2:09 AM Date Created
  • Views 785 views
  • Likes 1 like
  • Comments 0 comments
  • cypress modus toolbox 2.4
  • low power iot design challenge
  • psoc 62
Related
Recommended

Low Power Sump Well Water Level Monitoring #6 - Send Water Level to AWS IoT

cmelement14
cmelement14
10 Nov 2021


  • 1. Create a Project from Template Application
  • 2. Modify Code
    • 2.1 Modify WiFi Configuration
    • 2.2 Modify MQTT Configuration
    • 2.3 Certificate and Private Key Configuration
    • 2.4 Modify Functional Code
  • 3 Test the Code
    • 3.1 Create MQTT Topic Subscription
    • 3.2 Test Result

 

1. Create a Project from Template Application

 

There's a template application called AnyCloud MQTT Client. Create a new application out of this template. If you are not familiar with ModusToolbox, you can read Low Power Sump Well Water Level Monitoring #3 - Software Tool that shows how to create a new application.

image

 

 

2. Modify Code

 

2.1 Modify WiFi Configuration

image

 

 

2.2 Modify MQTT Configuration

 

First, you need to get the MQTT broker/server address. Click on AWS IoT page's Settings menu, the highlighted Endpoint is your broker/server address.

                imageimage

 

Copy and paste your server address in the configuration file. AWS IoT uses port number 8883. I will use "waterlevel" as my MQTT publish topic.

 

image

 

 

2.3 Certificate and Private Key Configuration

 

As shown in my previous blog, I downloaded a few certificates and keys files. In this project, we will use a root certificate, a device certificate and the device's private key. Before we can use the certificates and key in C project, we need to convert them to C strings. There's an online toolC string PEM to C string converterYou can also download a converter to your local machine from here.

 

image

Once the conversion is complete, you can open the file and copy/paste into the configuration file.

 

image

 

 

image

 

image

 

 

2.4 Modify Functional Code

 

First, we have three water level sensors so we add two more interrupt routines. In the initialization function, we will initialize three input pins the same way as we did in Low Power Sump Well Water Level Monitoring #4 - Water Level Sensor Interrupts.

image

 

image

 

image

 

 

3 Test the Code

 

3.1 Create MQTT Topic Subscription

 

As shown in the code modification, we named the device published topic "waterlevel". Thus in AWS IoT, we need to subscribe to this topic. AWS IoT provides a Test menu and just type the topic name and subscribe to it as shown below.

 

image

 

Device published topic will show up in the highlighted area once the device sends the water level status.

 

image

 

3.2 Test Result

 

Here's the serial console output. I only tried to trigger each sensor once, but each sensor was actually triggered multiple time because of the bouncing effect. We should be able to easily get rid of the bouncing by a small delay.

image

 

Here's published messages on AWS IoT. It should match the display on serial console.

 

image

  • Sign in to reply
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