Scott Hanselman

Exclusive Sneak Peek: The AGENT Smart Watch Emulator and managed .NET code on my wrist!

June 18, 2013 Comment on this post [30] Posted in Micro Framework | Tools
Sponsored By

The AGENT Smart Watch

I'm totally geeked out about Smart Watches. I always have been, from the original Microsoft SPOT watch (from 10 years ago!) to the Pebble, and now the AGENT Smart Watch from Secret Labs. Secret Labs are the folks that brought us the Netduino open source electronics platform that uses the .NET Micro Framework. It's pretty awesome that you can write C# and run it in 64k or in 64gigs, from the wrist to the cloud.

Upcoming Conference: If you're in or around Chicago in July 2013, consider joining Chris Walker from SecretLabs and I at the MonkeySpace conference! We'll be speaking about developing for embedded systems and the AGENT Watch with C#. What are the power considerations? How low-level is this kind of coding? Can one kind of app cause battery drain while another keeps the watch going for a week? What about notifications and bluetooth? We'll cover all this and lots more, join us.

The AGENT Smart Watch will talk to your phoneThe AGENT Smart Watch was trying to raise $100k to build a watch and as of the time of this writing they are within spitting distance of a MILLION dollars! There's just hours to go to get in on this cool Kickstarter. (Remember, Kickstarter is an investment, not a store.)

Not only is this a .NET Microframework Device, but we can start writing apps now using the AGENT Watch Emulator. From their Kickstarter site:

Traditional smartwatches run apps in an unrestricted environment.  AGENT's OS includes a managed runtime, optimized for our low-power architecture.  It is called the .NET Micro Framework and it makes watch apps trustable.

This feature-rich managed runtime also offers developers modern features they crave: event-based programming; multi-threading; garbage collection; lambda expressions; exception handling; automatic power management; and much more.

You can install VS2012 and the .NET Micro Framework 4.3 and write an app for your wrist! I alluded to this a little in my Xamarin talk "How C# Saved My Marriage." You can write .NET apps for embedded systems, a watch, tablets, desktops, web sites, large cloud systems and more.

Full disclosure: I have no financial stake or business relationship with SecretLabs, but we are friends and I'm a fan. I helped Chris with some copy writing on the Kickstarter page, its text and reviewing the video as a favor. I have received no money from SecretLabs and I backed the Kickstarter with my own money.

imageI got a preview of the AGENT Smart Watch emulator, and some code from Kickstarter backer Esben Bast who created a binary clock face. I loaded up VS2012 and the binary clock emulator. This initial code is just about 100 lines. You can see the references in Solution Explorer here. SPOT means "Smart Personal Object Technlogy."

The fact that there is an emulator is huge. No worries about breaking a watch or even having a watch! The Agent Watch SDK puts a reference to the AGENT Emulator in my registry, so it shows up directly in Visual Studio:


Then I can debug my watch app without a watch, just as if I were writing a Phone App or Web Site. It's a first class experience inside of VS. This makes me feel particularly empowered as a .NET developer because it means I already know how to write apps for this watch and I've never even seen it before..

The code is pretty straightforward, if appropriately low-level. This IS a small device we're talking about!

You've got total control over the screen and what can be displayed. You could create any watch face that you could imagine (that would fit on the screen) because you have a Bitmap to draw to.

The .NET Micro Framework has no fonts loaded by default, but I can include them as resources. There's some "tinyfnt" files in C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Fonts or I could download or make some myself. Even better I can use the TinyFontTool from Miloush.

I can load a font from a resource like this:

font = Resources.GetFont(Resources.FontResources.small);

and then later in my UpdateTime() method, Draw the time on my binary clock screen.

_bitmap.DrawText(DateTime.Now.ToString("HH:mm:ss"), font, Color.White, 45, 15);

Run my emulator again and I have the time printed as well!

Now my AGENT Smart Watch has the time printed above the Binary Clock

The only real "microframework-ism" in the code is that the watch face doesn't want to use a lot of power, so you should "go to sleep." It's the same as if you were writing a console app. If your main() function ends, then your app will end! But, since this is a watch face, we want it to run all the time, so, we start a 1 second timer, then sleep the main() forever. Everything interesting happens as an event on a background thread. (The watch can control the lifetime and tombstone or kill the watch face if you're doing other things.)

public static void Main()
_bitmap = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
_font = Resources.GetFont(Resources.FontResources.small);

// display the time immediately

// set up timer to refresh time every minute
DateTime currentTime = DateTime.Now;
TimeSpan dueTime = new TimeSpan(0); // beginning of next minute
TimeSpan period = new TimeSpan(0, 0, 0, 1, 0); // update time every minute
_updateClockTimer = new Timer(UpdateTime, null, dueTime, period); // start our minute timer

_button = new InterruptPort(HardwareProvider.HwProvider.GetButtonPins(Button.VK_SELECT),
_button.OnInterrupt += _button_OnInterrupt;
// go to sleep; time updates will happen automatically every minute

That last part is interesting. You've got two event handlers here, the one to UpdateTime every second and then one to watch for the Button getting pressed. You want the watch app to be needs to do as little as possible NOTHING until it's time to do something. This InterruptPort is watching for the the middle button (the VK_SELECT button). ResisterMode.PullDown means the button will show "1" or true when it's pressed. InterruptEdgeBoth means I get events when the button is pressed AND when it goes up.

Go make Watch Apps!

Here's another cool watch face from Dylan Mazurek next to the Big Digits example:

PixelFace example Watch for AGENT Smart Watch BigDigits example Watch for AGENT Smart Watch

And finally, here's an animated concept for a World Time face that Steve Bulgin made for Pete Brown as well as another Steve concept below:

The next step will be more than watch faces, it will be watch utilities and apps. Maybe an app for my FitBit, or an app to manage Blood Sugar? Perhaps a Nest app to control my thermostat?

The AGENT Watch Emulator emulator will be available to download this Thursday at You can get ready by installing the .NET Micro Framework today.

Steve Bulgin watch face for the AGENT smart watchWatch apps can be written in C# using Microsoft Visual Studio 2012 (including the free Express edition). Deploy your apps over Bluetooth and debug them interactively.

Download Visual Studio Express 2012
Download .NET Micro Framework SDK v4.3

Developers can also use AGENT as a secondary display, interacting with it remotely via Bluetooth from their Objective-C, C#, or Java smartphone app.

Even though the watch ships in December, I'm going to start writing apps now so I'm ready for the Watch App Store (coming soon)!

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
Hosting By
Hosted in an Azure App Service
June 18, 2013 21:59
Really excited! Can't wait to see what people do with this!
June 18, 2013 22:15
I wanted to get the Pebble, but as a WP8 user myself, it was sadly not the watch for me. But this one, running .NET? This is quite honestly the smart watch I've been wanting my entire life.

December can't come soon enough.
June 18, 2013 22:26
Thanks for this wonderful article showing the "hello world" app for this smart watch. You certainly have me intrigued. Does the API provide access to the smart phone too?
June 18, 2013 22:38
Was the "Sneak Peak" in the title intentional? :) ... you getting on a smart-watch "high" with "Secret" Labs.
June 18, 2013 23:22

It triggered the geek bug on me!

I spread it to my friends, although not even a handful will be able to read the binary format (which I loved by the way).

I will do an experience with my kid when she will learn the decimal code: give her a watch like this and see if she gets the binary way smoothly ;)

Jokes a side: those are the kind of things that really teach people how to code or appreciate the others effort on creating tools/frameworks.

Like in the old 70's song: "Oh baby it a lego-world".

Live longer and prosper!
June 18, 2013 23:26
I can't wait for mine and I'm downloading the SDK as we speak.
June 18, 2013 23:37
Did the Timex Datalink watch not count?
June 19, 2013 0:06

you truly are the king of all .NET geeks :)
June 19, 2013 0:23
Hey Scott, how does the emulator work with Bluetooth? Does it just use the PC's Bluetooth? Or is it even possible?

I'm envisioning some cool Windows Phone 8 apps paired with apps for the AGENT.
June 19, 2013 1:54
Been waiting years for a decent smartwatch and now they are finally arriving. Being a more traditional watch wearer though I am waiting for them to get a bit better looking.
June 19, 2013 2:25
Is dueTime being set properly ?
June 19, 2013 4:33
@Cam Soper -- This was asked in the Kickstarter comments - it seems it'll use Bluetooth SPP (Serial Port Profile) to communicate with the watch wirelessly for programming, step-through debugging, etc. As long as your PC has Bluetooth capable of SPP (either built-in or using a USB dongle) you should be covered.
June 19, 2013 7:32
This seems promising. I am giving it a try.
June 19, 2013 7:36
@Cam Soper -- as Erik said, yes you can communicate between WP8 apps and AGENT apps, even in the emulator. :)

A quick screenshot:

I tested that app on both an AGENT prototype watch and the emulator. No code changes required, other than swapping the name of the target Bluetooth device on the phone.

June 19, 2013 10:05
I think I see another BABYSMASH port coming soon!
June 19, 2013 13:02
The Agent watch has the potential to be brilliant, but blooming heck it's 1980's Casio UGLY. I'll stick with my Pebble until a better-looking model comes along!
June 19, 2013 13:04
Obviously, beauty is in the eye of the beholder and all that :)
June 19, 2013 14:00
Realy amazing!

Very good news. Thanks.
June 19, 2013 15:28
Any information when the AGENT SDK will be able to use? Did you have a download link?
June 19, 2013 17:31
I'd sure like to give up my Dexcom receiver and have the mg/dl, trend indicator and alarm here.

Then again, the FDA will probably always stand in the way of that.
June 19, 2013 18:25
Wonderful ! Give it a small microphone, a low bit-rate a-to-d converter, and a stream-by-BlueTooth-to smart-phone record function, and it will be the audio equivalent of Google Glass :)

thanks, Scott
June 19, 2013 19:34
I'm curious about your statement that, "Kickstarter is an investment, not a store." This seems inconsistent with the fact that although you've "backed" this product you don't have any financial stake in the company. Isn't it more accurate to describe Kickstarter as a store that resembles an investment in that it may not pay off?
June 19, 2013 20:15
@Paul -- Kickstarter backers rally together to support a project and get it off the ground. They don't receive any financial stake in the company itself in exchange for their pledge. They can however select to receive a reward (such as the production watch itself). This is similar to how PBS telethons work for instance.

@Tom -- an early SDK and emulator will be available for download tomorrow evening. :) We're pretty excited to see what you build!

Secret Labs
June 20, 2013 11:59
@Chris - Can't wait for the SDK download link, please let us know soonest :-)
June 20, 2013 14:50
hmm hmm, so we have a non-realtime watch here.
June 21, 2013 8:22
You know what I like best about this type of programming? Our children will love it! If I say to my son, "let's make a web app," he can get bent around the axle with the ceremony and cruft of HTML, JS, etc. But with this, he can have a physical device that he can remotely push to (via bluetooth) and debug. He will be able to code all weekend and have something to show his friends come Monday morning; no app store process, no executable file and hosting, just write, build, push to phone, and rock on.

This is so accessible!
June 21, 2013 9:38
Our early-access preview SDK and emulator for AGENT are now live :)

If you're adventurous--you can even create a Windows Phone app and use its Proximity and Networking features to connect to the AGENT Emulator via Bluetooth Serial Port Profile :)

BTW, Rob Chartier posted a blog post about installing the tools here:

We'll be updating the SDK with new features, creating tutorials, etc. over the next few months as we move towards autumn production.

Secret Labs
June 24, 2013 14:07
I want to see .NET spreading everywhere, so finding about about The Agent really made my day. Only problem is that I can't see how we can earn money making apps for this smartwatch (as we should). Unless maybe we could earn money off of the mobile phone app that uses The Agent.
June 25, 2013 16:27
Currently downloading the tools :)
Can't wait to get my hands on it and the actual hardware in December.

Awesome that they support Windows Phone. That's what ruled out the Pebble for me.
June 26, 2013 12:39
I Love You scott.

Comments are closed.

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