Windows 10–Further Misadventures with IoT Core, Raspberry Pi 2

In my spare time, I’ve been playing a little more with the Windows 10 IoT Core build on Raspbery Pi 2. I’ve also got a Minnowboard MAX 2 but I seem to have settled on the Pi as the place to play.

I upgraded to the latest OS build (10152) and was glad to see that the installation process seems to be getting better with some bits of tooling to help you get the OS image onto your SD Card rather than asking you to run command line tools to do it;

Installation Guide is Here

and, along with making some lights flash and some switches switch I’ve been toying primarily with 2 things driven largely by the Sunfounder kit that I ordered along with my Pi;

Sunfounder Kit is referenced from this post

Firstly, inside of my Sunfounder Kit I came across a 16×2 LCD panel and I thought ‘Ok, how hard can it be to get this up and running?’. This sort of thing;

 

A real case of ‘famous last words’ in that I’ve probably spent around 10 hours on it across various evenings and I still don’t have it up and running Smile

But I did manage to learn some things along the way which I thought I’d draw into a few ‘learnings’ here…

Learning 1 – Hardware + Software Adds Complexity (no way!)

Ok, it’s not something that I’m learning for the first time as I’ve written code for specific pieces of hardware (including half built hardware) before but I’d forgotten a little of what it’s like. Essentially, each debug cycle becomes;

  1. Is my code working?
  2. Is the preview OS/framework likely to be working?
  3. Is my wiring ok?
  4. Is the hardware likely to be working?

Specifically, with this LCD panel I was convinced that it was broken until at some point it ‘just started working’ and then, not much later, it stopped working again which has led me to think that my specific problem is around trying to hack up connections to it rather than solder them.

Hence, a soldering iron is on its way to my house. It’s a long time since I had to solder anything but I spent a long time at stages 1,2,3 above before deciding that 3 was proving to be my specific problem with this device.

Learning 2 – The Internet Helps and Hurts

In trying to figure out both the wiring and the protocol for talking to that LCD panel, I must have scanned 30-50 websites. There are examples of how to use this stuff everywhere.

That’s the upside.

The downside is that a lot of the examples disagree on how things should be put together and so you can spend a lot of time trying to figure out the ‘definitive guide’. The other downside is that, naturally, examples are using different revisions of hardware and different software stacks so it all combines to be quite ‘time consuming’ Smile

Here’s some examples of the sites I spent (a lot of) time on when trying to get that LCD panel to work;

and many, many more including a lot of University websites where I scanned through various pieces of course materials around how to put these bits together.

I specifically spent a lot of time trying to figure out why my initialisation code didn’t seem to be initialising the screen on sites like;

and many, many more.

I installed Raspbian onto the device and tested out some Python code to see if that worked differently from my own.

It didn’t, as it happens which led me back to suspecting my wiring.

Learning 3 – You Are Looking for the Datasheet

In the end, I decided that (however low level) it’s the Datasheet for the device that tells the true story and, for me, that involves skipping past a bunch of internal schematics that those documents have to find the information as to how to control a device from software.

That was true for the LCD panel (datasheet) an also the Accelerometer (datasheet).

For whatever device I look at in the future, my first web search will involve the keyword ‘datasheet’ Smile

Learning 4 – You Are Not Alone, Do Better Web Searches

In both the case of the LCD panel and the accelerometer, I made an assumption that there wasn’t much Windows IoT Core stuff out there already and so it would be unlikely that I would find tutorials/articles on how to use those bits from Windows IoT Core.

My approach then was to go off, do a bunch of figuring out, try things out and then when I got really stuck I’d do more and more specific web searches to see if I could identify a specific problem.

I should have started the other way around – specifically, I found both;

way, way, way later than I should have given where they are located. 

While I wanted to follow a ‘start from scratch’ approach, both of these could have saved me a tonne of time and also provided verification that I was/wasn’t going in the right direction.

Learning 5 – The Code Isn’t (Necessarily) Very Hard

In a spare 30 minutes this morning, I figured that I’d grab an accelerometer out of my SunFounder kit and see if I could make a connection to it.

I hadn’t looked at I2C on Windows IoT before but I wired up the bits (around 3 minutes) and booted the Pi (2 minutes) and then I dropped into a new UWP project in Visual Studio.

I figured that the I2C stuff would live in Windows.Devices and, sure enough, it does and I just used IntelliSense to try and figure out what the relevant classes were and within about 10 minutes I was at the point where I’d found my I2C device and opened up a comms connection to it.

The rest was a matter of going ‘back to the datasheet’ to see what commands it supported and how they were supposed to be sent back/forth.

I was going to write that up as a blog post here but, as part of doing it, I came across the tutorial that I just referenced earlier;

I2C Accelerometer Sample

which I merged into the code that I was writing, probably giving me a 10x speed-up in terms of figuring out how commands/data get sent to/from that device using the WinRT classes.

Within about 30 minutes I’d got data coming back from that accelerometer and displaying (in an ugly way) in a simple XAML form.

WP_20150710_12_00_25_Pro

So…just a few observations on playing around with these 2 pieces of kit from IoT Core – next steps will involve going back to that LCD with a soldering iron!