It’s been a while since I played with my Sphero device and so I thought I’d see if I could get some code up and running on Windows 10 UWP to talk to it.
It turned out to be a little more of a ‘journey’ than I’d hoped for but, nonetheless it was fun
I last did any work with Sphero in this blog post where I wrote a Windows 8.1 application in HTML/JS on top of a C# library which itself wrapped a Sphero control library into a custom WinRT component such that it could be used from JS.
I thought I’d revisit something similar in Windows 10 but use C# and XAML for everything rather than bring in HTML/JS.
I went to look for a Sphero control library and ended up back here;
where I have to admit that it’s a bit sad to see that the WinRT library for talking to Sphero;
is still in a 0.9.0-preview variant built specifically for Windows 8.1 and it doesn’t look like anything much has changed with that library for around 2 years.
Bummer. I’d hope that perhaps this will change in the light
...Putting the Basics Together on the PC
I paired my Sphero with my PC over bluetooth and I then took the RobotKit library that Sphero has on github and I build a quick Sphero control service out of it;
...Moving to the Phone
Up until this point, all the bits that I’ve played with for Windows 10 Mobile I’ve done in an emulator but I didn’t think that was quite going to cut it here and so I went and dug out an old Lumia 920 which has a broken proximity sensor (making it very hard to end a phone call!) and I set about installing the Windows 10 Preview on it.
I’d say that it took around 1 day to get to the point where I had build 10512 installed onto this device. I had a number of problems including;Running out of storage space. Having updates repeatedly fail to install . Getting stuck in a loop where my phone would reboot, show cogs , fail with an unhappy face and then repeat.
In the end, I had to resort to the Windows Phone Recovery Tool in order to re-flash the phone, start the update process over again (without restoring any backup to the phone) and get it updated to Windows 10.
Actually driving the ball;
...Moving to Windows IoT Core
In terms of moving this to Windows IoT Core, I hit a really interesting scenario which I thought I’d share. Firstly, I powered up my Raspberry PI 2 and went to its web admin UI in order to pair the device with the Sphero;In Summary
This has been a long post – what has it covered so far?Taking a Windows 8.1 library and using it in a Windows 10 project. Making that Windows 10 project work across PC, Phone and Raspberry PI 2. Dealing with a few hiccups along the way!
I’ll follow up the post with another where I’ll see if I can control the Sphero from the PI without having to use the UI and a mouse – I’ll add some buttons onto a breadboard and see how that works out.
In the meantime, all the code for this post is here for download if you want to do something with it.
[Click through to see the complete post, Windows 10, the UWP, an old Windows 8.1 library and controlling Sphero across PC, Phone and Raspberry PI 2. ]