element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Azure Sphere Starter Kit
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Azure Sphere Starter Kit
  • More
  • Cancel
Azure Sphere Starter Kit
Blog Sphextension
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Azure Sphere Starter Kit requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: marcosconcon
  • Date Created: 11 Jun 2020 2:54 AM Date Created
  • Views 810 views
  • Likes 4 likes
  • Comments 1 comment
  • azurespherehomehacks
  • homewhackdch
Related
Recommended

Sphextension

marcosconcon
marcosconcon
11 Jun 2020

image     Introduction

The first thought that came to mind about this "Home Is Where the Hack Is" Challenge was to build and improve on some appliances I had lying around my home with the goal of fun usability.

I had a spare unused power extension and thought it would be awesome to integrate the Azure Sphere with it to securely and remotely control household appliances powered by the extension, thus giving birth to the Sphextension (Sphere + Extension)!

 

image     Video

Here's the project demonstration, do turn on subtitles for some of the comments.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

image     Code

CODE LINK

 

image     Project Overview

 

There are three main parts to this project which are the customized mobile application for the control interface, cloud integration for remote control of the appliance, and finally the firmware on the Azure sphere itself.

 

image     Mobile Application Development

For this part, I had the aim of building on a platform that does not require installing Xcode or Android Studio for application development. Aside from the additional installation of these IDE's, there are big learning curves associated with building on those platforms. I've had prior experience with building web applications on the React framework and thought it would translate nicely to develop for a React-native mobile application in this challenge. So after digging around, I found Expo to be the perfect framework and platform for this project due to the fact that I can write and deploy code right from the Visual Studio Code development platform. Visual Studio Code is also used as the platform for firmware development on the Azure Sphere and thus building on Expo makes it convenient to develop and deploy code right from the same platform.

 

image

 

However, there are some caveats to building on this platform which is explained in the next part...

 

image     Cloud Integration

I initially planned to integrate the Azure IoT SDK within the custom mobile application, but with the Expo framework being relatively new and Azure having limited support for native mobile applications as of now, I had to settle with a cloud service that can achieve the project's functionality while still coupled to the Expo framework. I used Firebase, specifically the Realtime Database service to connect the mobile application and the Azure Sphere. Having good documentation, support for the Expo framework and a generous free allocation every month for service usage was perfect for this project's use case.

image

 

image     Azure Sphere Firmware

 

For this project's use case, there are two functionalities required. The first is having the capability to access the Cloud service in which the Azure sphere collects data on the state (ON/OFF) for each appliance connected to the power extension. The second is having the capability to send the appropriate signal to GPIO's to switch ON/OFF an appliance based on the state obtained from the cloud. The two Azure Sphere code sample links below were used and modified to achieve these functionalities. Visual Studio Code was the main development platform used to develop and deploy code to the Azure Sphere.

 

  • https://github.com/Azure/azure-sphere-samples/tree/master/Samples/HTTPS/HTTPS_Curl_Easy - to periodically obtain appliance state data (ON/OFF) from the cloud set by the mobile application.
  • https://github.com/Azure/azure-sphere-samples/tree/master/Samples/GPIO/GPIO_HighLevelApp - to set the appropriate signal to the GPIO for switching ON/OFF based on the obtained state data.

 

image     Hardware & Prerequisites

 

Before diving into the build process, here's the hardware used for the project.

  • Power Extension - to power the appliances

image

 

  • Relays - to safely switch ON/OFF high voltage appliances.

image

 

  • Azure Sphere - a secure high-level application platform with built-in communication and security features for internet-connected devices.

image

 

Here are the prerequisites before starting the project.

 

Visual Studio & Azure Sphere

  1. Visual Studio development platform installed with the C++ environment.
  2. The Azure Sphere SDK installed in your system.
  3. The Azure Sphere Extension installed on the Visual Studio platform.
  4. Claim the Azure Sphere for our tenant and connect it to your WiFi network.

 

Expo framework

  1. Download NodeJS in your system.
  2. Install the Expo command-line tool.
  3. The Expo Client on your mobile platform for realtime debugging & development. IOS or Android.

 

Firebase

  1. Create a Firebase project.
  2. Get and save your Firebase configurations to interface Firebase Realtime Database with Expo Framework

 

image     Develop

 

image     Expo App with Firebase Integration

 

We start by developing the mobile application first. Once the 'expo start' command is run on the terminal, a local development server is initialized where the QR code can be scanned by your phone to view and debug in realtime the code developed for the application.

image

A simple user interface is designed on the application to control appliances such as Table Lamps and Electric Fans.

 

 

image

 

 

And here's a code snippet to store the state based on button presses to the Firebase Realtime Database. A switch case to determine what appliance is being switched ON/OFF where tl is the Table Lamp, ef is the Electric Fan and ps is an additional Power socket to be controlled.

image

 

image     Verifying data on Firebase Console

 

image

 

 

image     Azure Sphere Firmware

 

First, we set the app_manifest.json file to include capabilities to connect to the Firebase Realtime Database and to allow signaling to the GPIO's used in the project.

image

 

 

Next, the CMakeLists.txt is modified to include the hardware descriptors of the Azure Sphere as well as including the Root Certificate of the web service that is being accessed.

image

 

 

Here's the code snippet that checks whether the obtained data from Firebase (obtained via the libcurl sample code) is to set an appliance ON/OFF. Raw string comparison isn't probably the best for comparison of data and a JSON library such as this is much better for tokenization since the data obtained from Firebase is JSON formatted. That will be for future improvements but for now, this approach works out.

image

 

 

image    Putting it all together

 

 

Here are the disassembly and connections of the Relay modules, Power Extension and the Azure Sphere.

image

 

 

And after all the wire configurations have been made and tested, the Azure Sphere and the Relay modules will be nicely tucked away when the cover is placed.

image

 

I do hope to document the whole build process even further as I only knew about this challenge one week before the deadline. Anyways, cheers to the organizers for coming up with this challenge, it was definitely one!

  • Sign in to reply
  • kevinkeryk
    kevinkeryk over 2 years ago

    The project looks like fun, hope you see it through to completion marcosconcon!

     

    Best Regards,

     

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube