I attempted to connect a Cypress PSoC 6 WiFi-BT Pioneer Kit to AWS (Amazon Web Services). The process had many steps just to get some code loaded. So, I put together this guide to walk you through the setup.

In this example I wanted to send the data from the onboard accelerometer, or any sensor, to AWS.

 

Setup AWS IoT. You can make a free account at their site: https://aws.amazon.com/

 

Logon as a root user (under your already created AWS account):

Open the https://aws.amazon.com/ address:

 

Press «Sing in to the Console», then sign in as a «Root user»:

 

 

Enter your account`s name press Next, then password and log in.

You should get the following screen:

 

Select «Services» and then «IoT Core» on the following page:

 

 

The AWS Console page will appear:

 

Select «Manage» on the left panel then choose «Things»:

If you already have a thing choose «Create», if it is the first thing on the account choose «Register a thing»:

 

On the Creating AWS IoT things page, choose «Create a single thing»:

 

On the next page enter a name for your IoT thing (for example, «SENSOR»), scroll the page down and then choose Next.

 

On the Add a certificate for your thing page, choose «Create certificate».

 

 

Click «Download» links to download certificate, keys, and a root CA certificate.

 

This is the only time you can download your certificate and private key!

 

 

This is the only time you can download your certificate and private key!

 

Then scroll down and choose «Activate» button.

 

Then choose «Attach a policy» if you already have one.

 

 

If no policies are defined then choose «Secure» on the left panel, then «Policies — Create»:

 

Fields of the page to fill are:

 

Name: is a policy name.

Action: should be set to iot:*

Resource: should be set to *

Effect: Allow

 

The same policy could be set in advanced mode by copying the fragment

 

{

"Version": "2012-10-17",

"Statement": [

    {

"Effect": "Allow",

"Action": "iot:*",

"Resource": "*"

    }

  ]

}

 

 

to the text field:

 

Press «Create» button to create the policy.

 

Example of the SENSOR_POLICY page:

 

Now the created policy should be attached to the certificate of the Thing (SENSOR):

 

Choose «Secure» then «Certificates» on the left panel of AWS console:

 

 

Then press «...» sign at the upper right corner and select «Attach policy»:

 

Select «sensor_policy» created before and then «Attach».

 

 

Modify WICED iot-publisher project

 

You need AP with Internet access and known login credentials (Wi-Fi SSID and WPA2-PSK key).

 

Open the Device Manager and find the PSoC® 6 WiFi-BT Pioneer Kit serial port (COM5 on the the picture).

 

 

 

Save the COM-port name to insert it into the Make Target config later.

 

Start WICED IDE and open in the Project Explorer (the left panel with folder tree) and open demo project source file /43xxx_Wi-Fi/apps/demo/aws/iot/pub_sub/publisher/publisher.c

 

 

 

To compile, build and upload the code you should create «Make Target» item at the right panel (Make Target panel).

Right-click on the 43xxx_Wi_Fi folder and select «New…»

 

 

Paste the following string to the «Target name» field of the «Create Make Target» window:

 

demo.aws.iot.pub_sub.publisher-CY8CKIT_062 download_apps download UART=COMXX VERBOSE=1 run

 

where COMXX is a COM name in the Device Manager.

 

 

 

Do not change other controls and click OK.

Double-click the appeared item and look for the console output for the strings:

 

Downloading Application ...

Download complete

Resetting target

Build complete

xx:xx:xx Build Finished (took Xm:Xxs.XXXms)

 

Wi-Fi credentials to change are stored in

 

/43xxx_Wi-Fi/apps/demo/aws/iot/pub_sub/publisher/wifi_config_dct.h

 

path. Double-click this file in the WICED Project Explorer (the left panel) to open it.

If your Wi-Fi net is a WPA2-PSK protected infrastructure type you should change the following lines:

 

            #define CLIENT_AP_SSID "AWS_IOT_PUB_AP"

            #define CLIENT_AP_PASSPHRASE "YOUR_AP_PASSPHRASE"

            #define CLIENT_AP_CHANNEL    1

 

Replace AWS_IOT_PUB_AP by your wireless Access Point SSID, YOUR_AP_PASSPHRASE by your WPA2-PSK key, 1 by the real Wi-Fi channel number. Leave quotes intact and save the file (Ctrl-S or File-Save).

 

You need to add your AWS key and certificates required to connect to the directories of the WICED IDE project tree.

 

WICED IDE directories which should contain AWS keys and certificate

 

 

            /43xxx_Wi-Fi/resources/apps/aws/iot/

 

This directory should contain certificate file of the Certificate Authority, named «rootca.cer».

 

            /43xxx_Wi-Fi/resources/apps/aws/iot/publisher/

 

This directory should contain client certificate and private key files named «client.cer» and «privkey.cer» respectively.

 

You should rename your AWS IoT certificates and key to replace dummy files already located in that directories.

 

Now replace «publisher.c» with the modified one (an additional publisher.c file).

 

For monitoring and debugging you can connect to the COMXX with any serial port monitor.

Install Putty (https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.74-installer.msi) run it and select Serial port with 115200 speed and COMXX as the port name:

 

 


Press the open button to connect to the COMXX port, you should see a black console window with diagnostic lines.

 

Now rebuild and reflash the board by double-click on the created «Make Target» item on «Make Target» panel.

 

Typical lines displayed in the COM port monitor (Putty) should be:

 

Starting WICED Wiced_006.004.000.0061

Platform CY8CKIT_062 initialised Rev: 0x23

Started ThreadX v5.8

WICED_core Initialized

Initialising NetX_Duo v5.10_sp3

Creating Packet pools

WLAN MAC Address : XX:XX:XX:XX:XX:XX

WLAN Firmware    : wl0: May 2 2019 02:39:20 version 7.45.98.83 (r714225 CY) FWID 01-476cc09d

WLAN CLM         : API: 12.2 Data: 9.10.39 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2019-05-02 02:29:53

Joining : SSIDNAME

Successfully joined : SSIDNAME

Obtaining IPv4 address via DHCP

L1420 : dhcp_client_init() : DHCP CLIENT hostname = [WICED IP]

IPv4 network ready IP: XX.XX.XX.XX

Setting IPv6 link-local address

IPv6 network ready IP: XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX

[Application/AWS] Opening connection...

[Application/AWS] Try Connecting...

[AWS] AWS endpoint: a38td4ke8seeky-ats.iot.us-east-1.amazonaws.com is at 35.170.136.36

[AWS/MQTT] Event received 1

[Application/AWS] Connection Acknowledgment Received

[Application/AWS] Connection Successful...

[AWS/MQTT] Event received 3

[Application/AWS] Publish Acknowledgment Received

[Application/AWS] Publishing... sens1: 0.690

 

You can open AWS IoT console monitor to view received messages.

 

Go to the AWS IoT console, select «Test» item:

 

 

Then enter # in the «Subscription topic» field and click «Subscribe to topic»:

 

 

 

Now you can monitor your messages received by the AWS IoT console client:

 

 

This tutorial and others here at element14 should get your started in the world of AWS and Cypress.