-
1AWS account set up
If you don’t have any AWS account first you must create an AWS account. You can find detailed information for AWS account here : https://aws.amazon.com/tr/premiumsupport/knowledge-center/create-and-activate-aws-account/
-
2Create your AWS IoT Thing
After create your AWS account you must login your AWS management console. At the top, click Services and scroll down until you see Internet of Things on the right hand side. Click on IoT Core.
On the left side, click Manage, and then click Create button. Choose "Create a Single Thing" and then give it a name. Scroll down and click Next. You can ignore other fields in here. The next page shows certificate creation options. AWS IoT is accessible via TLS with certificates. Create a thing object in AWS IoT and its X.509 device certificate, and then attach the policy document. The thing object is the virtual representation of your device in the AWS IoT registry. The certificate authenticates your device to AWS IoT Core, and the policy document authorizes your device to interact with AWS IoT. Choose the top option, One-click Certificate Creation.
Important: When you create certificate you must download your keys at this stage.
-
3Create an AWS IoT policy
X.509 certificates are used to authenticate your device with AWS IoT Core. AWS IoT policies are attached to the certificate that authenticates the device to determine the AWS IoT operations, such as subscribing or publishing to MQTT topics that the device is permitted to perform. Your device presents its certificate when it connects and sends messages to AWS IoT Core.
In this procedure, you will create a policy that allows your device to perform the AWS IoT operations necessary to run the example program. You must create the AWS IoT policy first, so that you can attach it to the device certificate that you will create later.
On the main IoT Core page, click Secure menu. Below Certificates, click on Policies, and then click on Create in the upper right. Give it a name like "Open". In the statements section below the name, enter iot:* as the action, and * as the resource ARN. Check off Allow, and then click Create at the bottom right.
-
4Setup Device and project files with AWS
Before writing project you must include AWS values into your header files.
AWSIOT_ENDPOINT_ADDRESS etc. Also you may need your ceritificate files.
-
5AWS add thing
AWS IoT provides a thing registry that helps you manage your things. A thing is the representation of a device or logical entity. It can be a physical device or sensor (for example, a light bulb or a switch on a wall). It can also be a logical entity like an instance of an application or physical entity that does not connect to AWS IoT, but is related to devices that do (for example, a car that has engine sensors or a control panel).
Things are identified by a name. Things can also have attributes, which are name-value pairs you can use to store information about the thing, such as its serial number or manufacturer. Adding your things to the thing registry allows you to manage and search for them more easily.
On the left menu click Manage part and select Things section. After that you can define your single thing. You can name it by simple psoc1. Other option can be blank here.
-
6AWS IoT thing details.
When you click that created thing you can find Interact details in here. HTTPS address is required for device and AWS communicaiton.
-
7Rules
After you successfulyt recveived MQTT messages you can define a rule for store messages. For this, click Act menu on left side. After that select Rules section. In rules give it simple name like "testing". In here you need a query for massages. In AWS documentation you can find detailed SQL syntax. But here we have simple SQL -> SELECT * FROM 'PSOC_GW' . PSOC_GW is the name of MQTT publisher name here.
In the Actions section you can define some rules. We choose "Insert a message into a DynamoDB table" rule here. To define table resources in DynamoDB table, you must create an account for DynamoDB system. for this please follow instructions. Key point is here after define your table you must write down in MQTT publisher name for data column.
This DynamoDB will be used to keep the number of smart devices detected by the gateway.
-
8How to choose the right IDE for PSoC?
Since PSoC is a new platform for our team, we spent most of the competition time getting to know the platform. But we saw that compared to the alternatives of PSoC, really there is a rich development environment. In this case, choosing the right tool is the most important thing.
Let's take a look at these:
1- PSoC Creator
2- Modus Toolbox
3- Zerynth
4- WICED StudioWe tried all of them... As part of the project, we knew that we had to use WiFi and BLE stacks at the same time. Then selected WICED studio.
-
9Programming the PSoC Gateway
Create a project folder named psoc_gw using project explorer
psoc_gw.c will be our main project c code, psoc_gw.mk is used to compile entire project, wiced_bt_cfg.c and wifi_config_dct.h files are used to configure bluetooth and wifi connections
Then you have to clone a make target item. Make target item must be named as "demo.psoc_gw.CY8CKIT_062 download_apps download run"
Rename the certifate keys which are downloaded from amazon before.
AmazonRootCA1.pem ---> rootca.cer
xxxxxxxx-private.pem ----> privkey.cer
xxxxxxxx-certificate.pem ---> client.key
Then insert certificate files to right place.
-
10Let's examine the code
Change your credentials for wifi connection in wifi_config_dct.h file.
wiced_bt_ble.h is used for runtime Bluetooth stack configuration parameters. There is nothing to change.
In psoc_gw.mk there are some important codes.
-Name : Must be unique
-Sources: Must include main project file and runtime for Bluetooth stack
-Resources: Must include declaration of certificate files
-Components: Must include AWS service, utilities and Bluetooth low energy libraries
-Wifi_Config_DCT_H: For WiFi connection, must be included
Change the AWS uri address in psoc_gw.c
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.