|
| 1 | +# AWS IoT Smarthome Secureshield Application |
| 2 | +This application is designed to show how to connect only 1 EMSK and [AWS IoT Cloud](https://aws.amazon.com/iot/?nc1=h_ls) using embARC. The connection between EMSK and AWS IoT Cloud is secured by TLS. The program is secured by secureshield. |
| 3 | + |
| 4 | +## Hardware and Software Setup |
| 5 | +### Required Hardware |
| 6 | +- [DesignWare ARC EM Starter Kit(EMSK)](https://www.synopsys.com/dw/ipdir.php?ds=arc_em_starter_kit) |
| 7 | +- [Digilent PMOD WiFi(MRF24WG0MA)](http://store.digilentinc.com/pmodwifi-wifi-interface-802-11g/) |
| 8 | +- [Digilent PMOD TMP2](http://store.digilentinc.com/pmod-tmp2-temperature-sensor/) |
| 9 | +- SD Card |
| 10 | +- WiFi Hotspot(SSID:**embARC**, Password:**qazwsxedc**, WPA/WPA2 encypted) |
| 11 | + |
| 12 | +### Required Software |
| 13 | +- Metaware or ARC GNU Toolset |
| 14 | +- Serial port terminal, such as putty, tera-term or minicom |
| 15 | + |
| 16 | +### Hardware Connection |
| 17 | +1. Connect PMOD WiFi to J5, connect PMOD TMP2 to J2. |
| 18 | +  |
| 19 | + |
| 20 | +2. Configure your hardware with proper core configuration. |
| 21 | + |
| 22 | +## User Manual |
| 23 | +### Before running this application |
| 24 | +Prepare you own AWS IoT account, and create required thing. |
| 25 | +Before compiling this example, you need to change macro **AWS_IOT_MQTT_HOST** in `src/aws_iot_config.h` to your own aws iot cloud mqtt host, and create an aws iot thing named **SmartHome**, you can refer to [Gettting Started with AWS IoT](https://docs.aws.amazon.com/iot/latest/developerguide/iot-gs.html) for details, and generate certificates and download them and rename them to the ones under `src/cert/smarthome/`. |
| 26 | + |
| 27 | +We also provided an application note about [Using a Smart Home Iot Application with EMSK](https://www.embarc.org/pdf/embARC_appnote_how_to_use_smart_home_iot.pdf). |
| 28 | + |
| 29 | +Copy `src/cert/` folder to root folder of the EMSK SD card, in SD card, the cert folder should be `cert/`. |
| 30 | + |
| 31 | +The hardware resources are allocated as following table. |
| 32 | + |
| 33 | +| Hardware Resource | Represent | |
| 34 | +| ------------------- | ------------------------------------------------------------- | |
| 35 | +| BUTTON R | Livingroom Lights Control | |
| 36 | +| LED 0-1 | Livingroom Lights Status(On or Off) | |
| 37 | +| BUTTON L | Kitchen Lights Control | |
| 38 | +| LED 2-3 | Kitchen Lights Status(On or Off) | |
| 39 | +| BUTTON X | Front Door Lock Control | |
| 40 | +| LED 4-5 | Front Door Lock Status(On or Off) | |
| 41 | +| LED 7 | WiFi connection status(On for connected, Off for not) | |
| 42 | +| LED X | Node working status(toggling in 2s period if working well) | |
| 43 | +| PMOD TMP2 | Temperature Sensor | |
| 44 | +| PMOD WiFi | Provide WiFi Connection | |
| 45 | + |
| 46 | +EMSK can send the status of the Room Temperature, FrontDoor Lock status, LivingRoom Light status and Kitchen Light status to the AWS IoT and interact with AWS IoT Cloud with using embARC. |
| 47 | + |
| 48 | +Open [dashboard website](http://foss-for-synopsys-dwc-arc-processors.github.io/freeboard/), and load `dashboard-smarthome-singlething.json` dashboard configuration file in current folder, and then you can control and monitor this single node. |
| 49 | + |
| 50 | +After loading this configuration file, you also need to click at the setting icon, and then click on the aws datasource, and then change the **AWS IOT ENDPOINT**, **REGION**, **ACCESS KEY**, **SECRET KEY** to your own aws ones. |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +The JSON Document in the AWS IoT cloud is shown below. |
| 55 | +```json |
| 56 | + { |
| 57 | + "reported": { |
| 58 | + "temperature": 0.00, |
| 59 | + "DoorLocked": false, |
| 60 | + "KitchenLights": false, |
| 61 | + "LivingRoomLights": false |
| 62 | + }, |
| 63 | + "desired": { |
| 64 | + "DoorLocked": false, |
| 65 | + "KitchenLights": false, |
| 66 | + "LivingRoomLights": false |
| 67 | + } |
| 68 | + } |
| 69 | +``` |
| 70 | + |
| 71 | +### Run this application |
| 72 | +Here take **EMSK2.3 - ARC EM7D** with Metaware Toolset for example to show how to run this application. |
| 73 | + |
| 74 | +1. Open Windows or Linux terminal, and cd to `src` folder. |
| 75 | + |
| 76 | +2. To build this applicaiton, select the proper board version, core configuration and build with selected toolchain using this command `gmake BD_VER=23 CUR_CORE=arcem7d TOOLCHAIN=mw` : |
| 77 | + ``` |
| 78 | + <app folder>\src>gmake BD_VER=23 CUR_CORE=arcem7d TOOLCHAIN=mw |
| 79 | + "Creating Directory : " obj_emsk_23/mw_arcem7d/application/. |
| 80 | + "Creating Directory : " obj_emsk_23/mw_arcem7d/arc |
| 81 | + ... ... |
| 82 | + "Assembling : " ../../../../arc/startup/arc_startup.s |
| 83 | + "Compiling : " ../../../../arc/startup/arc_cxx_support.c |
| 84 | + "Generating Linkfile : " obj_emsk_23/mw_arcem7d/linker_mw.ldf |
| 85 | + "Compiling : " main.c |
| 86 | + "Compiling : " ../../../../device/designware/spi/dw_spi.c |
| 87 | + "Compiling : " ../../../../device/designware/iic/dw_iic.c |
| 88 | + "Compiling : " ../../../../device/designware/uart/dw_uart.c |
| 89 | + "Compiling : " ../../../../device/microchip/mrf24g/mrf24g_adapter.c |
| 90 | + ... ... |
| 91 | + "Archiving : " obj_emsk_23/mw_arcem7d/libmidcommon.a |
| 92 | + "Archiving : " obj_emsk_23/mw_arcem7d/libmidaws.a |
| 93 | + "Archiving : " obj_emsk_23/mw_arcem7d/libmidlwip.a |
| 94 | + "Archiving : " obj_emsk_23/mw_arcem7d/libmidfatfs.a |
| 95 | + "Archiving : " obj_emsk_23/mw_arcem7d/libembarc.a |
| 96 | + "Linking : " obj_emsk_23/mw_arcem7d/freertos_iot_aws_smarthomedemo_mw_arcem7d.elf |
| 97 | + ``` |
| 98 | + All object files are generated under the `obj_emsk_23/mw_arcem7d` folder according to your choice. |
| 99 | + The application elf file is also generated in that folder. |
| 100 | + |
| 101 | +3. Connect PMOD WiFi to J5, PMOD TMP2 to J2. |
| 102 | + |
| 103 | +4. Plug the USB cable into the J7 port(JTAG and USB-UART) on EMSK, power on the board, and setup your WiFi hotspot. |
| 104 | + |
| 105 | +5. Configure the EMSK 2.3 to ARC EM7D core by setting the dip switch bit 1-2 all to OFF, then reload the core configuration by press the button above **C** character on board. |
| 106 | + |
| 107 | +6. Open your serial terminal such as Tera-Term on PC, and configure it to right COM port and *115200bps*. |
| 108 | + |
| 109 | +7. Run this application using this command `gmake BD_VER=23 CUR_CORE=arcem7d TOOLCHAIN=mw run` : |
| 110 | +  |
| 111 | + |
| 112 | +8. Interact using EMSK and Dashboard. |
| 113 | + - You can press the **button L/R/X** to see the led changes on board and also on dashboard web app. |
| 114 | + - You can also click the lights of **DESIRED STATUS** pane on the dashboard app, and see the led changes on board and dashboard web app. |
| 115 | +  |
0 commit comments