Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Committer:
JimCarver
Date:
Thu Oct 25 14:00:12 2018 +0000
Revision:
4:e518dde96e59
Parent:
0:6b753f761943
Simulated dispenser

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JimCarver 0:6b753f761943 1 # Mbed Cloud Workshop - Connect Service
JimCarver 0:6b753f761943 2
JimCarver 0:6b753f761943 3 ## Embedded Application
JimCarver 0:6b753f761943 4
JimCarver 0:6b753f761943 5 ### Prerequisites
JimCarver 0:6b753f761943 6 1. Install [Mbed CLI](https://os.mbed.com/docs/latest/tools/installation-and-setup.html)
JimCarver 0:6b753f761943 7 1. Register for an [Mbed OS account](https://os.mbed.com/account/signup/) (if you do not already have one)
JimCarver 0:6b753f761943 8 1. Register for an [Mbed Cloud account](http://cloud.mbed.com/quick-start)
JimCarver 0:6b753f761943 9 1. Download the code: `mbed import https://github.com/BlackstoneEngineering/mbed-cloud-workshop-connect`
JimCarver 0:6b753f761943 10
JimCarver 0:6b753f761943 11 ### Let's Code: Device to Dashboard
JimCarver 0:6b753f761943 12 1. Create a Developer Certificate for your device
JimCarver 0:6b753f761943 13 1. Log into the [Mbed Cloud Portal](https://portal.mbedcloud.com/) with your developer account.
JimCarver 0:6b753f761943 14 1. Go to **Device Identity** -> **Certificates**.
JimCarver 0:6b753f761943 15 1. Click **Actions** -> **Create a developer certificate**.
JimCarver 0:6b753f761943 16 1. Enter a certificate file name. This file name is for your convenience. For example: `Jenny_Plunkett`
JimCarver 0:6b753f761943 17 1. Click **Create Certificate**.
JimCarver 0:6b753f761943 18 1. A credentials C file called `mbed_cloud_dev_credentials.c` is created. It contains the credentials you need to connect your device to Mbed Cloud.
JimCarver 0:6b753f761943 19 1. Download the file and copy/paste it into your `mbed-cloud-workshop-connect` project folder
JimCarver 0:6b753f761943 20 1. Change the wifi SSID and password credentials at the top of `main.cpp`
JimCarver 0:6b753f761943 21 - SSID: `mbed`
JimCarver 0:6b753f761943 22 - Password: `mbedisawesome`
JimCarver 0:6b753f761943 23 1. Plug the board into your computer
JimCarver 0:6b753f761943 24 1. Compile, flash, and view the board's serial output
JimCarver 0:6b753f761943 25 - `mbed compile --target auto --toolchain GCC_ARM --flash --sterm`
JimCarver 0:6b753f761943 26 1. View your Mbed Cloud Portal dashboard: https://portal.mbedcloud.com/dashboard/usage
JimCarver 0:6b753f761943 27
JimCarver 0:6b753f761943 28 ### Let's Code: Make Device Blink
JimCarver 0:6b753f761943 29 - Read number of button presses – GET from "3200/0/5501", "button_count"​
JimCarver 0:6b753f761943 30 - Make LED’s Blink – POST to "3201/0/5850", "blink_action” ​
JimCarver 0:6b753f761943 31 - Change LED Blink Pattern – PUT to "3201/0/5853", "blink_pattern”
JimCarver 0:6b753f761943 32
JimCarver 0:6b753f761943 33 ### Let's Code: Challenge
JimCarver 0:6b753f761943 34 - Change variables in Developer Certificate
JimCarver 0:6b753f761943 35 - Serial, name, device type ... etc.
JimCarver 0:6b753f761943 36 - Add variables with multiple functions GET/PUT/POST
JimCarver 0:6b753f761943 37
JimCarver 0:6b753f761943 38 ## Web App
JimCarver 0:6b753f761943 39
JimCarver 0:6b753f761943 40 ### Let's Code: Web App
JimCarver 0:6b753f761943 41 1. Install [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/)
JimCarver 0:6b753f761943 42 1. Clone the Mbed Cloud SDK JavaScript Quickstart to your computer
JimCarver 0:6b753f761943 43 - `git clone https://github.com/ARMmbed/mbed-cloud-sdk-javascript-quickstart`
JimCarver 0:6b753f761943 44 1. `cd mbed-cloud-sdk-javascript-quickstart`
JimCarver 0:6b753f761943 45 1. Install the required npm packages: `npm install`
JimCarver 0:6b753f761943 46 1. Create your API key
JimCarver 0:6b753f761943 47 1. Open the Mbed Cloud Portal: https://portal.mbedcloud.com/
JimCarver 0:6b753f761943 48 1. In the Cloud portal, navigate to **Access management** > **API keys**
JimCarver 0:6b753f761943 49 1. Click **Create new API key**.
JimCarver 0:6b753f761943 50 1. Define the API key name. For example: `Jenny`
JimCarver 0:6b753f761943 51 1. Select the key's group. Note that the key will have the same privileges as the group you select, meaning an administrator key will have full privileges.
JimCarver 0:6b753f761943 52 1. Click **Create API key**. A key is generated.
JimCarver 0:6b753f761943 53 1. Copy the generated API key.
JimCarver 0:6b753f761943 54 1. Open `app.js`
JimCarver 0:6b753f761943 55 - Replace the `<access key>` placeholder in the `accessKey` variable on line 8 with the API key you just copied
JimCarver 0:6b753f761943 56 1. Run the app: `node app.js`
JimCarver 0:6b753f761943 57 1. Open `http://localhost:8080` in your browser
JimCarver 0:6b753f761943 58 1. You should now see a list of connected Mbed Cloud JavaScript Quickstart devices
JimCarver 0:6b753f761943 59 <img width="946" src="/img2.png">
JimCarver 0:6b753f761943 60 1. If you open the Mbed Cloud portal (https://portal.mbedcloud.com/) you should also see your device listed under **Device directory** > **Devices**
JimCarver 0:6b753f761943 61 <img width="835" src="/img1.png">
JimCarver 0:6b753f761943 62
JimCarver 0:6b753f761943 63 ### Let's Code: GET/PUT/POST to Device
JimCarver 0:6b753f761943 64 1. Subscribe to your board's simulated button presses by clicking on the checkbox next to **Subscribe** and then click **Get presses (GET)**
JimCarver 0:6b753f761943 65 1. Type `500:500:500:500` into the text box below **LED blink pattern**
JimCarver 0:6b753f761943 66 - This pattern indicates that the LED on the board will turn on for 500 ms, turn off for 500 ms, turn on for 500 ms, and then turn off for 500 ms (and then stay off)
JimCarver 0:6b753f761943 67 1. Click **Update (PUT)**
JimCarver 0:6b753f761943 68 1. Now click **Blink (POST)** and verify that your board's LED blinked twice