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

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

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


This project enables secure Over-the-Air (OTA) firmware updates for the Arduino MKR1000 via Microsoft Azure IoT Hub and features a Universal Windows Platform (UWP) app with voice control capabilities. A sample room thermostat demonstrates these components, using a DHT11 sensor to monitor temperature and a relay to control heating based on voice or phone commands. The solution includes reusable libraries, an IoT dispatcher, and a custom UWP interface for real-world IoT deployment.

Parts used in the Secure OTA Thermostat Project:

  • Arduino MKR1000
  • DHT11 Temperature & Humidity Sensor
  • Relay (generic)
  • Breadboard (generic)

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)/libraries: WiFi101, AzureIoT, RTCZero.

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

 

Quick Solutions to Questions related to Secure OTA Thermostat Project:

  • How does the thermostat control the heating system?
    The relay turns ON when the temperature drops below the preset level and turns OFF when the temperature is above it.
  • Can I use voice commands to control the device?
    Yes, the UWP client app recognizes spoken commands via the Microsoft Project Oxford Speech Recognition API.
  • What software is required to set up the development environment?
    You need Arduino IDE version 1.6.7 or higher, Visual Studio 2015, and specific libraries like WiFi101 and AzureIoT.
  • Is an initial USB connection necessary before using OTA?
    Yes, you must perform an initial upload via USB before switching to any of the three OTA methods.
  • Does the project support secure OTA over the Internet?
    Yes, it supports secure OTA via HTTPS using an IoT Dispatcher installed on a PHP + MySQL server.
  • What hardware component is essential for every OTA project in this guide?
    The Arduino MKR1000 is needed for every OTA project described in the article.
  • Can the UWP app be used as a starting point for other projects?
    Yes, the UWP client code can serve as a starting point for various IoT projects with different user interfaces.
  • Where is the firmware stored during the OTA process?
    The IoT Dispatcher application stores and serves the firmware on a third-party server like Microsoft Azure.

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
Scroll to Top