Repository navigation
2. Exercises
Check out this Exercise #1 Video if you need help.
1.1 Get board and sensors
host instructor will hand you a kit containing all the parts, check the list of contents. The Wio Node device box should have a "device name" on it, for example, dev-803. (Note: in the video, we used serial number D2D117, we changed it to dev-[Seq#] format, so it is easier to find device).
1.2 Download Wio App
We use a Wio App to set up sensors on devices. You can download the app for iPhone, in Apple Store, search for "wio link". And for Android phone, in Google Play store, search for "wio".

1.3 Configure Wio App
We host a Wio virtualization server on Oracle Cloud, so you need point your Wio app to the server.
customize server: http://129.150.86.239:8080

1.4 Login to Wio App
We will use a common event account, where we register all Wio Node boards there. Host instructor will let you know the account and password to login.

On your Wio Node device box, it should have a "device name" with sequence number, such as dev-803, and try to find your device with that name from the list in the Wio App. For example, if you have a box with dev-3103, then the first device on the list is yours.
Check out this Exercise #2 Video if you need help with details.
2.0 Power Wio Node using micro-USB cable
After a while, refresh the device list in Wio App, and you should see your device in Wio App to show "online" state.
2.1 Connect sensors to board
Please connect Light sensor and buzzer to Wio board, as shown in this diagram:

Note that we connect Light Sensor (aka Luminance Sensor) to right-hand size of port which is an analog port, and Buzzer (aka Speaker) to left-hand size digital port.
2.2 Connect sensor in Wio App
In the Wio App, we need to connect Light Sensor (aka Luminance Sensor) and Buzzer (aka Speaker) to reflect exactly how you connected them physically at step 2.1.

This tells Wio server how the device and sensors are connected, so that Wio server can produce corresponding firmware for your Wio Node.
2.3 Update firmware
Whenever you change the sensors in Wio App at step 2.2, it will show the button Update Firmware in red color. You need to click that button, to trigger Wio server to update device firmware over the air.
2.4 Go to API page
Using either View API button or menu item to get to API page. Look at the API page details, and you will find various APIs to interact light sensor and buzzer. You can interact with sensors on the board, by using the API calls.
2.5 Read light sensor data
Refer the picture diagram at Step 2.4 above, look for luminance API in your Wio App View API page and perform a read on light sensor by clicking "GET" button.
2.6 Play a sound on buzzer
Refer the picture diagram at Step 2.4 above, look for sound_ms API, and produce a buzzer sound by giving sound frequency and duration and clicking "POST" button.
2.7 summary of what you just did for this exercise
You just used Wio App and its API page to interact with sensors and buzzer on the Wio Node board. So far, no programming needed. In Exercise #3 below, we will write Javascript program invoking those API through library calls.
Check out this Exercise #3 Video if you need check step details.
3.1 Download and install Node.js
Follow this link to Install Node.js on MacBook
Follow this link to Install Node.js on Windows
Follow this link to Install Node.js on Linux
Type "node -v" in a command line window to verify Node.js is installed properly.
3.2 Download project source code
Goto this page: https://github.com/raymondxie/iotws18, read information on that page to understand usage of various source files. Then download source code and unzip into a project folder iotws18-master
Then in command line window, go to the directory iotws18-master, and execute
npm install
it will fetch all necessary npm library package used by this project as specified in package.json file.
3.3 Check configuration
You need to have an access_token for running program to access the board and connected sensors. Go to project folder iotws18-master, open sensor-config.js file, and look for setting for "wio_iot":
exports.wio_iot = {
"location": "http://129.150.86.239:8080",
"access_token": "94ef3060fb964724e42c1f3d1c6cd116"
};
Please verify location is set to proper Wio server, and change access_token to match with the token in your Wio App. Refer the API page in your Wio App, for example:
3.4 Write a Javascript program to make a buzzer sound
We provided you a starter code testWio.js, and check out the API calls in that file. To test, you can open a command window, and navigate to folder iotws18-master, and execute:
node testWio.js
You should hear a buzzer sound, and some readings from light sensor.
Now it is your turn to write a Javascript program, to make a sound on buzzer when light sensor reading is below 500.
Use sample code testWio.js as a reference to call API, and try to write Javascript code to get light sensor reading, and based on its value and decide to make a buzzer sound or not. If you you can't write Javascript code, you can skip it and just run the solution code testWio-solution.js at Step 3.5
3.5 Run the solution code
node testWio-solution.js
Now, hold the light sensor in your palm to block light, and observe the output log to see light sensor reading dips below 500, and buzzer makes a sound.
3.6 Summary of what you just did
You have coded a Javascript program to interact with Wio Node and connected sensors and actuators, programmatically.
4.1 Connection and Configuration file
You will need to configure sensor-config.js, to reflect what sensor is connected on which pin connector of the board, and that sensor reading is mapped to what data attribute defined in device model in IoTCS. Also you need configure the server location and access token to Wio virtualization server.
Refer to diagram image at step 3.3 for illustration where in the Wio App to get the pin, property, token, and location information for the configuration, here is the link to that diagram: information for sensor-config
which corresponds to settings in sensor-config.js
{
"type": "INPUT",
"pin": "GroveLuminanceA0",
"property": "luminance",
"attr": "light",
"val": 0
},
exports.wio_iot = {
"location": "http://129.150.86.239:8080",
"access_token": "1cc875f90c3ef2bdff66696cc9496bea"
};
4.2 Security provision
Ask host instructor to give you a security provision file, and its password. The file name should like "dev-[sequence#].csv", for example, dev-101.csv. Put it in the project folder iotws18-master.
4.3 Run IoTCS client program
We provided wio-iotcs-client.js code, which works with sensor-config.js file, and executes all logics for you. Make sure you "sensor-config.js" is properly reflect your device setup, and execute in a command line terminal:
node wio-iotcs-client.js [provision-file] [provision-password]
where [provision-file], [provision-password] is what you got from instructor at step 4.2. For example,
node wio-iotcs-client.js dev-101.csv MyCityName1
You should see some log messages, and light sensor readings; and when sensor reading changes, the data is sent to IoTCS.
4.4 Check sensor reading in IoT Asset Monitor
Check with host instructor about the sensor reading in IoT Asset Monitor chart, here is an example chart: sensor-reading-chart
4.5 Trigger buzzer sound from IoT Asset Monitor
Check with host instructor to trigger buzzer from IoT Asset Monitor to make sound on your device, here is the UI interface: buzzer-manual-button
By now, you have completed all exercises for the workshop session. If you like, you can continue to try the Temperature & Humidity sensor and LED bar. Just follow with Exercise #2, replacing Light sensor with Temperature & Humidity sensor, replacing buzzer with LED bar.
Here are some examples of connecting various sensors to the Wio Board, for your reference:
Wio-node with light sensor and LED bar
Wio-node with temperature sensor and a buzzer
When you get home, the Wio Node device no longer has access to the WiFi network you used at IoT Workshop, so you need to follow this setup instruction - Getting Started, to set your home WiFi network SSID and password to Wio Node device, so it can connect to Internet.
Also you can use the Wio Global server, instead of the Customize server used in the IoT Workshop. You need sign up an account on the Global server, add your device to your account. Please just follow Getting Started guide, from step 1 to step 5. You can replace the Grove LED used in the guide, with LED bar we supplied.