Smart Shades with Windows IoT 1

I wanted to be able to have my office shades go up or down automatically, depending on the amount of light outside. Then I thought, why not take it to the next level with Windows IoT?  I could design a UI with the help of the recently open-sourced Telerik UI for UWP and also leverage a FEZ HAT’s & Raspberry Pi 3 to drive the motors, detect light levels and temperature.

Why would I want to also measure temperature? Because if it were too hot inside, I wouldn’t want to open the shades even if it were light outside.

I’ll go into detail about the software and hardware, but before I do: here’s the GitHub repo with the source code and lets watch a short video of the UI animation and motor in action.

About the Hardware

The hardware you see is a Raspberry Pi 3 (can also be a Pi 2), a FEZ HAT, and a 90 degree motor (like this one). That motor is connected to the FEZ HAT’s Motor A connection, however I also have a second smaller 1:150 motor connected to Motor B (I am still testing out torque of different motors to see which is small and powerful enough to raise a shade).

The FEZ HAT has a great built-in motor driver so that you only need to connect a more powerful external power source to drive the motors. This is the two black wires you see connected to the FEZ HAT on the left.

2017-02-14_1600.png

About the Software

I built the app to be scalable, so there’s a ShadeItemViewModel that contains all the logic to control each shade independently of each other, but still use the same FEZ HAT.

The UI you see is DashboardPage.xaml, it has a GridView at the top with an item for each ShadeItemViewModel. Under the GridView is the light and temperature measurements displayed in a Telerik RadGauge control with LinearGaugeIndicators.

Each item in the GridView has command buttons to open and close the shade, but also a custom control I made that indicates the current position of the shade.

2017-02-14_16-12-43.jpg

 

In the ShadeItemViewModel there are several properties to help tweak the motor speed and for how long to run the motor. I considered using a servo for a while, but I’d need to build a very high ration gear set to turn the degrees of the servo rotations of the shade. It’s easier and more scalable to use time.

This way anyone can change the time and speed of the motor from the settings button to fit their shade’s length. Also, the way the “% complete” algorithm works, it will adapt to the current settings and give proper percentages and it opens or closes.

I’m still experimenting with the motors. I’ll be 3D printing up some housings, and likely gears, to connect the motor to the shade. Once that’s complete, I’ll be writing part 2 of this series and give you all an update with any additional STL files so you can print up the parts for the motors.

Until then, enjoy running/exploring the code and trying it out for yourself!

 

Adding Telerik Universal

Telerik has released a new toolset, UI for Windows Universal. You can now use many components like Charts and Calendars in a shared XAML page in your application. If you already have the Telerik Windows Phone or Windows 8.1 XAML controls, you now have a license for the Universal controls, too.

It is very simple to add it to your project. Let me show you in a quick File > New example:

1- Open Visual Studio 2013 and create a new Universal Store app.

Select File > New > Project > Visual C# > Store Apps > Universal Apps and choose the HubApp template (you can choose Blank App if you prefer, we’re only going to use the Shared folder to add content).

S1

2- After the project generates, let’s focus on the solution Explorer. First, lets add the Telerik reference to the Windows project.

Right click on References > Add Reference > select Windows 8.1 (in the left tree) > Extensions. Now you’ll see a list of extensions, choose “Telerik UI for Windows Universal

S2

3- Now add the Telerik extension to the Windows Phone project.

The steps are the sames as you did in step 2, but the extension’s name is “Telerik UI for Windows Phone 8.1

S3

4- Now we are ready to start building, let’s add a RadCalendar to a shared XAML page.

  1. Build the solution (F6)
  2. Right click on the Shared Project and select Add > New Item > Blank Page
  3. In the Visual Studio Toolbox type in “RadCalendar“, drag and drop it onto your new blank page. You can also type it in, but make sure you add the namespace (see screenshot)

S4

You can also see how the control will on Phone by simply toggling the view:

S5

That’s all there is to it!

Here are some more resources for you:

One last thing I should mention is that not all the Windows 8.1 controls are Universal right now. We are hard at work to bring more over. Here is a list as of Q3 2014:

Redeeming a Nokia Premium Developer Program token

There have been many questions recently about how to properly redeem your shiny new Nokia Premium Developer Program. What better way than to record a video for you? Without further ado, here is how to redeem the token, as well as how to get at the Telerik goodness in the center.

[youtube=http://www.youtube.com/watch?v=LDEJPi-B8f8&rel=0]

After doing this, you’ll know how to get the Microsoft DevCenter token as well as the Buddy.com token because it is the same process to retrieve the individual tokens.

Enjoy!

26.2 Smiles

The Boston Marathon gives you 26.2 miles, but the The Boston Hackathon can give you 26.2 smiles!

eventbrite_450x200

I am throwing a huge bash of a hackathon during the weekend of the marathon (april 13th – 14th). Awesome prizes awarded for your guts, and recognition for your glory. Just showing up proves your level of awesomeness, so you’ll get $1,500 worth of goodies just for building an app

Here’s a snapshot of the prizes:

  • 1st Place: Surface RT and a Nokia Lumia 920
  • 2nd Place: $250 cash and a Nokia Lumia 822
  • 3rd Place:  $100 cash and a Nokia Lumia 620

Everyone who publishes an app to the store will get:

  • $100 per app (up to $2000)
  • A Nokia Lumia 800

Everyone who submits an app for the hackathon will get:

  • Nokia Premium Developer Token ($1,500.00 value)

What is a Nokia Premium Developer Token? The token pays for your

  • Windows Phone DevCenter account ($99.00 Lets you publish apps to the Store and unlock phones)
  • Telerik RadControls for Windows Phone license ($99.00)
  • 1 Million Buddy API calls a month for 12 months ($1,200.00)
  • Two Nokia support tickets ($198.00)

So go grab your seat before they’re all gone. I look forward to seeing you all there!

Here’s the schedule:

poster-agenda

How Rad is your app?

I have another giveaway and challenge for my developers today. In addition to being a Nokia Developer Ambassador, I work full time as a XAML Support Specialist at Telerik, yep the awesome RadControls people. So, I’d like to ask you, “How Rad is your app?”

I don’t want this post to sound like an ad, but rather a testimonial. That’s why I make it a point to say that I used the RadControls long before I became an employee, their components are a powerful, indispensable part of my development toolbox. The RadControls make your app look like you had a whole team of designers.  I just released an app powered by the RadControls, “Conferenced In”.  Get it here so you can follow along with this post as I make a simple comparison.

In the app I use the DataBoundListBox instead of the default listbox, this easy change dramatically increased the polish and functionality of my app. With features like “PullToRefresh” and built-in animations, I got a great UX with minimal effort. Another great feature of the DataBoundListBox is the “OnDemand” feature. You have the ability to fetch new list items when the user gets to the bottom of the contents via an Automatic or Manual OnDemand method built into the control. To see this in action:

  1. Open Conferenced In and sign in to Twitter (if you don’t have a Twitter account, the app has a guest mode)
  2. Choose an upcoming conference (this combo box and popup display is the RadListPicker)
  3. Select “Load Speakers”. Notice how the speakers fill the viewport? Awesome sauce, right! That’s the RadDataBoundListBox built-in animation with a little customization.
  4. If you signed into twitter, slide over to your timeline or mentions and scroll all the way to the bottom. You’ll see a button to load older tweets, that is the OnDemandManual mode.
  5. Now go back to the speakers list and select a speaker, this will bring you to their profile page.
  6. With the speaker’s tweets in front of you, pull the tweets down. You’ll see the PullToRefresh icon and animation do it’s magic.  This is a built-in property that you only need to toggle and populate the event handler. Easy button.
  7. Now scroll to the bottom of the speaker’s tweets as fast as possible, when you reach the end of the list notice the “loading” busy indicator. This is the control in OnDemandAutomatic mode! You will see the older tweets animate in from the right.

Now imagine if I used a default listbox? How much coolness would I lose? Exactly…

So, I’ve added a new feature to this blog. If you look over to the right sidebar, you’ll now see a new widget titled, “Examples”. This is a live Box.net widget where I have placed example applications that you can download right now. Go ahead and get the Telerik Examples compressed folder from the widget. Inside there you will find the source code of several applications (in parenthesis is the link to the example if it is the Marketplace):

  1. Telerik Examples (live link only: You get this as part of your trial download. Find it at C:Program Files (x86)TelerikRadControls for Windows Phone 7 Q3 2012Demos)
  2. Picture Gallery (live link)
  3. Telerik Design Templates (live link)
  4. Telerik ToDo
  5. Telerik Exchange Client
  6. Telerik Agenda Viewer

The next step is go get yourself a trial of the RadControls for Windows Phone, go to this link and click the “Download Trial” button. Install the RadControls and then go explore the source code of the example apps. Take a look at how flexible and powerful they really are. I only gave you one small case, imagine what this can do for your apps! See how the Telerik Windows team leverages the different features in these examples. You can fully develop your app and also get unlimited support ticket during your trial!

Get free license to the RadControls for Windows Phone I will award one license to the first developer who sends me their app that uses at least 3 RadControls in their app and tells me how the RadControls made their app better. Apps published before Nov 7th are not eligible for this challenge, but if you are updating an existing app with the RadControls that was first published after Nov 7th, it is eligible. Contact me at Nokia-Dev(at)outlook(dot)com for more rules and details.

We’re back at the original question, “How Rad is your app?”

Resources, Resources, Resources!

I moved this blog post into its own page. Select the “Resources” tab above, or use this link.

If you have any questions, or if you are in the Boston area (New England), send me an email at nokia-dev@outlook.com or on twitter at @lancewmccarthy