It was 2012 when I first built an IoT device without even knowing that such a term already existed. Its codename was Pinpoint, and the primary goal was to allow localising objects and collecting information on their movement, which could be used in logistics to monitor a fleet of cars. Having been completed as part of my Engineering Thesis, the work ended in the closet instead of hitting the market. Back then, I didn't realise that IoT era had already begun.
A Few More Words on Pinpoint
Building electronic devices is like building from blocks (though more difficult ;).
My localisation module was made from a few blocks:
My localisation module was made from a few blocks:
- GPRS chip - handled cellular internet connection,
- sim card slot - required for the Internet service,
- GPS chip - responsible for obtaining the location,
- GPRS and GPS antennas - improving accuracy and network reception,
- power supply circuit - not all used modules had the same power requirements,
- 8-bit microcontroller - connecting all parts together.
If you think it's possible to build a mobile phone from those components, you're totally right. ;) Every element has its purpose and is incorporated in an electronic device for a reason. Let's talk more about what can hide behind the modern IoT devices.
Sensors are the eyes and ears of IoT, but they can do decidedly more than human senses. They can measure the speed, temperature and humidity among other things. Without them, there's no IoT.
Let's start with the basic one.
Yes, a button is also a sensor which we can describe as a touch sensor. It comes in many different shapes, colours and sizes. It's very simple, but there are many possibilities of use. A button could be a part of a user interface or it can be installed on the door frame to check if the doors are closed.
Do you know Amazon Dash Button? It's an IoT device that has only one sensor, and it's a button. ;-)
Quite many people still remember mercury thermometers which are no longer popular. That's because we have this tiny, smart thing called thermistor. It's a type of resistor the resistance of which is dependent on the temperature. By measuring the resistance and doing a few simple calculations, we're able to determine how hot it is at the moment. So, have all modern weather stations made the module too complicated? Not exactly. Currently, there are a lot of solutions that are much smarter and easier to incorporate. One of the most popular solutions - mostly for its price ($1-2) - is DS18B20 sensor by Maxim. It provides digital signals which the microprocessors can easily process.
Let's stay with the weather station topic. What else can we measure? Humidity? No problem, as we have all sorts of hygrometers. One of them, a resistive hygrometer, works like the aforementioned resistive thermistor. The market offers a lot of complete solutions, i.e. we have DHT11 which provides the same digital interface as DS18B20.
There is a wide range of sensors that can be integrated in IoT devices:
- distance meters,
- fingerprint readers,
- light and colour sensors,
- motion sensors,
- pressure sensors.
Even if we decide to go with a particular sensor, we will face a challenge to pick out the one that will be suited for our needs. This could be very challenging, as we need to make allowances for a number of factors, such as the size, supply voltage, power consumption, communication standard, a range of measured values, ability to work in the desired environment, etc.
Actuators are elements which produce information. The most basic one I can think of is LED. It's a simple element similar to the button with the difference that it can be used in a variety of places performing a number of tasks - from just signaling if the device is on, through being a part of a display, ending on emitting infrared light used to illuminate the target environment in the night vision cameras. I probably wouldn't be wrong if I said that 99% of IoT devices have at least one LED.
Besides, LEDs are the fundamental element of almost all types of displays - from a simple seven-segment display to 4k LCD monitors.
Another simple element used as an actuator is the speaker. Some of the devices use basic types of electroacoustic transducers (that's the speaker's realm name), but Apple took a step further and focused sharply on it in their new HomePod. This shows how a simple element can be redesigned and tweaked.
Let's move on to the issue of motors which are more complicated than LEDs and speakers. There is a range of motors and picking the one that suits our needs could be more difficult than picking a sensor. Motors are used for many purposes. One of them is the production of drones. Simple ones could be considered as toys, but there are models which may qualify as IoT devices. What we should consider when picking the right motor for a drone?
It should be small and light, but at the same time, it should produce enough thrust to lift the whole construction. Another very important aspect to consider is power consumption. It should not drain batteries very fast. Those are only the basic parameters, advanced knowledge about mechanics and electronics which help you make the right choice. Things like inertia, torque, peak current and more need to be considered as well.
What if we want an actuator that will produce rotating movement with an ability to move in a predefined range and at a specified angle? For that purpose, we can use servo - a motor with attached gears and electronics designed for controlling the whole mechanism. Where can we use it? As always, possible applications are limitless - here are some of them:
- moving the lock pad in an automatic lock,
- controlling the rudder in an autonomic boat,
- moving the robot's arms.
Another element which a motor usually contains is a pump which can be used in the home automation system.
We have an overview of different sensors and actuators, but how to connect it all together? We need to thank Gary Boone and Michael Cochran for inventing the first microprocessor. To put it simply, microprocessors are the hearts of IoT devices. They process signals and tell actuators what to do. In reality, the case is a little bit different and, usually, it's the microcontroller that's the heart. What's the difference? Similarly to the motor and servo, the microcontroller (often called uC, where u derives from the Greek letter mu(μ) that stands for micro in the metric system) is an integrated circuit which contains the processor, ROM, RAM and some input/output peripherals.
We can find a variety of microcontrollers on the market. The most basic way to divide them is by their microprocessor architecture. We can consider an 8-bit architecture as the minimum. Does it ring a bell? Let me explain. In 8-bit microprocessors, the memory addresses or other data units are those that are 8-bit wide. Every processor has a limited set of operations which can be performed. Let's look into it based on the easiest example: Addition. An 8-bit processor can add two 8-bit values in a single microprocessor cycle. The number of cycles per second is described by the clock rate usually expressed in MHz. If the processor is running at the clock rate equal to 12MHz, it can perform 12,000,000 add operations on 8-bit values within one second. An 8-bit value can take a number from 0 to 255. To sum up, the 8-bit microprocessor running at the 12MHz clock rate can add on the numbers from 0 to 255 twelve million times. This could raise the question if one can calculate numbers above 255 on an 8-bit processor? Certainly, but it will take more cycles. A single addition will take a few cycles. These types of processors can be used in applications where high computing power is not needed. I used an 8-bit microprocessor in my Pinpoint device - Atmega128 by Atmel. As a side note, modern smartphones use 32-bit or 64-bit architecture with a high clock rate. Thanks to that, it can run the whole operating system and very complex applications with ease.
As mentioned before, the microcontrollers can have different types of in/out peripherals. Those are used to communicate with both the sensors and actuators. As always, we employ the easiest way of communication, i.e. the logic level communication. There are only two states - 1 and 0. Simple? Yes, but it's enough to control the diode.
Let's go back to the DS18B20 temperature sensor. It provides an easy to use transmission interface called 1 Wire. As the name implies, it requires only one wire (plus ground). The transmission speed can reach up to 115.2 kbps, which is not much comparing to wifi or LTE but enough for basic applications that pass the temperature value.
Another example of a simple communication standard is I^2C. The work concept is pretty similar to 1-Wire, but - in this case - we can achieve higher data rates. As for the downsides, it works on smaller distances.
One of the most widely used communication standards is UART (Universal asynchronous receiver/transmitter). Many components, such as GPS or GSM modules used in my Pinpoint device, have a built-in piece of hardware that supports UART. Having UART in used microcontroller made it easy to implement. Most companies producing microprocessors provide solutions on how UART can be used in their data sheets. Sometimes you can even find some code examples there.
What is more, certain modules support USB by default, but more often than not, they are pretty advanced and require higher data speed.
If you've enjoyed my post, stay tuned. More about programming microcontrollers, development boards and connecting them with mobile apps soon!
More posts by this author