So … I’ve started playing with the whole Internet-of-Things stuff that Microsoft has been talking about lately. It’s funny … I’ve been doing this kind of stuff for several years, with Microsoft’s own product and it’s finally getting traction at Microsoft. Largely, I think, because of two things: first, Windows 10 IoT edition (which is pretty cool) and second, the Azure Event Hubs. And, honestly, I can’t say that I’m just “getting started” with IoT – I’ve been doing it for a while. But I am hopping on the current wave coming out from Redmond and, overall, I like what I’m seeing.
If you weren’t aware of Event Hubs, it’s a CEP service in the cloud. It scales to millions of events per second (they claim). In that, it has some of the same functionality as StreamInsight. However, getting StreamInsight to scale to millions of events per second would, admittedly, be pretty tough … that’s a lot of raw throughput. But part of how Event Hubs accomplishes this is to limit the functionality provided – the sources and sinks are strictly limited to those the team has elected to include and there’s no extensibility. It also doesn’t seem to provide the number of options that you have with StreamInsight. Not that this is a bad thing … depending on what you are trying to do, this may be absolutely fine. Also, the integration into the Azure Machine Learning with Event Hubs is pretty cool – though you can do that with a custom UDO or UDF in StreamInsight.
And it’s not an either-or thing … you don’t have to use simply one or the other. In fact, there is, I think, far more usages for a combination scenario, with StreamInsight on-prem feeding to Event Hubs in the cloud. First, since there’s a lot more that you can do with StreamInsight locally (due to its extensibility), there’s quite a bit of processing you can add to the data that you are streaming, including far more advanced analytics as well as downsampling and data cleansing. Also, with local connectivity to other devices, you can respond immediately to events and conditions by issuing control commands to these other devices that are on your local network. Rather than an “Internet of Things”, it’s an “Intranet of Things”. That locally processed information can then be forwarded to the cloud Event Hub if you so desire. Think, for example, of facilities management. You have various sensors around the facility measuring all kinds of things – temperature, humidity, air quality (including CO, CO2, volatile organics, flammable gases and more) – and taking appropriate action or raising alerts. Then, this would be downsampled (using, say, a hopping window in StreamInsight) and then streamed to the cloud-based Event Hub for multiple facility monitoring and tracking.
Naturally, I had to go get myself a bunch of devices. I’ve gotten an Arduino R3, Netduino 3 with WiFi and Raspberry Pi and started playing with them. My first task : duplicate the Raspberry Pi IoT Weather Station demo. Done … but took a little longer than expected and included a complete brain-fart where I hooked the 5V wire from the RasPi to the ground on the weather shield. Surprisingly, nothing appears damaged but, needless to say, it didn’t work either … and they both got quite warm. But first … now that I’ve had these for about a week, here are some thoughts.
Arduino Uno R3: This is a neat little device and it’s really, really inexpensive. When it comes to embedded, build-it-yourself devices, this is the one that has, by far, the most options and most importantly (especially when you are trying to figure the thing out), the most sample code out there for using sensors and devices. It’s also open source and many of the components are as well. The controller is a 16Mhz ATmega. Yup, that’s right … only 16Mhz. The same clock speed as the first 386’s – but it’s RISC-based, so it’s a different architecture. It’s also got 32KB of flash and 2KB of SRAM … so it’s actually very limited when it comes to program size (in the flash) and working set (SRAM). There are various flavors of the Arduino, including “clones” (for lack of a better term) and there’s also sew-on (wearable) Arduino-based systems (called LilyPad). The biggest downside to the Arduino is that the development environment really makes you appreciate Visual Studio. It’s bad … really bad. And if you leave it running too long – or maybe it’s through a sleep/resume cycle – it’ll starting chewing up CPU and memory. The programming language is C/C++-based. (Late breaking development … apparently there is a Visual Studio plug-in for Arduino. I will have to check it out). The debugger is non-existent. To debug, you’ll be writing out to the serial port and reading it. The IDE has a handy tool to monitor your serial/USB port to show the output. Still, it’s remarkably capable and powerful for the things it was designed for and the LilyPad stuff is quite intriguing. (Example: GPS embedded in a kid’s backpack, with cellular uplink to report location periodically. Kick it up a notch to record UV exposure as well). Power requirements are quite low … it’ll run just fine from a USB connection (500mA). It can be had for as little as $10.
Netduino 3 WiFi: This is an Arduino-shield compatible microcontroller that runs the .Net MicroFramework – a mini version of .Net for embedded system. This latest rev of the Netduino has a 168 Mhz processor, 1408KB of flash and 164KB of RAM. As the name implies, it also as 802.11 Wi-Fi built in, including support for 802.11N – but only to the 2.4Ghz band. That – right there – makes this, for me, a far more interesting and useful device than the Netduino, especially for the journey upon which I am embarking. Yes, there are WiFi and Ethernet shields for the Arduino but this is baked-in to the board. It also has a unique (as far as I can tell) Go-Bus that allows you to quickly and easily plug in additional devices, including additional Arduino shields. The board itself will run on a USB connection but once you start adding things to it, you’ll need to have supplemental power. Like the Arduino, it’s a truly embedded system and has no built-in support for any kind of display – though you can add Arduino-based LCDs or OLEDs for a simple display. Development is exclusively with Visual Studio using C# or VB.net and you get the full debugging experience right in Visual Studio. More powerful than the Arduino, it’s also more expensive at $70.
Raspberry PI 2 Model B: Second full version of the open-source Raspberry PI. This is a full computer that’s the size of a credit card. It sports a 900Mhz quad-core ARM processor with 1 GB of RAM, has a dedicated camera and display interface, HDMI port, 4 USB 2.0 ports, microSD and Ethernet all on-board and runs various flavors of (ported) Linux including Ubuntu, OpenElec, Pidora, and a flavor just for the RasPi called Raspbian as well as Windows 10 IoT edition. Development is done with Python, Scratch, C++ or various other environments (Sonic Pi looks like it’d be really cool for my son as he’s into music) or – if you install Windows 10 IoT edition on it (as I did), you can use Visual Studio 2015. Unlike the ‘duino-based boards above, it won’t reliably run just from a USB connection (500mA for USB 2.0, 900mA for USB 3.0) so you’ll want to get a higher-powered micro USB power supply. Also, unlike both of the ‘duino boards above, it doesn’t have a built-in analog-to-digital converter (ADC) so if you want to use any analog sensors (and there are plenty of them), you’ll need to wire in an ADC. That said, of the three, this is, by far, the most powerful – but that’s not a fair comparison. RasPi is a general-purpose computer that someone with modest needs to use as their personal computer – or as a media center – or as a full web server/DNS server/DHCP Server … you get the idea. It’s also a very, very affordable $40.
There are others out there as well. I’m also particularly interested in the Intel Galileo boards as they are Arduino-shield compatible but, like the RasPi, will run Windows 10 IoT edition (at least R1, right now … R2 runs Windows Embedded).
The Project: Weather Station Intra/Internet of Things Edition
Over the next … well, however long but I hope to be done by the end of the summer … I’ll be building out a duplicate and extension of the Raspberry Pi IoT Weather Station demo mentioned above with the Netduino as well as extending the Rasp Pi/Win10 version. We’ll set up the weather station to stream to an Intranet-Of-Things server running StreamInsight that will then publish the data internally using a modified version of Microsoft’s Connect The Dots. This will be running StreamInsight and also publish a cleansed, down-sampled stream to the Azure Event Hub. By the end of it, I hope to have a full weather station, including wind and rain meters as well as GPS, in my back yard … and, if all goes as I hope, it’ll incorporate feeds from Weather Underground of other weather stations in my area (for comparison and alerts of incoming fronts/weather changes) as well as publish to them. I’ll also hopefully have a couple of these things scattered around the house doing things like air quality, light and presence in addition to temperature and humidity. For the Intranet-Of-Things server, I’ll probably be using my recently purchased Asus VivoMini that’s running Windows Server 2012 R2.
Just today, I got all of the code running on the Netduio to access the built-in sensors of the SparkFun Weather Shield – light, temperature, humidity and pressure. There were several challenges that came out of this … and a pretty nice I2C device bus class for Netduino as well. I’ll be covering that in my next post.