Preface
One of the most fascinating trends today is the emergence of low-cost microcontrollers that are sufficiently powerful to connect to the Internet. They are the key to the Internet of Things , where all kinds of devices become the Internets interface to the physical world.
Traditionally, programming such tiny embedded devices required completely different platforms and tools than those most programmers were used to. Fortunately, some microcontrollers are now capable of supporting modern software platforms like .NET, or at least useful subsets of .NET. This allows you to use the same programming language (C#) and the same development environment (Visual Studio) when creating programs for small embedded devices, smartphones, PCs, enterprise servers, and even cloud services.
So what should you know in order to get started? This book gives one possible answer to this question. It is a Getting Started book, so it is neither an extensive collection of recipes (or design patterns for that matter), nor a reference manual, nor a textbook that compares different approaches, use cases, etc. Instead, its approach is less is more, helping you to start writing Internet of Things applications with minimal hassle.
The Platforms
The .NET Micro Framework (NETMF) provides Internet connectivity, is simple and open source (Apache license), has hardware available from several vendors, and benefits from the huge .NET ecosystem and available know-how. Also, you can choose between Visual Studio (including the free Express Edition) on Windows, and the open source Mono toolchain on Linux and Mac OS X.
There is an active community for NETMF at http://www.netmf.com/Home.aspx . The project itself is hosted at http://netmf.codeplex.com/ . Netduino Plus ( http://www.netduino.com/netduinoplus ) is an inexpensive NETMF board from Secret Labs ( http://www.secretlabs.com ). This board makes Ethernet networking available with a price tag of less than $60. It has the following characteristics:
A 48 MHz Atmel SAM7 microcontroller with 128 KB RAM and 512 KB Flash memory
USB, Ethernet, and 20 digital I/O pins (six of which can be configured optionally for analog input)
Micro SD card support
Onboard LED and pushbutton
Form factor of the Arduino ( http://www.arduino.cc/ ); many Arduino shields (add-on boards) can be used
.NET Micro Framework preprogrammed into Flash memory
All software and hardware is open source
There is an active community for the Netduino Plus (and NETMF) at http://forums.netduino.com/ . All the examples in this book use the Netduino Plus.
How This Book Is Organized
The book consists of three parts:
The first part tells you how to set up the development environment and write and run a program. It shows how to write to output ports (for triggering so-called actuators such as LED lights or motors) and how to read from input ports (for sensors ). It then introduces the most essential concepts of the Internet of Things: HTTP and the division of labor between clients and servers. In the Internet of Things, devices are programmed as clients if you want them to push sensor data to some service; they are programmed as servers if you want to enable remote control of the device over the Web.
The second part focuses on examples that send HTTP requests to some servicese.g., to push new sensor measurements to the Pachube service ( http://www.pachube.com ) for storage and presentation.
The third part focuses on examples that handle incoming HTTP requests. Such a request may return a fresh measurement from a sensor, or may trigger an actuator. A suitable server-side library is provided in order to make it easier than ever to program a small device as a server.
This contains a simple test server that comes in handy for testing and debugging client programs.
This shows the .NET classes that are needed to implement all examples, and the namespaces and assemblies that contain them.
This summarizes the interface of the helper library Gsiot.Server
that we use in .
Who This Book Is For
This book is intended for anyone with at least basic programming skills in an object-oriented language, as well as an interest in sensors, microcontrollers, and web technologies. The books target audience consists of the following groups:
Artists and designers
You need a prototyping platform that supports Internet connectivity, either to create applications made up of multiple communicating devices, or to integrate the World Wide Web into a project in some way. You want to turn your ideas into reality quickly, and you value tools that help you get the job done. Perhaps you have experience with the popular 8-bit Arduino platform ( http://www.arduino.cc/ ), and might even be able to reuse some of your add-on hardware (such as shields and breakout boards ) originally designed for Arduino.
Students and hobbyists
You want your programs to interact with the physical world, using mainstream tools. You are interested in development boards, such as the Netduino Plus, that do not cost an arm and a leg.
Software developers or their managers
You need to integrate embedded devices with web services and want to learn the basics quickly. You want to build up an intuition that ranges from overall system architecture to real code. Depending on your prior platform investments, you may be able to use the examples in this book as a starting point for feasibility studies, prototyping, or product development. If you already know .NET, C#, and Visual Studio, you can use the same programming language and tools that you are already familiar with, including the Visual Studio debugger.