Creating applications for the Internet of Things is surprisingly easy yet not without challenges. But don’t worry – you don’t have to go at it alone.
Are you ready to turn your ideas into an Internet of Things hardware-software reality? Here’s my simplified, friendly guide to building an IoT application, followed by a more detailed explanation of the ARM mbed.org development platform provided by samgrove, Staff Applications Engineer. -- JB
To play in the space, it’s best to have a desire to make something. Perhaps you've heard the sirens call to innovate - or you just like to tinker. Either way, you need to start with a passionate idea.
To play in the IoT world you’ll need a mix of hardware and software, but this isn't your dad’s pre-Internet transistor-resistor-capacitor component-based world. Today, you simply pick from an inexpensive (starting at $10) set of pre-configured hardware and begin coding.
And by jamming I mean creating the software that brings your hardware to life. You’ll need some hardware experience, but not much. Naturally, all of the tools needed to create your software are free.
There is no way around it. Sooner or later, you’ll run into problems and that’s where an active, online community can make all the difference. This is especially true in today’s globally connected collaborative development team environments. So go out and make new friends while you fix those problems and say “Hello” to the world.
OK, this isn't academia. Still, you need to document your work. Or do you?
This is just another way of saying to come with an idea.
Grove: There are all sorts of pre-configured hardware platforms on the ARM mbed.org site. Typically you start by looking for the performance you want based upon your requirements. The site allows you to select the requirements that are most important to you. For $10, you can easily create a microcontroller based project with a 50MHz ARM processor. On-board connectivity options range from Bluetooth to Ethernet or other separate component. The unique hardware comes from the competitive suppliers of the actual ARM-based microcontroller silicon, so they have incentives to keep the costs low.
Also, each one of the mbed boards has a mass storage device interface. Once compiled, you can drag and drop your application onto the board’s microcontroller. This means that you can develop embedded systems from anywhere with just a USB cable, a laptop and an Internet connection.
Blyler: Most IoT applications need some wired or wireless connectivity. How is that done in an mbed design?
Grove: Many of the hardware boards have built in wired (ethernet) and wireless (Bluetooth, WiFi and cellular) connectivity. If not, it can be added as a component, say a radio module. APIs are available to provide a common interface via a standard Berkeley Sockets Interface (BSD). That way, you can focus on writing your application – like pulling in libraries - instead of worrying about the transport mechanism. For example, if you need an ethernet connection, you just pull the library down into your program.
Blyler: What do you mean by components?
Grove: Components are the artifacts or modules that you need to make your design functional, e.g, sensors, radios, interfaces, etc. Typically, components are add-ons to the board and not part of the microcontroller system. You pick the components based upon your requirements and the base platform. The components come with all of the documentation, data sheets, and purchasing/buying information that you’ll need to get started.
Grove: mbed is a free development platform. It doesn't cost the developer anything to set up an account or to use the software tools like the hosted integrated development environment (IDE) and online code compiler. You can write your code in a web browser, compile it and then download the binary result onto your hardware board.
The mbed Software Development Kit (SDK) – the software package to develop applications – is native to all mbed projects or boards. When you create a new program, the SDK incorporates the needed dependencies for component libraries, device drivers and the like. That component will be compatible across all 20 or so platforms that have the required resources on the microcontroller to drive that peripheral or module.
The online IDE has all the revision control and collaboration tools that are expected for modern software development. Of course, you can export your project with Makefiles to any of the major off-line tool chains, e.g., GNU Compiler Collection (GCC).
Blyler: Why work online?
Grover: The online development tools remove many of the configuration hurtles that typically trip up programmers, i.e., numerous compiler and linker options. The idea is to make the make code development extremely productive by encouraging developers to focus exclusively on writing code and using the collaboration tools.
Blyler: Does mbed support Java?
Grove: mbed is programmed in assembly, C or C++ languages. If you are coming from Java, then C/C++ concepts like constructs and object oriented programming should be fairly simple. Learning the syntax shouldn't be a huge learning curve, either. But without a run-time environment to handle memory allocations and usage will mean that Java programmers must appreciate the memory constructs of C.
We see an interesting trend from our events and workshops. Programmers that come from higher-level languages (like Java) and script-based text languages tend to jump feet first into embedded development. They are not afraid to dive in and focus on making API calls. They are less concerned about the nitty-gritty details of the microcontroller or the peripherals.
Blyler: Collaboration is seldom easy - but it is a necessity for larger project. How is collaboration handled on mbed?
Grove: It doesn't matter where your team is located. Actually, since we publish the schematics, anyone can make any of the boards from scratch to fit their size and shape requirements. So all of the team can have the same hardware, software development tools and project settings that allows them to work on different parts of the project. As the day goes on, people can continuously pull updates and changes from each other.
Blyler: How would your secret algorithm or code be protected?
Grove: There are multiple ways, even though the IDE is in the cloud it is not part of mbed.org. All of the code and changes that you do in the IDE are completely private, located in a totally separate work space. Only when you decide to publish do you need to decide who has access and permissions to your work. In a collaborative space, it will be up to the team to manage members and decide how they choose to do a development with their intellectual property (IP). Repositories hosted on mbed.org can be set as public, public(but unlisted) or private.
Blyler: What happens when you need help?
Grove: We have a very vibrant online community. Over 75% of the questions asked on the site are answered by other community members. There is a vibrant ecosystem of developers on the site daily, helping each other out and sharing knowledge about some of the work they are doing. The goal is to break down barriers to rapidly build an embedded project.
Blyler: Few people like to document their work. Does the mbed platform automate this task?
Grove: We try to encourage good practices, both in code and documentation. Many people get focused on little distractions like the number of code indention spaces or the use of paths instead of spaces and that’s why we provide an automatic code formatting button. With a single click, you can automatically format your work to mbed approved good coding and style practices (K&R style).
The same approach is used in the generation of documentation. By inserting a couple of extra hash lines or symbols before and after your comments in your code, you’ll be able to generate some nice HTML, linkable documentation. For example, if you write a library and want to include a link to a datasheet, then the tool will automatically generate an HTML document. This way, when other people look at your code, they don’t have to get into your source to see what it is doing.
Another benefit of documentation is dependency tracking. On the public site, you can track the source of code published by others. You can find out if the code has been forked/sourced from another project and how many dependencies it has. That way you can follow the dependency tree or follow the fork history to find the original piece of code. This will help you determine whose code is best to use. For example, let’s say you’re trying to figure out whether to use John’s or Sam’s code. It may be that John’s code is a fork of Sam’s code, so you decide to look at the revision history. Since everything is under version control, you would see that John wrote a note concerning bug fixes, bus overflow, etc. You would actually see the “diff” of what lines of code have changed. From this, you’d quickly realize that Sam did a quick and dirty job to get something working but maybe didn't write as many tests as he should have to make sure his code was robust.
Blyler: That’s raises another point, namely, the availability of test suites.
Grove: We are working to bring that capability to the mbed site. Look for continued progress in the future.
Blyler: Thank you.