Program MKR Over-the-Air + Goodies: Voice Control, etc.

Secure OTA via Azure. Control via voice capable UWP app. Includes sample: room thermostat controlled via phone.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
This is needed for every OTA projects. The components below are needed only for the use case / sample: the room thermostat.
× 1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
× 1
Relay (generic)
× 1
Breadboard (generic)
Breadboard (generic)
× 1

Software apps and online services

Arduino IDE
Arduino IDE
Microsoft Azure
Microsoft Azure
Microsoft Azure IoT Hub
Visual Studio 2015
Microsoft Visual Studio 2015
Using UWP (Universal Windows Platform)
Microsoft Azure
Microsoft Azure
Microsoft Project Oxford (Speech Recognition API)

Story

Part 2: Use Case / Sample: Room Thermostat

As mentioned before, we developed the room thermostat to demonstrate how one can combine our components to build a real life project. In our case, we even put it into production, i.e. it controls the heating of our office.

The logic is simple:

  • when the temperature drops below the preset temperature => the relay (i.e. heating) turns ON
  • when the temperature is above the preset temperature => the relay/heating turns OFF
  • the user interface/UWP client: shows the status, and sets the preset temperature (via text box or voice)
YouTube: the room thermostat in action

1. Make the Project (Hardware)

We don’t provide a Fritzing diagram, as we use a Beta MKR1000. Pin layout may change in the future.

2. Setup the Dev Environment for OTA and Azure IoT Hub

  • Install Arduino IDE, at least version 1.6.7
  • Install Arduino SAMD Boards. From Arduino IDE: Tools > Board: … > Boards Manager … > select “Arduino SAMD Boards”
  • Download and unzip some libraries in: SKETCHBOOK_DIR (e.g. Documents/Arduino)/librariesWiFi101AzureIoTRTCZero.

And now our components:

  • Download and unzip the OTA run-time library in: SKETCHBOOK_DIR (e.g. Documents/Arduino)/libraries.
  • Download our custom “boards” package. Create a directory: SKETCHBOOK_DIR (e.g. Documents/Arduino)/hardware/flower-platform. Unzip the downloaded file here.
  • Download the Arduino IDE plugin. Create a directory: SKETCHBOOK_DIR (e.g. Documents/Arduino)/tools. Unzip the downloaded file here.

For secure OTA via Internet/HTTPS:

  • Download IoT Dispatcher and install it on a PHP + MySQL server. E.g. we have instructions on how to deploy in the Microsoft Azure Cloud.

3. Test Drive OTA

There are 3 OTA upload methods.

1) Try OTA via LAN: File > Examples > Arduino-FlowerOTA > WiFiOTA. Change the lines commented with “// CHANGE ME” accordingly, in order to configure the IP address, WiFi parameters, plain/ssl, server signature. Then Flower Platform > Upload OTA …

Make sure you use:

WiFiClient client;

and (cf. the “server signature” from the popup window).

ota.begin(&udp, &client, "1hvtdliHzKLjMykvfW1MfPwsFthUU/YfjN8fOZJ3Qhc=");

NOTE: for all the 3 methods, you need to do an initial upload via USB. After that, you can continue to use OTA, with the method of your choice.

2) Try OTA via secure dispatcher, using the same file:

Make sure you use:

WiFiSSLClient client;

and

ota.begin(&udp, &client, "my-iot-dispatcher-upload-key"); // cf. configured within IoT Dispatcher (PHP)

3) Try OTA via secure dispatcher + Azure IoT Hub. File > Examples > Arduino-FlowerOTA > WiFiOTA-AzureIoTHub. Again: don’t forget to adjust the lines commented with “// CHANGE ME“.

4) Try the use case / sample: the room thermostat. It’s available here.

4. Test Drive the User Interface (UWP App w/ Azure IoT Hub and Speech Recognition)

The UWP project is available here. Visual Studio 2015 and Windows 10 are needed.

Make sure you change the connection parameters cf. your Azure account:

SendCloudToDevice.cs

    class SendCloudToDevice
    {
        // CHANGE ME: Please replace the constants below, with actual values (taken from your Azure Portal)
        private const string HOST = "???.azure-devices.net";
        private const string DEVICE_ID = "???";
        private const string DEVICE_KEY = "???";
        static string sharedAccessKeyName = "???";
        static string sharedAccessKey = "???";

ReadDeviceToCloud.cs

    class ReadDeviceToCloud
    {
        // Please replace the constants below, with actual values (taken from your Azure Portal)
        private static string ConnectionString = "???";
        private static string eventHubEntity = "???";

This code can serve as starting point for client apps for various project. You only need to adjust the user interface according to your project.

Future Steps

Boards such as the Arduino MKR1000, that have reasonable processing power and SSL communication capabilities, represent a huge step forward for the community of makers.

We are continuing the work started with this project, in order to develop Flower Platform IoT, an online service which would tremendously accelerate IoT projects:

  • development: use of OOP components and graphical programming language (that can be mixed with hand written code);
  • deployment: use of OTA.

Leveraging the Flower Platform, we plan to create a foundation that will focus on teaching young children to make and program IoT projects.

Schematics

Close up photo

We don’t provide a Fritzing diagram, as we use a Beta MKR1000. Pin layout may change in the future.
20160330 182552

Code

 


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top