Scott Hanselman

Did I leave the garage door open? A no-code project with Azure IoT Central and the MXChip DevKit

May 1, '19 Comments [11] Posted in Azure | Hardware
Sponsored By

Azure IoT DevKitFor whatever reason when a programmer tries something out for the first time, they write a "Hello World!" application. In the IoT (Internet of Things) world of devices, it's always fun to make an LED blink as a good getting started sample project.

When I'm trying out an IoT platform or tiny microcontroller I have my own "Hello World" project - I try to build a simple system that tells me "Did I leave the garage door open?"

I wanted to see how hard it would be to use an Azure IoT MXChip DevKit to build this little system. The DevKit is small and thin but includes Wifi, OLED display, headphone, microphone, sensors like temperature, humidity, motion, pressure sensors. The kit isn't super expensive given all it does and you can buy it most anywhere. The DevKit is also super easy to update and it's actively developed. In fact, I just updated mine to Firmware 1.6.2 yesterday and there is an Azure IoT Device Workbench Extension for VS Code. There is also a fantastic IoT DevKit Project Catalog you should check out.

I wanted to use this little Arduino friendly device and have it talk to Azure. My goal was to see how quickly and simply I could make a solution that would:

  • Detect if my garage door is open
  • If it's open for more than 4 minutes, text me
  • Later, perhaps I'll figure out how to reply to the Text or take an action to close the door remotely.

However, there is an Azure IoT Hub and there's Azure IoT Central and this was initially confusing to me. It seems that Azure IoT Hub is a individual Azure service but it's not an end-to-end IoT solution - it's a tool in the toolbox. Azure IoT Central, on the other hand, is an browser-based system with templates that is a SaaS (Software as a Service) and hides most of the underlying systems. With IoT Central no coding is needed!

Slick. I was fully prepared to write Arduino code to get this garage door sensor working but if I can do it with no code, rock on. I may finish this before lunch is over. I have an Azure account so I went to https://azureiotcentral.com and created a new Application. I chose Pay as You Go but it's free for the first 5 devices so, swag.

Create a New Azure IoT Central App

You should totally check this out even if you don't have an IoT DevKit because you likely DO have a Raspberry Pi and it totally has device templates for Pis or even Windows 10 IoT Core Devices.

Azure IoT Central

Updating the firmware for the IoT DevKit couldn't be easier. You plug it into a free USB port, it shows up as a disk drive, and you drag in the new (or alternate) firmware. If you're doing something in production you'll likely want to do OTA (Over-the-air) firmware updates with Azure IoT Hub automatic device management, so it's good to know that's also an option. The default DevKit firmware is fun to explore but I am connecting this device to Azure (and my Wifi) so I used the firmware and instructions from here which is firmware specific to Azure IoT Central.

The device reboots as a temporary hotspot (very clever) and then you can connect to it's wifi, and then it'll connect to yours over WPA2. Once you're connected to Wifi, you can add a new Real (or Simulated - you can actually do everything I'm doing where without a real device!) device using a Device ID that you'll pair with your Mxchip IoT DevKit. After it's connect you'll see tons of telemetry pour into Azure. You can, of course, choose what you want to send and send just the least amount your projects needs, but it's still a very cool first experience to see temp, humidity, and on and on from this little device.

MxChip in Azure

Here's a wonderful HIGH QUALITY diagram of my Garage door planned system. You only wish your specifications were this sophisticated. ;)

Basically the idea is that when the door is closed I'll have the IoT DevKit taped to the door with a battery, then when it open it'll rotate 90 degrees and the Z axis of the Accelerometer will change! If it stays there for more than 5 minutes then it should text me!

image

In Azure IoT central I made a Device Template with a Telemetry Rule that listens to the changes in the accelerometer Z and when the average is less than 900 (I figured this number out by moving it around and testing) then it fires an Action.

The "Action" is using an Azure Monitor action group that can either SMS or even call me voice!

In this chart when the accelerometer is above the line the garage door is closed and when it drops below the line it's open!

The gyroscope Z changing with time

Here's the Azure Monitoring alert that texts me when I leave the garage door open too long.

Azure Activity Monitor

And here's my alert SMS!

mxchip

I was very impressed I didn't have to write any code to pull this off. I'm going to try this same "Hello World" later with custom code using a AdaFruit Huzzah Feather and an ADXL345 Accelerometer. I'll write Arduino C code and still have it talk to Azure for Alerts.

It's amazing how clean and simple the building blocks are for projects like this today.


Sponsor: Manage GitHub Pull Requests right from the IDE with the latest JetBrains Rider. An integrated performance profiler on Windows comes to the rescue as well.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Thursday, May 02, 2019 12:22:06 PM UTC
Thanks for posting this! I have a big overhead garage door that nothing seems to work with... I'll look into this too. I've been thinking about using this open source project: https://opengarage.io
Thursday, May 02, 2019 2:41:43 PM UTC
Any Idea why I do not see a New Rule Button in AzureIOTCentral ? The real device is there....
Rob
Thursday, May 02, 2019 7:16:50 PM UTC
Competition for Chamberlain's MyQ Smart Garage Door Opener!
Todd. M. Taylor
Friday, May 03, 2019 2:21:24 AM UTC
Or you could just use a cheap ZigBee Reed Switch module. I use Home Assistant/Zigbee2Mqtt to do similar automation.
Aron
Friday, May 03, 2019 7:03:40 AM UTC
Nice article. It's amazing what these IoT devices can do with platforms like Azure.

Couldn't you use the pressure of the door on the ground (or near the ground) instead of relying on the z-axis?
We used to have a garage door that would sometimes not close 100%, so the z-axis might not work for such a scenario.
Quintonn
Friday, May 03, 2019 3:04:53 PM UTC
Would go perfect with an iot garage door opener.

https://github.com/leblancmeneses/presentation-raspberrypi-firebase
Friday, May 03, 2019 3:06:13 PM UTC
Great idea!

How do you (or plan to) supply power to the device since it will move freely duck on the door?

Battery?
BOT Eric
Friday, May 03, 2019 6:35:10 PM UTC
This is really cool - I’ve never done any IoT work but I’m going to try to set this up.

Really basic question that I don’t think I saw addressed in the article: how does the MXChip unit get powered in your garage setup? Batteries?
Charlie
Friday, May 03, 2019 6:54:13 PM UTC
Fun idea. Do you have any in at the team that maintains the https://microsoft.github.io/azure-iot-developer-kit/ site? I was looking at the linked page from your article
and trying to find out more about purchasing options there, but it seems like they have broken links on that site. They are already called out in an issue on GitHub, https://github.com/Microsoft/azure-iot-developer-kit/issues/470, but nobody has commented on the issue in 23 days.
Michael
Saturday, May 04, 2019 2:09:19 PM UTC
Interesting project. Could similar app be devised to buzz a warning if the stove has been left on under a pot? This is a real life problem for those of us (or family members) over the age of (ahem) 65. I mean sitting in the next room, not necessarily after leaving the house.
Monday, May 06, 2019 5:55:07 AM UTC
thats realy good body
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.