This application is designed to show how to connect only 1 EMSK and AWS IoT Cloud using embARC. The connection between EMSK and AWS IoT Cloud is secured by TLS.
- DesignWare ARC EM Starter Kit(EMSK)
- Digilent PMOD WiFi(MRF24WG0MA)
- Digilent PMOD TMP2
- SD Card
- WiFi Hotspot(SSID:embARC, Password:qazwsxedc, WPA/WPA2 encypted)
- Metaware or ARC GNU Toolset
- Serial port terminal, such as putty, tera-term or minicom
-
Configure your hardware with proper core configuration.
Prepare you own AWS IoT account, and create required thing.
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 for details, and generate certificates and download them and rename them to the ones under src/cert/smarthome/
.
We also provided an application note about Using a Smart Home Iot Application with EMSK.
Copy src/cert/
folder to root folder of the EMSK SD card, in SD card, the cert folder should be cert/
.
The hardware resources are allocated as following table.
Hardware Resource | Represent |
---|---|
BUTTON R | Livingroom Lights Control |
LED 0-1 | Livingroom Lights Status(On or Off) |
BUTTON L | Kitchen Lights Control |
LED 2-3 | Kitchen Lights Status(On or Off) |
BUTTON X | Front Door Lock Control |
LED 4-5 | Front Door Lock Status(On or Off) |
LED 7 | WiFi connection status(On for connected, Off for not) |
LED X | Node working status(toggling in 2s period if working well) |
PMOD TMP2 | Temperature Sensor |
PMOD WiFi | Provide WiFi Connection |
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.
Open dashboard website, and load dashboard-smarthome-singlething.json
dashboard configuration file in current folder, and then you can control and monitor this single node.
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.
The JSON Document in the AWS IoT cloud is shown below.
{
"reported": {
"temperature": 0.00,
"DoorLocked": false,
"KitchenLights": false,
"LivingRoomLights": false
},
"desired": {
"DoorLocked": false,
"KitchenLights": false,
"LivingRoomLights": false
}
}
Here take EMSK2.2 - ARC EM7D with Metaware Toolset for example to show how to run this application.
-
Open Windows or Linux terminal, and cd to
src
folder. -
To build this applicaiton, select the proper board version, core configuration and build with selected toolchain using this command
gmake BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=mw
:
embarc_osp\application\aws_iot_smarthome\src>gmake BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=mw
"Creating Directory : " obj_emsk_22/mw_arcem7d/application/.
"Creating Directory : " obj_emsk_22/mw_arcem7d/arc
... ...
"Assembling : " ../../../../arc/startup/arc_startup.s
"Compiling : " ../../../../arc/startup/arc_cxx_support.c
"Generating Linkfile : " obj_emsk_22/mw_arcem7d/linker_mw.ldf
"Compiling : " main.c
"Compiling : " ../../../../device/designware/spi/dw_spi.c
"Compiling : " ../../../../device/designware/iic/dw_iic.c
"Compiling : " ../../../../device/designware/uart/dw_uart.c
"Compiling : " ../../../../device/microchip/mrf24g/mrf24g_adapter.c
... ...
"Archiving : " obj_emsk_22/mw_arcem7d/libmidcommon.a
"Archiving : " obj_emsk_22/mw_arcem7d/libmidaws.a
"Archiving : " obj_emsk_22/mw_arcem7d/libmidlwip.a
"Archiving : " obj_emsk_22/mw_arcem7d/libmidfatfs.a
"Archiving : " obj_emsk_22/mw_arcem7d/libembarc.a
"Linking : " obj_emsk_22/mw_arcem7d/freertos_iot_aws_smarthomedemo_mw_arcem7d.elf
All object files are generated under the obj_emsk_22/mw_arcem7d
folder according to your choice.
The application elf file is also generated in that folder.
-
Connect PMOD WiFi to J5, PMOD TMP2 to J2.
-
Plug the USB cable into the J7 port(JTAG and USB-UART) on EMSK, power on the board, and setup your WiFi hotspot.
-
Configure the EMSK 2.2 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.
-
Open your serial terminal such as Tera-Term on PC, and configure it to right COM port and 115200bps.
-
Run this application using this command
gmake BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=mw run
: -
Interact using EMSK and Dashboard.