My First Jab at IoT
What is the internet of things?
The “Things” are literally… things. Things with sensors of some sort that are capable of receiving and pushing data through a network, or to an IOT gateway and that gateway pushes that data to be used and analyzed to do whatever the software or person at the other end needs to do with it.
One example is smart parking. There is a an engineer out of New Zealand, named Brian Granatir that works for Smart Parking, that is using Google’s IoT core and GCP along with his manufactured sensors to build an app that people could use to see where there is parking near them in whatever city that they might be in. The sensors would allow the app to tell users which parking decks/lots are available, how many spots are available. And which level of that parking deck (if it is a parking deck). This came from the Google Cloud Platform Podcast that I frequent, and highly recommend if you’re interested in all things that are cool, in tech. They also interviewed Vint Cerf, one of the original creators of the internet. Really cool interview.
Another example (more of an idea that’s kinda in the works) is the implementation of Apple watches to track health.. anything. There is already such a connected and thick concentration of information that is available in healthcare as of recently because of the introduction of technology for tracking and storing information about patients. What is holding the industry back is that most of the data and information is from in-hospital visits, only. A non-intrusive way to monitor health even when there is no immediate concern is by using a device many have, like the Apple Watch (granted it’s mostly people that can afford it).
So let’s get into talking about the ideal operating system for IoT development. The idea originally was super low cost and low-energy based systems, thus many embed systems run on 8 to 16 bit architectures and use more limited OS’s. This may sound like a negative, but you wouldn’t need a tow-truck to move a toy car. Obviously, build for the necessity and affordability of the current need. Alternatively, sometimes you need to build a tow-truck because you need to move that car. With more complex needs arising, more complex and sophisticated tools need to be used. For these needs there is now hardware that can run a complete RTOS (Real time operation system) that includes…
a kernel
UI
File System
USB support
Networking capabilities
and more can fit in a memory space of less than 1 mb of RAM.
because of all of this and the fact that these more powerful devices are becoming less and less expensive, embedded and IoT developers are really taking to it.
It allows for greater flexibility and easier troubleshooting
Here’s a quick video that explains RTOS pretty well at a high-level:
<a href="https://medium.com/media/a1f8cfb4c6ac7a312f9eacf62d7fa511/href">https://medium.com/media/a1f8cfb4c6ac7a312f9eacf62d7fa511/href</a>
Now going back to talking about gateways to try to meet that happy medium in cost and efficiency. You could have many embedded devices running on a 16 bit architecture that don’t have all of the capabilities of a more complex operating system, and they could connect to a gateway that would handle all of the network related necessities.
We will take a look at two different IoT Operating systems on the market. One is open-source and one is closed/commercial.
RIOT came out around 2013 (If you can’t use linux, try RIOT)
Riot is open-source, free core, and driven by a grassroots community. RIOT isn’t targeting raspberry-pis or phones. It is more geared towards “things” that have a few Kbs of ram and no MMU’s. Programming languages used in RIOt is C++ and ANSI-C. It provides some POSIX features like pthreads and sockets. Also, no IoT specific hardware is needed for development. You can run and debug RIOT as a native process on Linux, with things that we are used to like GDB and Valgrind. Because of this, you can simulate your IoT device or network of devices on your computer.
Let’s get into some of the RIOT specs.
Microkernel architecture that uses ~1.5k of RAM
RIOT is built to be able to support 8, 16, and 32 bit So there is potential to building once and deploying everywhere.
Tickless scheduler for energy-efficienty unless there is actual work to do, your device can stay in deep-sleep mode
Deterministic O(1) scheduling for real-time
Low latency interrupt handling for reactivity
Preemptive multi-threading & powerful IPC
RIOT supports..
Many different PHY technologies like (IEEE802.15.4, IEEE802.3, Bluetoooth, NFC, serial, CAN bus.
Interoperability tested IETF 6lo implementation
IPv6 (which is good. I’ll explain later)
UDP, TCP
COAP, with MQTT-Sensor Network (coming soon)
Android Things is a variant of android that was optimized for IoT that replaced their previous service called Brillo.
Android Things gives you…
Ability to use the Android SDK and google play toolkit to build out applications
Capability to easily integrate with different things that Google offers like TensorFlow, Firebase, GCP ( the thing I talked about earlier in my examples with the parking thing )
Android things currently supports a few different boards, including Raspberry Pi 3 and a few different NXP boards. These have at least half a gb of memory and run at between 500 mhz and 1 ghz. (I know nothing about these boards since I haven’t done anything with hardware besides building my PC, which hardly equates). as opposed to some lighter iot kits that run on micro controllers that run at 48 to 96 mhz and maybe have 256 or less k of ram.
That is because Android Things necessitates more power because it is Linux based which means that it is a full multi tasking system with virtual memory support which needs a more sophisticated MMU (memory management unit) Because of these higher requirements though, things like voice and facial recognition and higher levels of AI are possible. The obvious downside is the level of entry. It costs much more at scale because of the hardware requirements, but Google has made it easier on you in terms of the power of Android, Security, and the fact that it is managed by Google.
It’s actually pretty easy to build IoT apps with Android Things. You’d build them in Android Studio the same way that you’d build actual android applications, which makes it easy for you to connect your Android apps, with your Android Thing, whatever that may be.
The obvious and major difference between building for an android phone and building an IoT app for one of these boards, is that you have direct access to the hardware, like buses, input output pins, and other types of tech that I have limited knowledge of.
The major similarity is the connectivity to the internet. Creating an ease of gathering and analyzing information, or updates over the cloud.
Some issues:
With this amount of things being connected through the internet, we are running out of addresses. Thus, IPv4 is facing a global shortage. IPv6 aims to fix that issue, so to future proof your IoT applications and devices should support IPv6. If your goals are more short term, then IPv4 should be fine. On the other hand, to reduce the load from each IoT device, you could have them push all of their information to a Gateway.
Also, the issue of security. In open-source, it is a little harder to guarantee security whereas Google can guarantee a specific level of security with Android Things. I am a huge advocate for open-source projects because of the sheer amount of incredibly smart people finding common ground and building because they’re passionate about the product. There are still ways to securely use open-source technology. You just have to make sure to pay more attention to it.
Anyways, people are constantly complaining about their privacy and security and consistently choose convenience over security. If you think about it, if your smart toaster is connected to the app on your phone, then you’re running a security risk. Do you really trust the manufacturers of that smart toaster to have fully secured its connectivity? They care more about getting it to market, than anything else. Now don’t get me wrong, I’m not saying to not buy all the cool connected stuff! I want you to buy it, and I want to buy it. I’m just saying, be aware and informed about what you are buying and the trade-off with security and convenience.