Tag Archives: IoT

Working with SQLite in UWP

*Post will be updated with explanation soon!*

The following samples have been tested on Desktop, Mobile and IoT (Raspberry Pi 2). They require that you have the 10586 SDK installed (Visual Studio 2015 Update 1 or later).

UWP using Entity Framework 7 – use SQLite for persistent storage: EF7Sample

UWP using SQLite-NET, second example using SQLite-WinRT NuGet.
The SQLite-NET sample also demonstrates accessing a SQLite database from a background task (Click the Background Task link on the command bar menu to navigate to a page where you can register and signal (i.e. start) the background task).
*Check the SQLite Extension SDK references in the foreground projects. The samples were built with 3.10.0 but if you have a different SQLite version installed, you will need to remove and then re-add the SQLite extension reference*

Baby steps into the Internet of Things #1

First Steps #1: What is the Internet of Things?

You might have noticed a bit of chatter recently about something called the “Internet of Things” or IoT for short. It’s a classical industry hype buzz – everyone talking about it, a lot of people worried that they’re going to miss out on this ‘next big thing’ if they’re not careful. In fact, Gartner has called it as currently right at the peak of  the curve of ‘hype, and unrealistic expectations’ on their classical curve of technology adoption – which means the inevitable ‘trough of disillusionment’ is only just around the corner!

But this thing is real, and it’s exciting. I can make an honest claim to have been in IoT for many years, since I have been working for many years writing apps with the .NET Compact Framework on small processors running Windows CE in embedded applications, and on small handheld computers running Windows Mobile or Windows CE and more recently Windows Phone.

But all that is a niche (but very interesting) area using relatively pricey computers, and the real reason for the excitement around IoT is that we can finally start to deliver on having really cheap computers and sensors incorporated into ‘things’ around us, delivering data that we can use to create really interesting solutions. And I want to be in on this too, so I’ve started to explore it a bit and I’m going to document my ‘journey’ in a short series of blog posts – this is the first.

Enter ‘The Makers’

So I get that in any IoT solution, there are ‘things’ which are gathering data. These ‘things’ can be very simple, such as PIR movement detectors, light sensors, temperature sensors or GPS locators, or more sophisticated such as NFC readers or facial recognition solutions to detect when a specific person has entered a location.


These smart things can be modelled and tested out using development boards where you can prototype this basic information gathering. There are a number of cheap electronics development boards out there, such as Arduino, Raspberry Pi, Netduino, Intel Galileo to mention just a few, which electronics-savvy people can wire up to simple stuff such as sensors, LEDs, visual displays, buzzers or sounders, or to more sophisticated devices such as motors and actuators to do cool stuff. And these boards can easily be networked to the internet or to other things where they can send the data that they gather. The people who work with these development boards are collectively known as ‘makers’ and there’s a lively community out there, all helping each other to make cool stuff, and readily giving help to beginners.

For me – this is perfect! Way back in the mists of time, I studied at Manchester University and my degree course was Electronics. But on my course, I realised I was more interested in this relatively new industry called Computer Programming than I was in soldering, so after I got my degree, I’ve been working in software ever since and hardly done anything with electronics. Which seems a bit of a shame – so now I can go back to my roots, so to speak, and combine both a bit of electronics with my love of software solutions and hopefully build something exciting!

If you have no interest in electronics, don’t worry. You don’t have to know how to use a soldering iron to get involved with the IoT. This thing will be huge, and the cheap electronics that are embedded in the ‘things’ is just one part of it. Sure prototyping electronics boards is one part of the whole process, but once the prototype sensor bit of it has been perfected using a development board, then some factory somewhere will manufacture the production version of it which will end up built into your smart refrigerator, your entry door, your environmental sensor – or whatever it is. Then the data starts flowing and it’s time to build a solution that makes use of that data.

So, what does an IoT solution look like?

This was the first question I asked, as a beginner in this field. I had an idea that there was small electronics boards in there. The classical example is the smart refrigerator, which warns you when your milk has been in the fridge too many days so you can throw it out, or which automatically adds items to your electronic shopping list as you use them up. OK – but how would that actually work?

How would a smart refrigerator actually work?

Well, that kind of scenario isn’t easy. For starters, the smart refrigerator would have to ‘know’ what items were in your fridge. I guess you could try to incorporate a barcode scanner in the door so that each time an item goes in and out, the user would have to scan the code on the packaging. Hmmm – no, that’s no good: too intrusive for the user. We could get an industry consensus-thing going so that every food manufacturer put an NFC tag on their packaging! Yeah, great idea, not going to happen.

So today, you’d have to sell your smart refrigerator with a big bag of smart tags, which the user would attach to products when they bought them, and which would be separated into different categories, maybe, milk, butter and any other specific products that the user wants to track. That’s probably OK since the user chooses which products to track, they stay in control and probably the only annoyance would be when the user accidentally throws out another smart tag with the trash and periodically has to purchase some more? Although – actually these pretty dumb tags could be passive NFC and maybe they would be cheap enough to throw away, and maybe throwing them away would be a good thing, since that might avoid mistakes like your fridge telling you your milk has gone off when actually all you’ve done is to re-use a tag but attached it to a new milk carton.

Alright, so now we’ve tracked the products and now the fridge can gather data about products going in and out of your fridge. What should it do with that data?

What to do with all that data?

This is where you start to see the anatomy of a complete IoT solution appear. The fridge itself could have software running in it to make decisions based on the data that it has – but then it would also have to be updated when software updates become available. And it would probably also have to offer some kind of UI so that the end user can configure their fridge. This doesn’t sound like a flexible, extensible solution.

So wouldn’t it be better for the fridge to simply take all that data and transmit it up to a database in the cloud, where the smart stuff would happen? Jobs would run in the cloud to analyse the stream of event data coming from smart refrigerators. The cloud would also host the end-user website where they can configure their fridge and determine what kind of alerts should be raised and what actions to take when their milk has been in the fridge for four days, and because it is in the cloud, it can easily be updated with new features.

The fridge itself acts as a gateway to ship the raw data up to the cloud, but it also acts as a consumer of the outputs of the processing and has buzzers and a display panel to alert the user to messages which have come down from the cloud as a result of the analysis of the raw data. But think how easy it would be to also send alerts to the users’ smartphone, or email, or SMS or…?


This sounds good! Now we’ve got a good solution for this. Good for the end-user – but also good for the manufacturer of the smart fridge who not only offers a good service to consumers, but can also get diagnostic messages from their smart refrigerators through the cloud, and also gets some potentially valuable usage data about what users are putting in their fridges which could guide their future product development and could possibly be sold onto other organisations– with end user permission of course.

The basic anatomy of an IoT solution

So with that I think I’ve figured out the basic layout of an IoT solution: sensors gather data which you ship to the cloud where you process it and publish the results to some consumer(s) – which could be a website, a smartphone or computer, or some other device.

Next thing for me is to take a closer look at the data gathering bit of all this and to get my hands dirty with a development board. I’m going to get myself a development board and have my first experiences of being a ‘maker’! That’ll all be in my next post!