CloudBit Libraries for Windows Apps

LittleBits are tiny electronic components that can be fitted together to create working circuits. They are great fun and you can find out all about them here:

http://littlebits.cc/

They make a device called CloudBit:

http://littlebits.cc/kits/cloudbit-starter-kit

This puts LittleBits signals into the cloud, where you can connect to them from browsers and services such as If This Then That (ITTT). I used my CloudBit in the Microsoft Band Hackathon earlier this week, where I was using values sensed by the cloudbit to trigger alerts in the Band. I also used the Band accelerometer to control the output of the cloudbit as well.

I thought I'd put the LittleBits library that I used to control the device up on GitHub. So I have. You can find it here:

https://github.com/CrazyRobMiles/CloudBitControl

You might want to control your LittleBits devices from your Windows PC or Phone, and that's what this library does. You can send a percentage power value to your CloudBit device and receive a percentage value back. What the signals mean is entirely up to you. They might control a servo, light a lamp, open a cat flap or any number of other actions. You can use the inputs from the CloudBit in any way you like too.

There's a sample universal application that uses the library. This is a good basis for getting started. You just need the device ID and access token for your CloudBit and you are good to go.

json2csharp is magic

Json (JavaScriptObjectNotation) is a really popular way to pass information around on the internets. Lots of services will serve up lumps of json for your programs to munch on. It works very well with JavaScript (which is not surprising) but in the strongly typed world of C# (a great place to be in my opinion) it is a bit of a pain, because C# likes to have proper classes to back up the contents of the Json strings. 

That's where the wonderful json2scharp web page comes in. Grab the chunk of json that you get back from the service (in this case I pulled it straight out of the string in my app while debugging with Visual Studio) and paste it into the window at json2csharp.com and it will spit out all the class definitions that you need.

You can then paste these into your source code and hey-presto, you have all the types that you need to read and work with the json formatted data you just received.

Wonderful stuff.

Birthday Bluetooth

It's my birthday today. I had my treat over the weekend and am now saving up for a Segway (just about doable) and a twenty acre estate that I can use it in (pretty much impossible). So I'm here in the office, eating chocolates and writing C#. Which counts as a pretty good situation in my book. 

Anyhoo, I've been playing with a present I bought myself last week. It is a Texas Instruments SensorTag. You can pick these up for a very reasonable sixteen pounds or so and they are enormous fun (if you like connecting devices to sensors). It talks Bluetooth BLE and I've fancied having a go at this for a while.

Turns out to be easy to get it to connect to a Windows 8.1 device. Just remember that for Windows you have to pair the tag over Bluetooth. It just works with iOS and Android - I hope that they remove the need for pairing with Windows at some point. 

If you fancy having a go I've written a very simple universal app and put it on GitHub. You can use this to connect to the accelerometer in a SensorTag and get events fired in your program when a new reading is produced. 

I used a superb post from Dan Ardelean to get started, and just built a little wrapper class around methods that he described.  Great fun.