Skip to content

compulim/codeaholics-iot-demo

Repository files navigation

Codeaholics meetup: Alexa + Azure IoT + Arduino

This is the repository for Codeaholics meetup on 2017 January, presented by William Wong.

Devices

Device name Description
bridge Bridge for device discovery and health check
powerStrip1 Power strip controller

Preparation

Install Arduino IDE

  1. Install Arduino IDE
  2. Install Sparkfun ESP8266 Thing Dev board by following these steps

Prepare Azure IoT Hub

  1. Create Azure Iot Hub, write down the connection string for iothubowner
  2. Log into IoT hub
    • iothub-explorer login HostName=<iot hub name>.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=<iot hub key>
  3. Create bridge device
    • iothub-explorer create bridge
  4. Create powerStrip1 device
    • iothub-explorer create powerStrip1

How to use

Setup Sparkfun ESP8266 Thing Dev

  1. Run Arduino IDE
  2. Open arduino/StandardFirmataWiFi/StandardFirmataWiFi.ino
  3. Modify arduino/StandardFirmataWiFi/wifiConfig.h
    1. Modify line 122, update char ssid[] = "<Your SSID>";
    2. Modify line 129, update #define STATIC_IP_ADDRESS 192,168,0,123
    3. Modify line 154, update char wpa_passphrase[] = "<Your password>";
  4. Upload the sketch to your Sparkfun ESP8266 Thing Dev

Setup AWS Lambda

AWS Lambda is required for using Alexa Smart Home Skill API.

  1. Follow Alexa instructions to setup Alexa app and AWS Lambda
  2. Compress the folder lambda and upload it to AWS Lambda

Setup local Node.js bridge

  1. Modify bridge/lib/config.js to provide connection strings
  2. Modify bridge/lib/powerStrip1.js if you are using different pin for control and status, default is pin 15 and 4 respectively
  3. Under bridge/, run npm start

Build the board

Board design

Development points

Sparkfun ESP8266 Thing Dev

AWS Lambda

Local Node.js bridge

  • Set environment variable DEBUG to device* for debugging

Azure IoT Hub explorer

Currently iothub-explorer is buggy and does not work with device methods, we wrote some CLI scripts to invoke device methods for testing.