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
      •  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
Connected Cloud Challenge
  • Challenges & Projects
  • Design Challenges
  • Connected Cloud Challenge
  • More
  • Cancel
Connected Cloud Challenge
Blog Mbed connect to AWS iOT, OS, driver, security ..  #2
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: saicheong
  • Date Created: 3 Apr 2020 6:51 PM Date Created
  • Views 438 views
  • Likes 2 likes
  • Comments 0 comments
  • amazon web services
  • dog bites
  • mailbox
  • cypress
Related
Recommended

Mbed connect to AWS iOT, OS, driver, security ..  #2

saicheong
saicheong
3 Apr 2020

Developing Framework for the Project

 

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

 

How i choose platform

 

I am try to build the framework which is the foundation of this project. In Cypress PSOC 6, we can choose three main OS

 

1. PSOC ModusToolbox App, which is specified for PSOC 6 hardware

2. Mbed, which is open source multi-platform iOT OS by ARM

3. Amazon FreeRTOS which is open source small RTOS promote by Amazon

 

The Mbed and Amazon FreeRTOS fully support AWS and Cypress provided document and example code for developer learning.

 

In this project, i choose Mbed for the platform because:

 

1. It provide more abstraction though Mbed HAL so it is more easy porting to other hardware. (Hardware independenting)

2. It provide object oriented programming (C++)

3. It fully support Amazon AWS and even other main competitors.

4. It support uTesnor, which is lightweight AI engine, which i want to implement at Advanced phase.

 

However, the learning curve of Mbed is longer because it is more sophistic and complex that FreeRTOS.

 

Install of Mbed CLI

Cypress provide good instructions of implement AWS under Mbed, as i just briefing introduced the step of create our framework

 

1. Installed Mbed CLI

2. Use mbed new <project> create a new program

3. Add Cypress Amazon AWS library

mbed add https://github.com/cypresssemiconductorco/aws-iot

4. Add Cypress connectivity-utilities (for WIFI)

mbed add https://github.com/cypresssemiconductorco/connectivity-utilities

5. Add Cypress EmWin (the licences free use for cypress customers) for LCD display

mbed add https://github.com/cypresssemiconductorco/emwin

6. Add Cypress  capsense for touch button

mbed add https://github.com/cypresssemiconductorco/capsense

https://github.com/cypresssemiconductorco/emwin

7. Porting the pioneer kit TFT LCD and emWin driver for Mbed

8. Modify the mbed_app.json  for emWin library and custom BSP config

9. Build network.cpp for WIFI connection

10. Build aws-iot.cpp for AWS connection

11. Build log.h for display message to LCD

12. Create Amazon AWS account, add IOT, edit the Policy document, build SSL Certificates, import to Mbed program,

 

However, in our environment, the WIFI under Mbed may not boot up the WIFI chip , there have chance the system is not recognised the wifi chip (SDIO bus issue),

i need to study more deeply of wifi driver (cybsp_wifi.c) for tweaking such as the timeout and stack setting.

 

Amazon AWS Security

After successful of connect the WIFI and get the IP from AP, the device fail connect to Amazon because the Policy document incorrect.

the key is import correct certificate, link this to "Things" and "Policies", and with correct "Policies" documents which is required custom for each iOT project.

 

The briefing step is:

 

1. Create the Things such as "myIOT"

2. under Things > Security > Create certificate.

3. Get the cert and import to aws_config.h,

4. ensure aws_config.h AWSIOT_ENDPOINT_ADDRESS some as AWS iOT console > Settings > Endpoint

5. carefully edit the policy document, for example:

{
  "Version": "2012-10-17",
  "Statement": [
  {
  "Effect": "Allow",
  "Action": [
  "iot:Publish",
  "iot:Receive"
  ],
  "Resource": [
  "arn:aws:iot:us-west-2:1600000000xx0:topic/AWS_TOPIC"   // require match of #define AWSIOT_TOPIC
  ]
  },
  {
  "Effect": "Allow",
  "Action": [
  "iot:Subscribe"
  ],
  "Resource": [
  "arn:aws:iot:us-west-2:1600000000xx:client/${iot:Connection.Thing.ThingName}"
  ]
  },
  {
  "Effect": "Allow",
  "Action": [
  "iot:Connect"
  ],
  "Resource": [
  "arn:aws:iot:us-west-2:1600000000xx:client/${iot:Connection.Thing.ThingName}"
  ]
  }
  ]
}

 

  • Ensure the prefix (arn:aws:iot:us-west-2:100000000:)is correct, this is unique for individuals AWS account.
  • the "resource type" (after : and before / ) need specified for each type of "Action" such as topic for iot:Publish and it:Receive.
  • the last "resource name" should match your defining.

     for example aws_config.h   

#define AWSIOT_THING_NAME                   "myIOT"
#define AWSIOT_TOPIC                        "AWS_TOPIC"

   As the AWSIOT_TOPIC is "AWS_TOPIC", and i have a "things" named "myIOT", so is match of above  policy document.

 

More detail https://docs.aws.amazon.com/iot/latest/developerguide/iot-action-resources.html

 

The Mbed serial console output:

Connecting to the network using Wifi...
--- [RESET] ---
START DEVICES...: Success
Connecting to the network using Wifi...
WLAN MAC Address : CC:C0:88:AA:9E:AA
WLAN Firmware    : wl0: Sep  5 2019 23:24:33 version 7.45.98.92 (r722362 CY) FWID 01-f7128517
WLAN CLM         : API: 12.2 Data: 9.10.39 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2019-09-05 23:10:00 
WHD VERSION      : v1.70.0 : v1.70.0 : GCC 6.3 : 2019-12-02 04:14:53 -0600
num of wifi: 7: Success
IP: 192.168.1.139 : Success
Connected to the network successfully. IP address: 192.168.1.139
connected to AWS : Success
Connected to AWS endpoint
Success
publish to AWS successfully: Success
Published to topic successfully
Success
publish to AWS successfully: Success
Published to topic successfully
Success
publish to AWS successfully: Success
Published to topic successfully
Success
publish to AWS successfully: Success
Published to topic successfully
Success
publish to AWS successfully: Success
Published to topic successfully
Success

 

The AWS console output

image

What Next

The next step is improve the reliability of WIFI, and try to triggering the iOS APP (Device button > AWS Cloud > APP )

  • 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