You are on page 1of 81

Embedded Devices

The definition of a “Thing” in the Internet of Things varies a lot. We define a Thing as an
embedded computing device (or embedded system) that transmits and receives information over a
network.

What is an Embedded System?

Embedded systems are based on microcontrollers (MCUs), and run


software with a small memory footprint. Some Linux and Android-
based systems can also be described as embedded systems. But
usually, these general-purpose operating systems require an
application processor, and have additional capabilities such as
dynamic application loading. This is why MCU-based embedded
systems are often described as deeply embedded systems, versus the
more general definition of embedded systems. These deeply
embedded systems are the Things in the Internet of Things.

MCUs featuring 32-bit architectures have dropped in price over the last several years, and are becoming
common in embedded systems. The greater capabilities of 32-bit MCUs present new choices for
embedded systems developers.

For 8 and 16-bit MCUs, software has often been written using a foreground/background approach (that
is, a super-loop). But with 32-bit MCUs dropping in price, a real-time operating system (RTOS) is now
the preferred option, allowing for more flexible and extensible software to run on these systems. A
complete RTOS – with a kernel, GUI, file system, USB stack, networking, and more – can fit in a
memory space of less than 1MB. With an RTOS, the software architecture of an embedded system can
be more flexible. Troubleshooting and adding new features becomes dramatically simplified. It is also
simpler to perform firmware upgrades. In summary, it just makes sense to use an RTOS with a 32-bit
processor.

6|Page
Processors for the Things

So which processor architecture should you choose? To date,


the main contenders are Intel and ARM.

Intel has positioned its Atom processor as an embedded CPU,


and has targeted it at the industrial Internet. The new Intel Quark,
on the other hand, is aimed squarely at the deeply embedded
system market.

ARM’s family of processors includes a wide range of 32-bit


architectures that are licensed to a large number of suppliers.
The ARM chips are among the best low-power architectures,
and processor software start-up is a lot simpler compared to
Intel.

It’s commonly believed that IoT hardware should always be low-cost, so that we can flood the planet
with IoT devices (an IP address for every light bulb). But in fact, low-cost is not the solution for every
application, especially when IP networking is concerned.

First off, a TCP/IP stack is not a small piece of code. Of course, you can find open source TCP/IP stacks
that fit within 32 KB of code space, but usually this is achieved by taking liberties with the TCP/IP
standards. This can cause problems because you may need a device that can operate on the vast majority
of IP networks.

Second, TCP needs a fair number of network buffers to work efficiently, which require precious RAM.
And, if you need to use Java, then the IoT device will require an RTOS as the foundation to run the Java
virtual machine (JVM). All these elements work against the choice of a low-cost architecture for the IoT
device.

Picking an MCU

Which MCU makes a good starting point when designing an IoT device?

• For an ARM processor in the IoT device, the Cortex-M0 is perfect. For gateways, the ARM
Cortex-M3/M4 or Cortex-A are good choices because of their greater processing capabilities.

• For non-ARM processors, a good option is the Renesas RL78 or RX100 for the IoT device,
and the Renesas RX600 or RZ for the gateway.

Either way, new processors with more flash memory and more RAM appear on the market regularly, and
always at a lower cost.
7|Page
Power Conservation

Until recently, a common strategy to save power in an embedded system was to execute as quickly as
possible, and then go into sleep mode immediately. But there are now processor core architectures that
consume almost no power, although with reduced performance. This is an attractive option for a WSN
edge node design. This tradeoff of power for performance means designing transistors that operate close
to (or below) their threshold voltage.

ARM is currently working on a processor core optimized for operation close to the threshold voltage of
CMOS transistors, and at clock frequencies of the order of tens of kilohertz. ARM’s near-threshold
design is compatible with the Cortex-M0 architecture, which is good news for the software community.
Near-threshold designs are easier to achieve, as ARM can work with multiple foundries without having
to characterize the chip process. This is not the case with sub- threshold design, which would require a
custom manufacturing process, and which brings greater risk.

Programming Languages

The programming languages used in deeply embedded systems include C, C++ and sometimes Java. It
is important to note that Java always runs on top of an operating system. So, your choice is not
between C/C++ or Java; it is whether you will use C/C++ and Java.

Java is attractive for IoT devices because the number of Java developers worldwide brings tremendous
growth potential to the industry. Oracle and ARM estimate there are about 450,000 embedded software
engineers across the globe, and about nine million Java developers.

The resource requirements for a Java engine are not negligible. Oracle’s Java ME Embedded is
designed for small devices, and Oracle estimates the following system requirements:

System based on ARM architecture SOCs

• Memory footprint (approximate)


• From 130 KB RAM/350KB ROM (for a minimal, customized configuration)
• To 700 KB RAM/2000 KB ROM (for the full, standard configuration)
• Very simple embedded kernel, or a more capable embedded OS/RTOS
• At least one type of network connection (wired or wireless)
8|Page
These numbers don’t meet definition of a deeply embedded device. The above requirements, plus the
embedded kernel and the communication stack, pushes the total into megabytes of ROM and RAM.
Clearly, Java’s role in IoT devices will be limited to more capable and expensive systems.

Thing Design

When cost is not an issue, you can select a single powerful processor to run all the tasks required of
your device. However, a common engineering compromise is to use two processors in the
sensor/actuator device. One low-cost processor (8 or 16 bit) is used for the physical- world interface,
and a second 32-bit processor runs the network interface. This second processor is often placed in a
separate module, one that has already been certified for the protocol and FCC compliance.

When two processors are used, a real-time kernel is not strictly required for the sensor/actuator
processing, but is strongly recommended for the communication module.

9|Page
Gateway Design

A gateway connects two dissimilar networks so that data can flow between them. Usually this is a
connection between a proprietary network and the Internet.

For example, in home automation, different utilities companies may install a wide variety of IoT
devices in your house, each with their own gateway. These can include electricity or gas, water,
phone, Internet, cable/satellite, alarm system, medical devices, and so on. Some of these gateways
may require additional functions, such as local storage, or a user interface.

10 | P a g e
The Internet

Communication is central to the Internet of Things. Networking technologies enable IoT devices to
communicate with other devices as well as with applications and services that are running in the cloud.
The internet relies on standardized protocols to ensure that communication between heterogeneous devices
can occur securely and reliably. Standard protocols specify the rules and formats that devices use for
establishing and managing networks, as well as for transmission of data across those networks.

We often describe networks as being built up from a stack of technologies, with technologies at the
bottom of the stack, such as Bluetooth LE, relating to physically connecting devices, while technologies
further up the stack, such as IPv6, relating to logical device addressing and routing of network traffic.
Technologies at the top of the stack are used by the applications that are running on top of those layers,
for example, message queuing technologies.

In this article, I describe some widely adopted technologies and standards for IoT networking. I also
explain when you might want to choose one network protocol over another. I then discuss key
considerations and challenges that are related to networking within IoT, including range, bandwidth,
power usage, intermittent connectivity, interoperability, and security.

11 | P a g e
Networking standards and technologies

The Open Systems Interconnection (OSI) model is an ISO-standard abstract model that describes a stack
of seven protocol layers. From the top down, these layers are: application, presentation, session,
transport, network, data link and physical. TCP/IP, or the Internet Protocol suite, underpins the internet,
and it provides a simplified concrete implementation of these layers in the OSI model.

Figure 1. OSI and TCP/IP networking models

The TCP/IP model includes only four layers, merging some of the OSI model layers (see Figure 1):

• Network Access & Physical Layer


This TCP/IP Layer subsumes both OSI layers 1 and 2. The physical (PHY) layer (Layer 1 of
OSI) is concerned with how each device is physically connected to the network with
hardware, for example with an optic cable, wires, or radio in the case of wireless network like wifi
(IEEE 802.11 a/b/g/n). At the link layer (Layer 2 of OSI), devices are identified by a MAC
address, and protocols at this level are concerned with physical addressing, such as how switches
deliver frames to devices on the network.
• Internet Layer
This layer maps to the OSI Layer 3 (network layer), which relates to logical
addressing. Protocols at this layer define how routers deliver packets of data between
source and destination hosts identified by IP addresses. IPv6 is commonly adopted for
IoT device addressing.

• Transport Layer
The transport layer (Layer 4 in OSI) is focused on end-to-end communication and provides
features including reliability, congestion avoidance, and guaranteeing that packets will be
delivered in the same order that they were sent. UDP (User Datagram protocol) is often
adopted for IoT transport for performance reasons.
• Application Layer
The application layer (Layers 5, 6, and 7 in OSI) covers application-level messaging. HTTP/S is
an example of an application layer protocol that is widely adopted across the internet.

12 | P a g e
Although the TCP/IP and OSI models provide you with useful abstractions for discussing networking
protocols, and the specific technologies that implement each protocol, in practice, some protocols don't
fit neatly into these layered models. For example, the Transport Layer Security (TLS) protocol that
implements encryption to ensure privacy and data integrity of network traffic can be considered to
operate across OSI layers 4, 5, and 6.

IoT networking protocols

Some of the networking protocols that are widely adopted within IoT and where they fit within the TCP/IP
layers are shown in Figure 2.

Figure 2. IoT network protocols mapped to the TCP/IP model

13 | P a g e
Many emerging and competing networking technologies are being adopted within the IoT space. Multiple
technologies are offered by different vendors or are aimed at different vertical markets like home
automation, healthcare, or industrial IoT, often provide alternative implementations of the same standard
protocols. For example, IEEE 802.15.4 describes the operation of low-rate wireless personal area networks
(LR-WPANs) and is implemented by several competing technologies including ZigBee, Z-Wave,
EnOcean, SNAP, and 6LoWPAN.

Technologies used for internet connectivity, like Ethernet, for example, can often be applied within the
IoT; however, new technologies are being developed specifically to meet the challenges of IoT. As you
look further down the stack toward physical transmission technologies, you face more challenges that
are specific to IoT devices and IoT contexts.

The structure of a network is known as its topology. The most common network topologies that are adopted
within IoT are star and mesh topologies. In a star topology, each IoT device is directly connected to a
central hub (gateway) that communicates the data from the connected devices upstream. In mesh
topologies, devices connect to other devices within range, and nodes within the network can act as simple
sensor nodes, as sensor nodes that also route traffic, or as gateway nodes. Mesh networks are more complex
than networks with star topologies, but have the advantage of being more resilient to failure because they
don't rely on a single central gateway.

Network access and physical layer IoT network technologies


IoT network technologies to be aware of toward the bottom of the protocol stack include cellular, wifi,
and Ethernet, as well as more specialized solutions such as LPWAN, Bluetooth Low Energy (BLE),
ZigBee, NFC, and RFID.

• LPWAN
(Low Power Wide Area Network) is a category of technologies that are designed for low- power,
long-range wireless communication, and so they are ideal for use within large-scale deployments
of low-power IoT devices like wireless sensors. LPWAN technologies include LoRa (LongRange
physical layer protocol), Haystack, SigFox, LTE-M, and NB-IoT(Narrow- Band IoT).

• Cellular
The LPWAN NB-IoT and LTE-M standards are aimed at providing low-power, low-cost IoT
communication options using existing cellular networks. NB-IoT is the newest of these standards
and is focused on long-range communication between large numbers of primarily indoor devices.
LTE-M and NB-IoT were developed specifically for IoT, however existing cellular technologies
are also frequently adopted for long-range wireless communication.
These include 2G (GSM), which is mostly used in legacy devices, and which is currently
being phased out, as well as CDMA, 3G, and 4G.

• Bluetooth Low Energy (BLE)


BLE is a low-power version of the popular Bluetooth 2.4 GHz wireless communication protocol.
It is designed for short-range (no more than 100 meters) communication, typically in a star
configuration, with a single primary device that controls several secondary devices. Bluetooth
operates across both layers 1 (PHY) and 2 (MAC) of the OSI model, which is shown in Figure 1.

14 | P a g e
BLE is best suited to devices that transmit low volumes of data in bursts, as the devices are
designed to sleep to save power when they are not transmitting data. Personal IoT devices
like wearable health and fitness trackers often use BLE.

• ZigBee
ZigBee also operates on 2.4GHz wireless communication spectrum, but it has a longer range than
BLE of up to 100 meters. It also has a slightly lower data rate (250 kbps maximum compared to
270 kbps for BLE) than BLE. ZigBee is a mesh network protocol, and unlike BLE, not all devices
can sleep between bursts, depending on their position in the mesh and whether they need to act as
routers or controllers within the mesh. ZigBee was designed for building and home automation
applications, like controlling lights. Another closely related technology to ZigBee is Z-Wave,
which is also based on IEEE 802.15.4 MAC. Z-Wave was also designed for home automation, and
it was a proprietary technology that was recently released as a public domain specification.

• NFC
The near field communication (NFC) protocol is used for very small range communication (up to 4
cm), such as holding an NFC card or tag next to a reader. NFC is often used for payment systems,
but it is also useful for check-in systems and smart labels in asset tracking in Industrial IoT
applications.

• RFID
RFID stands for Radio Frequency Identification. RFID tags store identifiers and data and are attached
to devices for reading by an RFID reader. The typical range of RFID is less than
a meter. RFID tags can be active, passive, or assisted passive. Passive tags are ideal for devices
without batteries, as the ID is passively read by the reader. Active tags periodically broadcast their
ID, while assisted passive tags become active when RFID reader is present. Dash7 is a
communication protocol that uses active RFID that is designed to be used within Industrial IoT
applications for secure long-range communication. Similar to NFC, a typical use case for RFID is
tracking inventory items within retail and industrial IoT applications.

• Wifi
Wifi is standard wireless networking based on IEEE 802.11a/b/g/n specifications. 802.11n offers the
highest data throughput, but at the cost of high-power consumption, so IoT devices might only use
802.11b or g for power conservation reasons. Although wifi is adopted within many prototype and
current generation IoT devices, as longer-range and lower-power solutions become more widely
available, it is likely that wifi will be superseded by these lower- power alternatives.
• Ethernet
Widely deployed for wired connectivity within local area networks, Ethernet implements the IEEE
802.3 standard. Not all IoT devices need to be wireless devices that are designed to be stationery.
For example, sensor units that are installed within a building automation system can use wired
networking technologies like Ethernet. Power line communication (PLC) is an alternative hard-
wired solution that uses existing electrical wiring instead of dedicated network cables.

15 | P a g e
Internet layer IoT network technologies
Internet layer technologies (OSI Layer 3) are concerned with identifying and routing packets of data.
Technologies that are commonly adopted for IoT that are related to this layer include IPv6, 6LoWPAN, and
RPL.

• IPv6
At the Internet Layer, devices are identified by IP addresses. IPv6 is typically used for IoT applications over
legacy IPv4 addressing. IPv4 is limited to 32-bit addresses, which only provide around 4.3 billion addresses
in total, which is less than the current number of IoT devices that are connected, while IPv6 uses 128 bits, and
so provides 2128 addresses (around
3.4 × 1038 or 340 billion billion billion billion) addresses. In practice, not all IoT devices need
public addresses. Of the tens of billions of devices that are expected to connect to the IoT over the
next few years, many will be deployed in private networks that will use private address ranges and
only communicate out to other devices or services on external networks by using gateways.
• 6LoWPAN
The IPv6 Low Power Wireless Personal Area Network (6LoWPAN) standard allows IPv6 to be used
over 802.15.4 wireless networks. 6LoWPAN is often used for wireless sensor networks, and the Thread
protocol for home automation devices also runs over 6LoWPAN.
• RPL
The Internet Layer also covers routing. IPv6 Routing Protocol for Low-Power and Lossy Networks
(RPL) is designed for routing IPv6 traffic over low-power networks like those networks implemented
over 6LoWPAN. RPL (pronounced "ripple") is designed for routing packets within constrained
networks such as wireless sensor networks, where not all devices are reachable at all times and where
there are high or unpredictable amounts of packet loss. RPL can compute the optimal path by
building up a graph of the nodes in the network based on dynamic metrics and constraints like
minimizing energy consumption or latency.

Application layer IoT network technologies

HTTP and HTTPS are ubiquitous across internet applications, which is true also within IoT, with RESTful
HTTP and HTTPS interfaces widely deployed. CoAP (Constrained Application Protocol) is like a
lightweight HTTP that is often used in combination with 6LoWPAN over UDP. Messaging protocols like
MQTT, AMQP, and XMPP are also frequently used within IoT applications:

• MQTT
Message Queue Telemetry Transport (MQTT) is a publish/subscribe-based messaging protocol
that was designed for use in low bandwidth situations, particularly for sensors and mobile devices
on unreliable networks.
• AMQP
Advanced Message Queuing Protocol (AMQP) is an open standard messaging protocol that is used for
message-oriented middleware. Most notably, AMQP is implemented by RabbitMQ.
• XMPP
The Extensible Messaging and Presence Protocol (XMPP) was originally designed for real- time
human-to-human communication including instant messaging. This protocol has been adapted for
16 | P a g e
machine-to-machine (M2M) communication to implement lightweight middleware and for routing
XML data. XMPP is primarily used with smart appliances.

Your choice of technologies at this layer will depend on the specific application requirements of
your IoT project. For example, for a budget home automation system that involves several sensors,
MQTT would be a good choice as it is great for implementing messaging on devices without much
storage or processing power because the protocol is simple and lightweight to implement.

IoT networking considerations and challenges

When you consider which networking technologies to adopt within your IoT application, be mindful of the
following constraints:

• Range
• Bandwidth
• Power usage
• Intermittent connectivity
• Interoperability
• Security

Range

Networks can be described in terms of the distances over which data is typically transmitted by the IoT
devices attached to the network:

• PAN (Personal Area Network)


PAN is short-range, where distances can be measured in meters, such as a wearable fitness tracker
device that communicates with an app on a cell phone over BLE.
• LAN (Local Area Network)
LAN is short- to medium-range, where distances can be up to hundreds of meters, such as
home automation or sensors that are installed within a factory production line that
communicate over wifi with a gateway device that is installed within the same building.
• MAN (Metropolitan Area Network)
MAN is long-range (city wide), where distances are measured up to a few kilometers, such as smart
parking sensors installed throughout a city that are connected in a mesh network topology.
• WAN (Wide Area Network)
WAN is long-range, where distances can be measured in kilometers, such as agricultural sensors that
are installed across a large farm or ranch that are used to monitor micro-climate environmental
conditions across the property.
Your network should be designed to get the data from the IoT devices to where it will be used. So, make
sure that you select a network protocol that matches the range that is required for your use case. For
example, you shouldn't choose BLE for a WAN application that needs to operate over
a range of several kilometers. If transmitting data over the required range presents a challenge, consider
edge computing, which moves the analysis to the data out to the devices, rather than moving
17 | P a g e
the data elsewhere for processing.

Bandwidth

Bandwidth, or the amount of data that can be transmitted in a specific period of time, limits the rate at
which data can be collected from IoT devices and transmitted upstream. Consider these factors:

• The volume of data that each device is generating


• The number of devices that are deployed in a network
• Whether the data is being sent as a constant stream or in intermittent bursts, as the
bandwidth that is available will need to cope with the peak periods
The packet size of the networking protocol that you choose should match up with the size of the data that is
typically being transmitted. It is inefficient to send packets padded out with empty data, but on the flip side
there are overheads in splitting larger chunks of data up across too many small packets. Data transmission
rates are not always symmetrical (that is, upload rates might be slower than download rates). So, if there is
two-way communication between devices, data transmission needs to be factored in. Wireless and cellular
networks are traditionally low-bandwidth, so consider whether a wireless technology is the right choice for
high-volume applications.

Also, consider whether all of the raw data needs to be transmitted. One solution might be to capture less
data by sampling less frequently, capturing fewer variables, or performing some filtering on the device to
drop insignificant data. If you aggregate the data before you transmit it, you help to reduce the volume of
data to be transmitted, but then this process has implications on flexibility and granularity in the upstream
analysis. Aggregation and bursting is not always suitable for time-sensitive or latency-sensitive data either.
All of these techniques also increase the data processing and storage requirements for the IoT device.

Power usage
Transmitting data from a device consumes power, and transmitting data over long ranges requires more
power than over a short range. You must consider the devices that operate on a battery to conserve power to
prolong the life of the battery and reduce operating costs. To prolong the battery life, you can put the device
into sleep mode whenever it is idle. It is a good idea to model the energy consumption of the device under
different loads and different network conditions to ensure that the device's power supply and storage
capacity matches with the power that is required to transmit the necessary data by using the networking
technologies that you adopted.

Intermittent connectivity
IoT devices aren't always connected. In some cases, devices will connect periodically by design in order
to save power or bandwidth. However, sometimes an unreliable network might cause
devices to drop off due to connectivity issues. Sometimes quality of service issues, such as dealing with
interference or channel contention on a wireless network using a shared spectrum.

Interoperability
With so many different devices connecting to the IoT, interoperability can be a challenge. Adopting
18 | P a g e
standard protocols has been the traditional approach for maintaining interoperability on the internet.
However, for the IoT, standardization processes sometimes struggle to keep up with the rapid pace of
change and technologies are released based on upcoming versions of standards that are still subject to
change. In these cases, consider the ecosystem around the technologies; that is, ask these questions: Are
they widely adopted? Are they open versus proprietary? How many implementations are available?

Security

Security is always a priority, so be sure to select networking technologies that implement end-to- end
security, including authentication, encryption, and open port protection. For example, IEEE
802.15.4 includes a security model that provides security features that include access control,
message integrity, message confidentiality, and replay protection, which are implemented by
technologies based on this standard such as ZigBee.

• Authentication
Adopt secure protocols to support authentication at the device level, for gateways, users, and
applications and services. For example, consider adopting the X.509 standard for device
authentication.
• Encryption
If you are using wifi, you can use Wireless Protected Access 2 (WPA2) for wireless network
encryption or you might adopt a Private Pre-Shared Key (PPSK) approach. To ensure privacy
and data integrity for communication between applications, be sure to adopt TLS
or Datagram Transport-Layer Security (DTLS), which is based on TLS, but adapted for
unreliable connections that run over UDP. TLS encrypts application data and ensures its
integrity.
• Port protection
Port protection ensures that only the ports that are required for communication with the gateway or
upstream applications or services remain open to external connections. All other ports should be
disabled or protected by firewalls. For example, device ports might be
exposed when exploiting Universal Plug and Play (UPnP) vulnerabilities, so UPnP should be
disabled on the router.

Conclusion

Selecting the IoT networking technologies to adopt involves compromise, across the board. Your choice of
networking technologies will have an impact on the design of your IoT devices, and there are dependencies
among most of the considerations that I discussed in this article. For example, network range, data rate, and
power consumption are all directly related. If you increase the network range or rate and volume of data that
is transmitted, your IoT devices will almost certainly require additional power to transmit the data under
those conditions

19 | P a g e
Physical Layer Data Protocols

IoT mainly consists of Sensors and Actuators, People, Communication protocols, Cloud and Analytics. So,
in this section, we’ll discuss different Communication protocols used in IoT.
We will now start our discussion by answering three basic questions: What is the protocol? What do you
mean by communication? And what are the protocols associated with the communication?
• Protocol: A set of rules and regulations.
• Communication: Exchange of information from one system to another system with a medium.
• Communication Protocol: A set of rules and regulations that allow two electronic devices to connect
to exchange the data with one another.

There are two types of communication


• Wired Communication
• Wireless Communication
We’ll discuss the wired communication protocols in the next unit.

Overview on Electronic Communication Protocols

Introduction:

• Protocol: A set of rules and regulations is called a protocol.


• Communication: Exchange of information from one system to another system with a medium is called a
communication.
• Communication Protocol: A set of rules and regulations that allow two electronic devices to connect to
exchange the data with one and another.

Types of Electronic Communication Protocols:


There are two types of communication protocols which are classified below:
1. Inter System Protocol
2. Intra System Protocol

1. Inter System Protocol: The inter system protocol using to communicate the two different devices. Like
communication between computer to microcontroller kit. The communication is done through a inter bus
system.

Inter System Protocol by Edgefx Kits


Different categories of Inter system protocol:

• UART Protocol
• USART Protocol
• USB Protocol

2. Intra System Protocol: The Intra system protocol is used to communicate the two devices within the
circuit board. While using this intra system protocols, without going to intra system protocols we will
expand the peripherals of the microcontroller. The circuit complexity and power consumption will be
increases by using intra system protocol. Using intra system protocols circuit complexity and power
consumption, cost is decrease and it is very secure to accessing the data.

Intra System protocol by Edgefx Kits

Different categories of Intra system protocol

• I2C Protocol
• SPI Protocol
• CAN Protocol

UART Protocol:
UART stands for universal asynchronous transmitter and receiver. UART Protocols is a serial
communication with two wired protocol. The data cable signal lines are labelled as Rx and Tx. Serial
communication is commonly used for transmitting and receiving the signal. It is transfer and receives the
data serially bit by bit without class pulses. The UART take bytes of data and send the individual bits in
sequential manner. UART is a half-duplex protocol. Half duplex means transferring and receiving the data
but not at a same time. Most of the controllers have hardware UART on board. It uses a single data line for
transmitting and receiving the data. It has one start bit, 8-bit data and one stop bit mean the 8-bit data
transfer one’s signal is high to low.
Ex: Emails, SMS, Walkie-talkie.

UART Protocol Data Flow


USART Protocol:

USART stands for universal synchronous and asynchronous transmitter and receiver. It is a serial
communication of two wire protocol. The data cable signal lines are labelled as Rx and TX. This protocol is
used to transmitting and receiving the data byte by byte along with the clock pulses. It is a full-duplex
protocol means transmitting and receiving data simultaneously to different board rates. Different devices
communicate with microcontroller to this protocol.

Ex: -Telecommunications.

USART Protocol Data Flow

USB Protocol:

USB stands for universal serial bus. Again, it is a serial communication of two wire protocol. The data cable
signal lines are labelled D+ and D-. This protocol is used to communicate with the system peripherals. USB
protocol is used to send and receive the data serially to the host and peripheral devices. USB communication
requires a driver software which is based on the functionality of the system. USB device can transfer data on
the bus without any request on the host computer. Now a day’s most of the devices are using this technique
for communicating with USB protocol. Like computer to communicate with ARM controller using USB.
USB transfer the data different modes. first one is slow speed mode 10kbps to 100 kbps; second one is full
speed mode 500kbps to 10mbps, high speed mode 25mbps to 400 mbps USB maximum cable length of 4
meters.

Ex: Mouse, Keyboard, Hubs, switches, pen drive.

USB Protocol Communication

22 | P a g e
Differences Between the Inter System Protocols:

I2C Protocol:

I2C stands for inter integrated circuit. I2C requires only two wires connecting all peripherals to
microcontroller.I2C requires two wires SDA (serial data line) and SCL (serial clock line) to carry
information between devices. It is a master to slave communication protocol. Each slave has a unique
address. Master device sends the address of the target slave device and read/write flag. The address is
matching any slave device that device is ON, remaining slave devices are disable mode. Once the address is
match communication proceed between master and that slave device and transmitting and receiving the data.
The transmitter sends 8-bit data, the receiver replies 1-bit of acknowledgement. When the communication is
completed master issues the stop condition. The I2C bus was developed by Philips Semiconductors. Its
original purpose is providing an easy way to connect CPU to peripherals chips. Peripheral devices in
embedded systems are often connected to the microcontroller as memory mapped devices. I2C requires only
two wires for connecting all the peripherals to the microcontroller. These active wires, called SDA and SCL,
are both bidirectional. SDA line is a serial data line and SCA line is a serial clock line.

I2C protocol data flow

23 | P a g e
I2C Pull-up Resistors:

Why given the pull-up resisters in I2C SCL and SDA line?

• Both SDA and SCL lines are open drain drivers.


• It’s can be drive output low cannot driver it high.
• For the lines to be able to go high you must provide pull-up resistors

SPI Protocol:

SPI stands for serial peripheral interface. It is one of the serial communication protocols developed by
Motorola. Sometimes SPI protocol is also called a 4-wire protocol. It requires four wires MOSI, MISO, SS,
and SCLK.SPI protocol used to communicate the master and slave devices. The master first configures the
clock using a frequency. The master then selects the particular slave device for communication by pulling
the chip select button. That particular device is selected and starts the communication between master and
that particular slave. The master selects only one slave at a time. It is full duplex communication protocol.
Not limited to 8-bit words in the case of bit transferring.

SPI protocol data flow

CAN Protocol:

CAN stands for controller area network. It is a serial communication protocol. It requires two wires CAN
High (H+) and CAN low (H-). It was developed by the Robert bosh company in 1985 for in vehicle
networks. It is based on a message-oriented transmission protocol.

24 | P a g e
Differences Between the Inter System Protocols:

The wired communication is divided into two categories:

INTERNAL SYSTEM PROTOCOLS

EXTERNAL SYSTEM PROTOCOLS

The Internal system protocol is used to communicate between two devices within the circuit board. This
category of protocols is majorly used for the peripherals present inside micro-controllers and devices
similar to it.

Different categories of protocols in Inter system protocols are:


• SPI Protocol
• I2C Protocol
SPI:

• The Serial Peripheral Interface bus (SPI) is a synchronous serial communication specifically used for
short distance communication, primarily in embedded systems. Sometimes SPI protocol is also called a 4-
wire protocol. It requires four wires MOSI, MISO, SS, and SCLK. SPI protocol used to communicate the
master and slave devices.
• Applications for this type of communications are Secure Digital cards and liquid crystal displays.

25 | P a g e
The master selects only one slave at a time. It is a full-duplex communication protocol.

Advantages and Disadvantages of SPI:


Advantages:
• It’s faster than asynchronous serial communication
• The receiving hardware can be a simple shift register
• It supports multiple slaves
Disadvantages:
• It requires more signal lines (wires) than other communications methods
• The communications must be well-defined in advance.
• The master must control all communications (slaves can’t talk directly to each other)
I2C
• I2C, therefore, stands for “Inter-integrated circuit” connections.
• I2C is one of the most popular protocols used in industry for many purposes. Here we will see the
technical details of this protocol with its advantages and disadvantages.

• It is a master-slave communication protocol.


• It can also be used as a multi-master protocol (meaning there may be more than one master
present in this types of communication).
• In I2C devices processors, EEPROMs, sensors, real-time clocks are used as a control interface.
26 | P a g e
• There are 3 types of I2C based on speed: Slow (under 100 Kbps), Fast (400 Kbps), High-speed
(3.4 Mbps).

There are two wire lines: Serial Data (SDA) and Serial Clock (SCL).
Advantages and Disadvantages of I2C:
Advantages:
• Occasional communication of devices is easy to implement
• I2C requires only two wires connecting all peripherals to a microcontroller
• Addressing scheme allows multiple devices
• Interconnection without additional wires
Disadvantages:
• Hardware and especially software implementation are more complicated than the SPI Half-duplex.
• Not scalable for a large number of devices.
Differences Between the Internal System Protocols:

The external system protocol is used to communicate between two different devices, like communication
happening between a computer to microcontroller kit.

27 | P a g e
For e.g. when plugging in your pen drive into the computer.
or, connecting Arduino with a computer.
The protocols which are there for this communication are:
• Ethernet
• UART Protocol
• USART Protocol

Ethernet:
Ethernet is a type of connection between computers forming Local Area Networks (LAN). It also serves
as one of the main methods for connecting a computer or network to an Internet hub. Ethernet cables that
connect to a central hub or router in order to network several computers together.
A system for connecting a number of computer systems to form a local area network, with protocols to
control the passing of information and to avoid simultaneous transmission by two or more systems.

Advantages and Disadvantages of Ethernet:


Advantages:
• Network start with it and end with it.
• Reliable and can be used within a building, doesn’t matter
how many floors.
• It will be needed to switch to keep the network.
• It is basically used for making LAN.
Disadvantages:
• Can’t be used for long distance network. copper or Fibre will help here.
• In a building network, you have to connect Ethernet to switch and then Ethernet again which makes
such network, a hell (with the presence of a lot of cables) which is very irritating and tough to
manage.

Application of Ethernet:
• Cloud Computing
• Site to Site Access
• Video Applications
• Distributed Storage Area Networks
• CCTV
• Copper cable
• Fibre optic cable

Before we going to learn the Difference between UART and USART, we would discuss it one by one
term used by UART and USART. As we all know, the full name of UART and USART is Universal
Asynchronous
28 | P a g e
Receiver Transmitter & Universal Synchronous-Asynchronous Receiver Transmitter respectively
which includes main two words called Synchronous and Asynchronous. So, these two words is the
main philosophy used in serial communication.

Let us discuss it first

UART:
A Universal Asynchronous Receiver/Transmitter. It is a microcontroller peripheral that converts
incoming and outgoing bytes of data into a serial bit stream. A start bit initiates the serial bit stream and a
stop bit (or two) completes the data word. A UART also has the option of adding a parity bit to the stream
to assist in detecting if a bit error occurs during transmission. The provided figure shows a standard
example of what an engineer would expect to see from data transmitted through a UART.

Figure – UART Serial Data

UART adds start and stops bits to the data packet being transferred. These bits define the beginning and
end of the data packet to the receiving UART knows when to start reading the bits. When the receiving
UART detects a start bit, it starts to read the incoming bits at a specific frequency known as the baud
rate. Baud rate is a measure of the speed of data transfer, expressed in bits per second (bps).

Advantages and Disadvantages of UART:


Advantages:
• Single wire.
• Easy interface to PCs.
• The range of standard physical interfaces (TTL, RS232, RS422, RS485).
Disadvantages:
• Needs reasonable clock accuracy both ends.
• Max data rate in practice about 1mbit/sec (typically limited by UART capabilities).

Application of UART:

• Transmitting and receiving UARTs must be set for the same bit speed, character length, parity, and
stop bits for proper operation.
• Very low-cost home computers or embedded systems dispense with a UART and use the CPU to
sample the state of an input port or directly manipulate an output port for data transmission.
• Typical serial ports used with personal computers connected to modems use eight data bits.
USART
A Universal Synchronous/Asynchronous Receiver/Transmitter is
a microcontroller peripheral that converts incoming and outgoing
bytes of data into a serial bit stream.
Hmm. The definition of a USART is identical to that of a UART,
but with “synchronous” added to the term.

The two-way communication as shown in the figure.


Surely there are some more meaningful differences? Otherwise, a USART would just be known as a UART.
Well, there are differences – important ones. The first difference between a USART and a UART is the
way in which the serial data may be clocked. A UART generates its data clock internally to the
microcontroller and synchronizes that clock with the data stream by using the start bit transition. There is
no incoming clock signal that is associated with the data, so in order to properly receive the data stream,
the receiver needs to know ahead of time what the baud rate should be.
A USART, on the other hand, can be set up to run in synchronous mode. In this mode, the sending
peripheral will generate a clock that the receiving peripheral can recover from the data stream without
knowing the baud rate ahead of time. Alternatively, the link will use a completely separate line to carry the
clock signal. The use of the external clock allows the data rate of the USART to be much higher than that of
a standard UART, reaching up to rates of 4 Mbps.
Are USARTs and UARTs the same?
Technically the answer is no. A USART generally has more capabilities than a
standard UART and the ability to generate clocked data allows the USART to
operate at baud rates well beyond a UART’s capabilities. A USART does
encompass the capabilities of a UART, though, and in many applications, despite
having the power of a USART, developers use them as simple UARTs, ignoring
or avoiding the synchronous clock generation capability of these powerful
peripherals. No wonder so many people use the terms as though they were
synonyms.
USB:
It is a representative peripheral interface. USB stands for Universal Serial Bus. It
provides a serial bus standard for connecting devices, usually to a computer, but it also is in use on other
devices such as set-top boxes, game consoles, and PDAs.
USB Standard:
• USB 1.0 specification introduced in 1994
• USB 2.0 specification finalized in 2001: Became popular due to cost/benefit advantage.eg. IEEE
1394
— high bandwidth, high cost
• Three generations of USB: USB 1.0, USB 2.0, USB 3.0
Advantages and Disadvantages of USB:
Advantages:
• Flash drives use little power, have no fragile moving parts,
and for most capacities are small and light.
• Data stored on flash drives is impervious to mechanical shock,
magnetic fields, scratches, and dust.
Disadvantages:

30 | P a g e
• Flash drives can sustain only a limited number of write and erase cycles before the drive fails.
• A drawback to the small size is that they are easily misplaced, left behind, or otherwise lost.

Below Image differentiates between UART, CAN, and USB.

31 | P a g e
What is an IoT Platform?

Whether you’re new to IoT or a seasoned veteran, you’ve probably heard the term “IoT Platform” before.
After all, there were over 300 IoT platforms as of last year and this number continues to quickly grow (I’ve
heard there are now over 700). The IoT platform market is growing at a compound annual growth rate
(CAGR) of 33% and is expected to reach a $1.6 billion market size in 2021.
IoT platforms are a critical component of the IoT ecosystem, but I’ve found that for many people,
it’s not clear what an IoT platform is exactly or the differences between them.
In this post I’ll provide a simple, non- technical explanation of IoT platforms. What they are, when
businesses should use them, and the important considerations when choosing between the multitude of
options.

So, what is an IoT Platform exactly?


To understand what an IoT platform is, first you need to understand a little about the components of a
complete IoT system. My previous post, How Does an IoT System Actually Work? It is a great way to
learn, but I’ll quickly summarize here.

1. A complete IoT system needs hardware, such as sensors or devices. These sensors and
devices collect data from the environment (e.g. a moisture sensor) or perform actions in the
environment (e.g. watering crops).
2. A complete IoT system needs connectivity. The hardware needs a way to transmit all that data
to the cloud (e.g. sending moisture data) or needs a way to receive commands from the cloud
(e.g. water the crops now). For some IoT systems, there can be an intermediate step between
hardware and connecting to the cloud, such as a gateway or router.
3. A complete IoT system needs software. This software is hosted in the cloud (what’s the
cloud?) and is responsible for analysing the data it’s collecting from the sensors and making
decisions (e.g. knowing from moisture data that it just rained and then telling the irrigation
system not to turn on today).
4. Finally, a complete IoT system needs a user interface. To make all of this useful, there needs
to be a way for users to interact with the IoT system (e.g. a web app with a dashboard that shows
moisture trends and allows users to manually turn irrigation systems on or off).

IoT platforms are the support software that connects everything in an IoT system. An IoT
platform facilitates communication, data flow, device management, and the functionality of
applications.
IoT platforms exist in part 3 and, often, part 4 of what’s described above. With all the varying kinds of
hardware and the different connectivity options, there needs to be a way of making everything work
together and that’s what IoT platforms do.

IoT platforms help:

• Connect hardware
• Handle different communication protocols
• Provide security and authentication for devices and users
• Collect, visualize, and analyse data
• Integrate with other web services

32 | P a g e
When Should Your Business Use an IoT Platform?
• Because IoT is a system of systems, rare is the organization that has expertise across all the
relevant domains. IoT platforms exist to help businesses overcome technical challenges without
the need to figure it all out in-house.

For example, your business might be really good at building hardware and decide that you want to make
your hardware “smart”. Instead of the expensive and time-intensive process of hiring software
developers to build everything in-house, you can instead use an IoT platform to get up and running
quickly and more cost-effectively.

However, there is a trade-off. IoT platforms that save you time may cost more in the long run depending on
how they’re priced. This is because they charge use-based and/or subscription fees that can add up over
time. But you still get the benefit of significantly lower up-front costs (no CapEx).
IoT platforms that are inexpensive up front will likely cost you time. This comes back to the same point in
bold above, the less you spend the more work you’ll have to do on your own, which takes time.
IoT Platform:
IoT (Internet of Things) is nothing but the ecosystem of physical object that can be connect to the internet
and we can access as well as control it remotely anytime anywhere.
Internet of Things platform is the support software which connect the hardware, access point and data
network to the end user application. IoT platform handle or manage the task and data visualization that
allow the user automate the environment.
IoT platform ensures the seamless integration with the different hardware by using a range of popular
communication protocols and also apply the different types of topology using SDK.
IoT platform also referred as a middleware which is act as mediator between hardware and the
application layer.

IoT-platform is an application that connect


IoT with the cloud and output devices
corresponds to it.
The Components of IoT platform
as follows:

Hardware: Hardware is nothing but the


microcontroller with wireless connectivity
with hold the application.

Hub Level: Hub level is the software which facilitates the connection with the cloud Hub Level is nothing
but the bridge between IP connected cloud and IP non connected cloud.

Cloud Level: The cloud is that part where the data is sent from devices and it should be formatted for
output. It is also used for remotely manage the devices and remove software updates.

Third party Application:


In Third party application output should be send. These can be a mobile app or internal system amongst
other things.
The IoT platform ensures the communication between devices, output work i.e. collection of data and
formatted in correct way, functions like as remote updates and access facilitated.
There are also other components like as security features, connectivity choice i.e.
WIFI, Bluetooth, Zigbee etc.

33 | P a g e
image credit: Smart-Industry

IoT Platform Key Components or Functional Requirements:


As we all know IoT allows us to connect or communicate and also manage the various things. An
effective IoT platform gives the inter-connectivity in a seamless way by acting as the link between
machines, applications, devices and people.
All IoT platform work in similar ways. There are various capabilities, levels and features available such
type of the variation in platform is depends upon the unique objectives of the organizations and also their
end users. This organization take care of key components of Internet of Things platform.

IoT Security:
security is one the most important factor while selecting the IoT platform. For data security we have to
authenticate all connected devices and the application with end-to-end security mechanism. It ensures that
the organization and end users are protected from unauthorized access.
Enterprises look for the platform that features end-to-end data encryption so that data is protected. IoT
platform should deliver regular security updates and demonstrate a commitment to ensuring that consumers
fully understand their IoT security architecture.

Real-time Analytics:
when an internet of things platform features real time analytics it contextualizes as well as visualizes data
as it flows through the system. This enables organization to effectively monitors their devices, understand
the performance, usage pattern and also availability and proactively identify privacy issues and insecure
conditions. In other words, real-time analytics give the consumer the power to manage devices and ensures
both security and performance as efficiently as possible.

Horizontal Management:
Enterprises and municipalities often work with several agencies that may all be working in isolation and
only focusing on their own needs. This can create a fragmented and inefficient model for operation and
development with each vertical creating their own custom solution. A horizontal management IoT platform
allows organization to cover connectivity data collection, analytics, business application development and
service management.

34 | P a g e
Whatever We Can Do with IoT Platform:

An IoT platform plays important role for smart devices. Users can use their product with remote control and
real time monitoring function, configurable alerts or notification, pluggable cloud services and integration
with consumer’s smartphones or other devices.

IoT platform is cost optimization for companies in the industrial sector through remote monitoring of
devices and vehicles, collecting the sensor data for real time, ensuring safety and end-to end delivery
tracking.

By using IoT platform used to develop IoT infrastructure for delivering all types of the services for
customers. Among them Car service, smart building smart metering and others.

IoT platform is most essential technology for improving the customer experience in different field
like retail, healthcare , hospitality and travelling. It ensures the stress-free interaction between
customer and the company.

35 | P a g e
IoT using PaaS Cloud

36 | P a g e
What is Ubidots?

A mix of backend and frontend ingredients designed to accelerate IoT deployment.

Ubidots (ubidots.com) is an IoT Application Development Platform that automates the process of IoT
application creation for enterprises and individuals to deploy any IoT solution to scale, and do so quickly.
Ubidots platform is a user-focused point-and-click IoT App builder with data analytics and cloud
function tools, dashboard visualizations, device management tools, BI events and alarm engine, and end-
user authentication/access to give end-users and operators the data they need and nothing more. With the
Ubidots platform, users collect, enhance, and deliver sensor, actuator, and beacon data that matters for
businesses and users to make data-driven decisions that improve efficiency and effectiveness.

Ubidots IoT Application Enablement...

Friendly APIs =
and Time-Series
Device
Managem Communication Architecture
ent
Protocols

User Custom Point-and-Click


Managemen
t Branding Dashboard
Development

End-user Application

37 | P a g e
Ubidots Basics: Devices, Variables, Dashboards, and Alerts

The basics components of any Internet of Things application powered by Ubidots


are: Devices, Variables, Synthetic Variables Engine, Dashboards, and Events. Within this article we
will address each of these concepts as they relate to Ubidots IoT Development and Deployment Platform
and how you can better organize your Ubidots Apps to best connect with the users.

Once your devices, variables, and general Application is assembled, give your App some layers with
Ubidots Device Management to learn more about Ubidots internal architecture and how you can use Apps,
Organizations, and Users to efficiently connect your data with those who should be using it.

Table of Contents

1. Devices
2. Variables
3. Dashboard and Visualizations
4. Events.

1. Devices

A Ubidots' device is a virtual representation of a data-source or simply, an asset taking sensor data and
transmitting said data through a connection protocol to Ubidots' cloud.

All devices are different, but the standard setup on any device entails:

• A library that should be installed in the device's IDE. (not always required)
• Filling parameters for authentication and connection such as a TOKEN (i.e. the unique ID for
each account or user), device and variable labels (i.e. devices and variables unique identifiers in
Ubidots), Wi-Fi SSID and Password, depending on the device and the requirements.
• Making API request (i.e. a call from a device to the web server). Ubidots’ libraries spare the need to
manually make these requests. However, if you’re working with a device not currently in the list
of supported hardware, you can choose a connectivity protocol such as MQTT or HTTP and make
a request using the API accordingly.

Creating devices: there are three ways to create devices:

1. Devices are created automatically in Ubidots the first time a dot is received to a user's private
TOKEN or an Organizational TOKEN.
2. Clicking the "+" icon in the top right corner of any single device's screen.

38 | P a g e
2. Variables

Once a device is created and receiving data from your hardware or another 3rd party data-source, the data
will be presented in its raw or calculated form as a variable.

Types of Variables:

– Default - raw data coming from devices (people counted).

– Derived - correspond to statistical or arithmetical operations of default variables.

– Rolling Window – corresponds to Time/loop based mathematical operations such as sum, Average,
Minimum, maximum, count etc. based on a trigger point attached to it such as in mentioned
minutes/hours/days

Creating variables: there are two ways to create variables.

1. Assigning a label as a variable within your hardware's code.


2. Clicking the "+" icon found in any single device screen and assign a name which will also
correspond to the variable's label. By default, Ubidots assigns an additional unique identifier to
the variable called Variable ID. To find both the variable's ID and variable's label, select the "i"
icon form the variables card.

Note that default variables are yellow, and Derived & Rolling window Variables are green.

39 | P a g e
3. Dashboards and Visualizations

Historical Switch Line Chart Multi Map Gauge

Slider Metric Table Indicator Subcat

Dashboards are the human-machine interfaces where data is easily visualized. Your Ubidots account will let
you create as many dashboards as needed, containing widgets and data-visualizations to comprehend your
data at a glance.

Dashboards (static and dynamic) are user interfaces to organize and present a device's data and the
insights derived from the data. Dashboards contain widgets that display the data as charts, indicators,
controls, tables, graphs, and other size, shapes, and forms.

With Ubidots, you can create Static and Dynamic dashboards.

• Static Dashboards are used to visualize data from predetermined devices and variables. Static
dashboards display the same device and variable data at all times.
• Dynamic Dashboards utilize a primary and replica (master/slave) technology to visualize data from
different devices and variables, using a dropdown menu in the settings bar. By selecting different
devices from the settings bar, a dynamic dashboard will refresh with the underlying device and
variables populating each widget's visualization according to the device selected.

Table of Contents

A. Explaining Dynamic Dashboards


B. Explaining Static and Dynamic Widgets

40 | P a g e
A. Explaining Dynamic Dashboards

When a device is selected from the setting bar, then all variables within each widget will automatically
update to reflect the device’s variables. This is achieved because dynamic dashboard widgets are not
associated with predetermined variables; instead, they are associated with variable labels (i.e.
label=temperature).

This is very helpful enablement as it erases the need to create additional dashboard per device. Image you
have a fleet of 1,000 trucks; with static dashboards you’d have to create 1,000 dashboards. With dynamic
dashboards, you only have to create one dashboard, and then have the App's Users select the device for
which they want to see the data:

B. Explaining Static and Dynamic Widgets

Ubidots allows you to combine static and dynamic widgets at will. Using our Truck Application
example, imagine you have a variable with the aggregated fuel consumption across all thousand trucks.
You want this variable to be displayed in every truck’s dynamic dashboard, regardless of the selected
truck. In this case you would create a static widget pointing to a preset variable.

To better understand the difference between static and dynamic, here’s a table explaining how a widget
behaves when created within a static or dynamic dashboard:

41 | P a g e
4. Events

In Ubidots, Events are messages triggered and delivered through Email, SMS, Telegrams, Slack, Voice Call
or webhook messages based on a customized design rule created in the application.

3 Event types:

• When sensor readings reach a specific value:

• Variable is inactive during a specific amount of time:

• When a device enters or exits a specific area (geofence):

You can also determine the format of alerts by choosing between emails, SMS, Telegrams or Webhook.

42 | P a g e
Deep dive to Devices in Ubidots

Learn to provision, create, and edit Devices in Ubidots IoT Application Development Platform.

Table of Contents:

1. What is a Device?
2. Device Setup and Activation
3. Creating Devices
4. Editing Devices
5. Deleting Devices
6. Reset a Device's Data

1. What is a Device?

A Device in Ubidots is a virtual representation of a data- source or simply, an asset taking in sensor data and
transmitting said data through a connection protocol to Ubidots' cloud. For billing purposes, a Device in
Ubidots is counted as a collection of 20 variables. Moving from that limit forward, a device then is counted
based on the number of variables as multiple of 20:

– 1 to 20 variables: 1 device.
– 21 to 40 variables: 2 devices.
– 41 to 60 variables: 3 devices, And so on...

2. Device Setup and Activation

All Devices are different, but the standard setup for any device entails the same characteristics when
connecting to Ubidots:

• A library that should be installed in the device's IDE. (not required)


• A webhook or function should be used to communicate with 3rd party hardware clouds or platforms.
• Filling parameters for authentication and connection such as a TOKEN (i.e. the unique ID for each
account or user), device label, variable label (i.e. devices and variables identifiers or names in
Ubidots), Wi-Fi SSID, or Wi-Fi password, depending on the device and requirements.
• Making API request (i.e a call from a device to the web server). Ubidots’ libraries spare the need to
manually make these requests. However, if you’re working with a device not currently in the list
of supported hardware, you can choose a connectivity protocol such as MQTT or HTTP and make
a request using API accordingly.

3. Creating Devices

Creating devices can be done in three ways:

1. Devices are created automatically in Ubidots the first time a dot is received to a user's private
TOKEN or using an Organizational TOKEN.
2. Clicking the "+" icon in the top right corner of the Device's section of your account.
3. Creating a Device Type which then creates a new device with pre-determined device
properties, appearance, and variables and automate the on-boarding of thousands of
devices.

43 | P a g e
4. Editing Devices

Devices can easily be edited directly from the User Interface. Simply click to
open the device you need to edit and then using the Device detail pane
located on the left-hand side of your Ubidots display correct any information
as needed.

6. Delete Devices

Go to and hover the device you want to delete. You will see two icons in the
bottom right: one for assigning this device to an organization, the second, a
"trashcan" icon for deleting a device. If you wish to delete the device, select
the trashcan and confirm.

44 | P a g e
7. Reset a Device's Data

From any Device you can easily clear all gathered data without having to recreate the device. To clear all
data from a Device, simply open the device you need to reset and click the "reload" icon located in the
main control bar to remove any recorded data and reset the device's data.

45 | P a g e
Hands-on: Connect a NodeMCU ESP8266 to Ubidots over MQTT
Learn to connect the NodeMCU ESP8266 to Ubidots
Application Development Platform over MQTT

The NodeMCU Development Kit is based on the ESP8266,


and integrates GPIO, PWM, IIC, 1-Wire and ADC into one
board.

By following this guide, you will be able


to PUBLISH and SUBSCRIBE data to/from Ubidots using
the NodeMCU ESP8266 module in just a couple of
minutes!

Requirements

• NodeMCU version 1.0


• Arduino IDE 1.8.2or higher
• ubidotsMQTTESP library
• PubSubClient Library

Step-By-Step

1. Setting up the Arduino IDE


2. Sending (PUBLISH) Data to Ubidots
3. Receiving (SUBSCRIBE) Data from Ubidots
4. Summary

1. Setting up the Arduino IDE

1. To be able to work with the NodeMCU ESP8266 platform in the Arduino IDE, you will need to install
the ESP8266 platform using the preconfigured Arduino Board Manager.

2. With the ESP8266 platform installed, select the ESP8266 device you are working with. In the case, we
are working with a “NodeMCU 1.0(ESP12E module)”. To select your board from the Arduino IDE, select
Tools > Board “NodeMCU 1.0(ESP12E module)”.

3. Download and install the UbidotsMQTTESP8266 library.

4. Download and install the PubSubClient library.

46 | P a g e
2. Sending (PUBLISH) Data to Ubidots

With the following sample code you will be able to post the readings taken from ANALOG pin A0 of
the NodeMCU ESP8266.

1. To publish your first value in Ubidots, open the Arduino IDE and paste the sample code below. Once
you have pasted the code, you will need to assign your uniqueUbidots TOKEN, SSID (WiFi
Name) and Password of the available network.

/****************************************
* Include Libraries
****************************************/
#include "UbidotsESPMQTT.h"

/****************************************
* Define Constants
****************************************/
TOK
#define TOKEN "..... " // Your Ubidots EN
#define WIFINAME ".... " //Your SSID
#define WIFIPASS "..... " // Your Wifi Pass
Ubidots client(TOKEN);

/****************************************
* Auxiliar Functions
****************************************/

void callback(char* topic, byte* payload, unsigned int length) {


Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i=0;i<length;i++) {
Serial.print((char)payload[i]);
}
Serial.println();
}

/****************************************
* Main Functions
****************************************/

void setup() {
/ put your setup code here, to run once: //client.ubidotsSetBroker("business.api.ubidots.com"); //
Sets the broker properly for the
business account
client.setDebug(true); // Pass a true or false bool value to activate debug messages
Serial.begin(115200);
client.wifiConnection(WIFINAME, WIFIPASS);
client.begin(callback);
}

void loop() {
/ put your main code here, to run repeatedly: if(!
client.connected()){
client.reconnect();
}

float value1 = analogRead(A0);


client.add("temperature", value1);
client.ubidotsPublish("my-new-device");
client.loop();
}

47 | P a g e
2. Verify your code within the Arduino IDE. To do this, in the top left corner of our Arduino IDE you will
see the "Check Mark" icon; press it to verify your code.

3. Upload the code into your “NodeMCU 1.0(ESP12E module)”. To do this, choose the "right-arrow"
icon beside the "check mark" icon.

4. To verify the connectivity of the device and the data sent, open the serial monitorby selecting
the "magnifying glass" icon in the top right corner of the Arduino IDE to see the connectivity logs.

NOTE: If no response is seen, try unplugging the NodeMCU and then plugging it again. Make sure the
baud rate of the Serial monitor is set to the same one specified in your code 115200.

5. Confirm your data in Ubidots. Now you should see the posted data in your Ubidots account, located
the device called "my-new-device".

NOTE: To change the name ID of the device being updated in Ubidots, replace the string assigned in
code with the following line:

client.ubidotsPublish("my-new-device");

3. Receiving (SUBSCRIBE) Data from Ubidots

With the following sample code you will be able to subscribe a value from Ubidots to start controlling
any asset you desire.

1. To begin receiving values from Ubidots, open the Arduino IDE and paste the sample code below. Once
you have pasted the code, be sure to assign the following parameters:

• SSID (WiFi Name) & Password of the available network connection.


• Ubidots TOKEN
• Device Label of the device which contains the variable to want to GET.
• Variable Label of the variable you want to GET

/****************************************
* Include Libraries
****************************************/
#include "UbidotsESPMQTT.h"

/****************************************
* Define Constants
****************************************/
TOK
#define TOKEN "..... " // Your Ubidots EN
#define WIFINAME "..... " //Your SSID
#define WIFIPASS "..... " // Your Wifi Pass
#define DEVICE_LABEL "..." // Put here your Ubidots device label #define
VARIABLE_LABEL "..." // Put here your Ubidots variable label

Ubidots client(TOKEN);

/****************************************
* Auxiliar Functions
****************************************/

void callback(char* topic, byte* payload, unsigned int length) {


Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");

48 | P a g e
for (int i=0;i<length;i++) {
Serial.print((char)payload[i]);
}
Serial.println();
}

/****************************************
* Main Functions
****************************************/

void setup() {
/ put your setup code here, to run once: client.ubidotsSetBroker("business.api.ubidots.com"); //
Sets the broker properly for the
business account
client.setDebug(false); // Pass a true or false bool value to activate debug messages
Serial.begin(115200);
client.wifiConnection(WIFINAME, WIFIPASS);
client.begin(callback);
client.ubidotsSubscribe(DEVICE_LABEL, VARIABLE_LABEL); //Insert the dataSource and Variable's
Labels
}

void loop() {
/ put your main code here, to run repeatedly: if(!
client.connected()){
client.reconnect();
client.ubidotsSubscribe(DEVICE_LABEL, VARIABLE_LABEL); //Insert the dataSource and
Variable's Labels
}
client.loop();
}

2. Verify & Upload the code into the board following the same steps provided in the PUBLISH step above.

3. To verify the connectivity of the device and the data which is being received, open the serial monitor by
selecting the "magnifying glass" icon in the top right corner of the Arduino IDE to see the connectivity logs.

NOTE: If no response is seen, try unplugging the NodeMCU ESP8266 and then plugging it again. Make
sure the baud rate of the Serial monitor is set to the same one specified in your code 115200.

4. In the serial monitor, you will be able to see the last value received in Ubidots of the variable specified
in the firmware.

4. Summary

With this simple tutorial you are able to PUBLISH & SUBSCRIBE data to/from Ubidots with the ease
of the Arduino IDE and a NodeMCU ESP8266. If your wish to find more examples to handle context or
timestamp values in your request
49 | P a g e
Hands-on: Connect a NodeMCU ESP8266 to Ubidots
over HTTP

Learn to connect the NodeMCU ESP8266 to Ubidots


Application Development Platform over HTTP

The Development Kit based on ESP8266, integrates GPIO, PWM,


IIC, 1-Wire and ADC all in one board. Power your development
in the fastest way by combining with NodeMCU Firmware!

By following this guide, you will be able to POST data to Ubidots using the NodeMCU ESP8266
module in just a couple of minutes!

Requirements

• NodeMCU version 1.0


• Arduino IDE 1 .6.5 or higher
• UbidotsMicroESP8266 library
Step-by-Step

1. Setting up Arduino IDE


2. Sending (POST) Data to Ubidots
3. Summary

1. Setting up Arduino IDE

1. To be able to work with the NodeMCU ESP8266 platform in the Arduino IDE, you will need to
install the ESP8266 platform using the preconfigured Arduino Board Manager.

2. With the ESP8266 platform installed, select the ESP8266 device you are working with. In the case, we
are working with a “NodeMCU 1.0(ESP12E module)”. To select your board from the Arduino IDE,
select Tools > Board “NodeMCU 1.0(ESP12E module)”.

3. Download and install the UbidotsMicroESP8266.

Note: The library will create a new Ubidots device named "ESP8266" receiving the mac address of the
ESP8266 as the unique device label. If you desire assign a different device name and label, please
implement the follow lines of code into your setup of your code (no changes are needed in the loop).

• To change the Device Name:

client.setDataSourceName("New_name");

• To change the Device label:

client.setDataSourceLabel("New_label");

50 | P a g e
2. Sending (POST) Data to Ubidots

With the following sample code you will be able to post readings taken from the ANALOG pin of
the NodeMCU ESP8266.

1. To post your first value in Ubidots, open the Arduino IDE and paste the sample code below. Once
you have pasted the code, you will need to assign your unique Ubidots TOKEN, SSID (WiFi
Name) and Password of the available network.

#include "UbidotsMicroESP8266.h"

#define TOKEN "Your_token_here" // Put here your Ubidots TOKEN #define


WIFISSID "Your_WiFi_SSID" // Put here your Wi-Fi SSID #define
PASSWORD "Your_WiFi_Password" // Put here your Wi-Fi password

Ubidots client(TOKEN);

void setup(){
Serial.begin(115200);
client.wifiConnection(WIFISSID, PASSWORD);
//client.setDebug(true); // Uncomment this line to set DEBUG on

}
void loop(){
float value1 = analogRead(A0);
client.add("temperature", value1);
client.sendAll(true);
delay(5000);
}

2. Verify your code within the Arduino IDE. To do this, in the top left corner of our Arduino IDE you will
see the "Check Mark" icon; press it to verify your code.

3. Upload the code into your “NodeMCU 1.0(ESP12E module)”. To do this, choose the "right-arrow"
icon beside the "check mark" icon.

4. To verify the connectivity of the device and the data sent, open the serial monitorby selecting
the "magnifying glass" icon in the top right corner of the Arduino IDE to see the connectivity logs.

NOTE: If no response is seen, try unplugging the NodeMCU and then plugging it again. Make sure the
baud rate of the Serial monitor is set to the same one specified in your code 115200.

5. Confirm your data in Ubidots. Now you should see the posted data in your Ubidots account, located
the device called "esp8266".

3. Summary

With this simple tutorial you are able to POST data to Ubidots with
the ease of the Arduino IDE and a NodeMCU ESP8266.
51 | P a g e
Introduction to Raspberry pi

What is Raspberry pi?

• Raspberry Pi is a credit card sized bargain micro Linux machine.


• The goal behind creating Raspberry Pi was to create a low-cost device that would improve programming
skills and hardware understanding for students.
• The latest model of Raspberry Pi comes sporting 1 GB of RAM, 1200 MHz quad – core ARM Cortex-
A53 processor, and basic levels of functionality that enables hobbyists, computer enthusiasts, and
students to use this device for DIY projects.
• Raspberry Pi is open hardware with the exception of its primary chip, the Broadcomm SoC which
runs the main components of the board – CPU, graphics, memory, USB controller etc.

Raspberry Pi 3 Model B
(Latest release of Raspberry Pi)

Pin Configuration of Raspberry Pi +:

52 | P a g e
Connecting with Raspberry pi:

GPIO Pin Configurations:

53 | P a g e
Simulate data in Ubidots using Python in Raspberry Pi

Send a simple Python requests from Raspberry Pi's terminal to test and interact with Ubidots' REST
API.

If you have a Raspberry Pi, Onion Omega, Beaglebone or other Linux-based device, or if you just want
to create a script in your PC to interact with Ubidots, here's a brief example to get you there.

Requests: HTTP for Humans

Requests is a popular Python library that simplifies making HTTP requests from any python script which
can be run in your computer's terminal or any embedded Linux device.

With your computer configured with Python correctly, run the pip package in your computer or
device's terminal to install the correct library.

$ pip install requests

With Python properly installed, we will now need to create a Python script. Run the below command in
your computer terminal to create a script.

$ nano

Python Script Theory

First, let's look at how Ubidots API expects an HTTP request to process data:

• Method: HTTP allows for several methods (GET, POST, PUT, DELETE, etc). To create a value in
Ubidots we use a POST request.
• URL: The URL of the resource you want to access
(things.ubidots.com/api/v1.6/your-device-label/?token=your-token)
• HTTP Headers: Ubidots' API uses JSON as the data type, so the header would be
"Content-Type:application/json"
• Body: A JSON string containing the label of the variable(s) and their values. For example:
{"temperature":23, "humidity":98}

Sending data with your code

Copy and paste the below code in your terminal; assigning your Ubidots TOKEN where indicated in
the code.

import time
import requests
import math
import random

TOKEN
TOKEN = "..." # Put your here
DEVICE_LAB
EL = "machine" # Put your device label here
VARIABLE_LA
BEL_1 = "temperature" # Put your first variable label here
VARIABLE_LA
BEL_2 = "humidity" # Put your second variable label here
VARIABLE_LA = "position" # Put your second variable label here
BEL_3

54 | P a g e
def build_payload(variable_1, variable_2, variable_3):
# Creates two random values for sending data
value_1 = random.randint(-10, 50)
value_2 = random.randint(0, 85)

# Creates a random gps coordinates


lat = random.randrange(34, 36, 1) + \
random.randrange(1, 1000, 1) / 1000.0
lng = random.randrange(-83, -87, -1) + \
random.randrange(1, 1000, 1) / 1000.0
payload = {variable_1: value_1,
variable_2: value_2,
variable_3: {"value": 1, "context": {"lat": lat, "lng": lng}}} return

payload

def post_request(payload):
# Creates the headers for the HTTP requests url
= "http://things.ubidots.com"
url = "{}/api/v1.6/devices/{}".format(url, DEVICE_LABEL)
headers = {"X-Auth-Token": TOKEN, "Content-Type": "application/json"}

# Makes the HTTP requests


status = 400
attempts = 0
while status >= 400 and attempts <= 5:
req = requests.post(url=url, headers=headers, json=payload)
status = req.status_code
attempts += 1
time.sleep(1)

# Processes results if
status >= 400:
print("[ERROR] Could not send data after 5 attempts, please check \ your
token credentials and internet connection")
return False

print("[INFO] request made properly, your device is updated")


return True

def main():
payload = build_payload(
VARIABLE_LABEL_1, VARIABLE_LABEL_2, VARIABLE_LABEL_3)

print("[INFO] Attemping to send data")


post_request(payload)
print("[INFO] finished")

if __name__ == '__main__':
while (True):
main()
time.sleep(1)

Once the code has been compiled with your Ubidots TOKEN, press CONTROL + O and ENTER to save
the file - assigning a file name as you save (be sure to remember the ".py" in your file name). Once the
script is saved, exit the Python editor by pressing CONTROL + X and return to the computer's terminal.
Execute your script

From your computer terminal, run the script, (including the saved script from Python editor) with
the following command.

55 | P a g e
$ python [saved_script_name].py

Visualize your results

Run the code in your computer or device(Raspberry pi) terminal to begin simulating data and visualize
your work by logging into your Ubidots account.

Receiving data with your code

import requests
import random
import time

TOKEN = "...." # Assign your Ubidots Token


DEVICE = "...." # Assign the device label to obtain the variable
VARIABLE = "...." # Assign the variable label to obtain the variable value
DELAY = 1 # Delay in seconds

def get_var(device, variable):


try:
url = "http://things.ubidots.com/"
url = url + \
"api/v1.6/devices/{0}/{1}/".format(device, variable)
headers = {"X-Auth-Token": TOKEN, "Content-Type": "application/json"} req =
requests.get(url=url, headers=headers)
return req.json()['last_value']['value'] except:
pass

if __name__ == "__main__":
while True:
print(get_var(DEVICE, VARIABLE))
time.sleep(DELAY)

56 | P a g e
Ubidots for Education Events: Creating an Event (SMS, Email, and Telegram)

Learn to create complex events via email, SMS, or Telegram based on your sensor data.

An event (or alert) is any action triggered when data fulfills or exceeds a design rule. For example, an
email or SMS message can be sent anytime a sensor stops sending data or a temperature exceeds a
maximum threshold. In this article we will describe the setup and logic of Ubidots' Events Engine.

Creating an Event

To begin, we will tell Ubidots to send an alert via email when the variable called "Power" exceeds a
predetermined 1,500 boundary.

To create an Event:

• Select Events (from the Device Management dropdown).


• Select Add Event
• Select a device: Machine 1 (the name of our device)
• Select a variable: Power
• If the value is greater than 1,500, then send an email.

57 | P a g e
Next, choose the format of your alert. In this case, we will use emails.

Alerts can be very helpful and with Ubidots you can customize who, when, why, and what will be said
in any alert. You might be interested in sending this alert to your maintenance department, machinist, or
a manufacturer for quality assurance.

Lastly, name this alert for simple identifying the next time it is needed.

Select "Finish" and you have now created an alert for the Power variable when it exceeds 1,500.

We also created an alert when Machine's 1 energy consumption is below 5000 and inserted the last value
of the variable within the message.

Types of Text Message Alerts

SMS: SMS stands for Short Messaging Service and is a text-only messages with a limit of 160 characters
per message.
58 | P a g e
Telegram: is an open source messaging app that allows you to send files in almost any format.

When Events are Triggered

The figure below describes how the Events Engine triggers alerts inside Ubidots core:

Please note that after an alert is triggered, the subsequent values will not trigger the alert again, even if
they comply with the trigger conditions, unless the value goes outside the trigger condition and returns
again:

59 | P a g e
Just being connected only gets us so far. Intelligence is required to build truly useful IoT devices.

When you think about the Internet of Things (IoT), when do you picture it arriving? In five years?
Ten?

It’s a trick question, because the IoT is already here. Don’t believe me? Answer this: How many IP
addresses do you have at home right now?

It wasn’t that long ago that every house had only a single IP address — one for a PC modem. These days,
nearly every new smartphone, tablet and speaker has an IP address. If you’ve got a thermostat, security
cameras or connected lightbulbs, they’ve got them, too. Add all these things up, and you’ll find you’ve got
10, 20, or maybe even 30 IP addresses at home. I’ve got 43.

Just being connected only gets us so far. Intelligence is required to build truly useful IoT devices.

What do IP addresses have to do with the state of the IoT? They’re an indication that our lives and our
homes are already full of connected devices. We’re surrounded by them. And many of these devices aren’t
just connected — — they’re also intelligent. This means that homes and cities aren’t suddenly going to
become smart at some point in the future. There won’t be a “eureka!” moment or a flipped switch. Instead,
we’re building an intelligent IoT one purchase at a time. And that’s already changing the way we live our
lives.

Take televisions. You’re going to have a hard time buying one that’s not connected today. A good set will
be able to download its own software updates and stream your favourite shows from your favourite
streaming services.

And TVs are just one piece of the trend; connectivity is being added to an amazing array of devices, from
simple to complex, all over the world. In China, for example, companies like Haier, Hisense and Medea
launch hundreds of appliances every year, and more than half are connected. We’re talking rice cookers,
vacuums, dishwashers, and even air conditioners. The number of connected devices worldwide is expected
to be in the billions in the next few years.
That connectivity brings plenty of convenience to our devices, but just being connected only gets us so far.
Intelligence is required to build truly useful IoT devices. The TV of the future will work with other devices
and sensors in your house to recognize when you’re sitting in front of it, and will automatically flip on your
favourite show. You’ll also be able to use it to control your lights, thermostat, and probably everything else.

And those benefits aren’t limited to the home. Imagine intelligent freeway lighting that only illuminates
roads when it senses a car approaching, or connected cars that interact with parking meters to tell you
where the closest available parking spot is.

We need to break down the barriers that keep smart devices as islands, unable to communicate with
one another.

The IoT also needs to evolve to be truly functional. The next step is a seamless network of devices that live
at the edge and have intelligent processing. Take that security camera in your house. Right now, you get a
barrage of useless notifications, because it can’t tell the difference between a car on the street and a
stranger at your door. Thinking ahead: A smart security camera would not only be able to differentiate
between friends and strangers, but also pets and stray animals. And it would only notify you when someone
you don’t know is knocking at the door.

Intelligent processing has its challenges, though, like storage, security and seamless interactions. We need
to break down the barriers that keep smart devices as islands, unable to communicate with one another.
Your TV should be able to talk to your refrigerator if it wants to.

And, of course, you still need to meet consumer expectations: Simplicity, durability and extended battery
life. You don’t want a fitness tracker that requires you to constantly check your phone, but neither do you
want a bulky smartwatch that runs out of batteries in a couple of hours.

There’s no one technology that will address all these issues. It’s going to take multiple kinds of connectivity,
from Wi-Fi to Bluetooth to LTE. We need complex information processing capabilities that work on the
edge and in the cloud. It’s much more than just adding a bunch of sensors to the environment. It requires
new thinking and the creation of platforms and systems that can take all of these challenges and deliver them
in a format that works.

The evolution will be incremental. But add up the many small changes, and we’ll soon be living in a
new kind of smart, connected world. The future of the IoT will be here faster than you think.

61 | P a g e
The Cloud

What is cloud computing?


Simply put, cloud computing is the delivery of computing services—servers, storage, databases, networking,
software, analytics and more—over the Internet (“the cloud”). Companies offering these computing services
are called cloud providers and typically charge for cloud computing services based on usage, similar to how
you are billed for water or electricity at home.

Cloud Computing Basics


Whether you are running applications that share photos to millions of mobile users or you’re supporting the
critical operations of your business, a cloud services platform provides rapid access to flexible and low -cost
IT resources. With cloud computing, you don’t need to make large upfront investments in hardware and
spend a lot of time on the heavy lifting of managing that hardware. Instead, you can provision exactly the
right type and size of computing resources you need to power your newest bright idea or operate your IT
department. You can access as many resources as you need, almost instantly, and only pay for what you use.

Uses of cloud computing


You are probably using cloud computing right now, even if you don’t realize it. If you
use an online service to send email, edit documents, watch movies or TV, listen to
music, play games or store pictures and other files, it is likely that cloud computing is
making it all possible behind the scenes. The first cloud computing services are barely
a decade old, but already a variety of organisations—from tiny startups to global
corporations, government agencies to non-profits—are embracing the technology for
all sorts of reasons. Here are a few of the things you can do with the cloud:

• Create new apps and services


Store, back up and recover data
• Host websites and blogs
Stream audio and video
• Deliver software on-demand Analyse data for patterns and make predictions

62 | P a g e
Six Advantages and Benefits of Cloud Computing

Trade capital expense for variable expense


Instead of having to invest heavily in data centres and servers before you know how you’re
going to use them, you can only pay when you consume computing resources, and only pay for
how much you consume.
Benefit from massive economies of scale
By using cloud computing, you can achieve a lower variable cost than you can get on your own.
Because usage from hundreds of thousands of customers are aggregated in the cloud, providers
such as Amazon Web Services can achieve higher economies of scale which translates into lower pay as you
go prices.

Stop guessing capacity


Eliminate guessing on your infrastructure capacity needs. When you make a capacity decision prior to
deploying an application, you often either end up sitting on expensive idle resources or dealing with
limited capacity. With cloud computing, these problems go away. You can access as much or
as little as you need, and scale up and down as required with only a few minutes notice.

Increase speed and agility


In a cloud computing environment, new IT resources are only ever a click away, which means
you reduce the time it takes to make those resources available to your developers from weeks to
just minutes. This results in a dramatic increase in agility for the organization since the cost and time it
takes to experiment and develop is significantly lower.

Stop spending money on running and maintaining data centers


Focus on projects that differentiate your business, not the infrastructure. Cloud computing lets
you focus on your own customers, rather than on the heavy lifting of racking, stacking and
powering servers.

Go global in minutes
Easily deploy your application in multiple regions around the world with just a few clicks. This
means you can provide lower latency and a better experience for your customers simply and at
minimal cost.

63 | P a g e
Types of cloud services: IaaS, PaaS, SaaS
Most cloud computing services fall into three broad categories:
infrastructure as a service (IaaS), platform as a service (PaaS) and
software as a service (Saas). These are sometimes called the cloud
computing stack because they build on top of one another. Knowing
what they are and how they are different makes it easier to accomplish
your business goals.
Infrastructure-as-a-service (IaaS)
The most basic category of cloud computing services. With IaaS, you
rent IT infrastructure—servers and virtual machines (VMs), storage,
networks, operating systems—from a cloud provider on a pay-as-you-go
basis.
Platform as a service (PaaS)
Platform-as-a-service (PaaS) refers to cloud computing services that
supply an on-demand environment for developing, testing, delivering
and managing software applications. PaaS is designed to make it easier
for developers to quickly create web or mobile apps, without worrying
about setting up or managing the underlying infrastructure of servers,
storage, network and databases needed for development.
Software as a service (SaaS)
Software-as-a-service (SaaS) is a method for delivering software
applications over the Internet, on demand and typically on a
subscription basis. With SaaS, cloud providers host and manage the
software application and underlying infrastructure and handle any
maintenance, like software upgrades and security patching. Users
connect to the application over the Internet, usually with a web
browser on their phone, tablet or PC.

Few Popular Public Cloud Services Present in the market are:

• Amazon Web Services


• Google Cloud Platform
• IBM Cloud
• Microsoft Azure
• Alibaba Cloud

64 | P a g e
Introduction to AWS

Amazon Web Services (AWS) is a cloud service from Amazon, which provides services in the form of
building blocks, these building blocks can be used to create and deploy any type of application in the cloud.

These services or building blocks are designed to work with each other, and result in applications which are
sophisticated and highly scalable.

Global network of AWS regions

AWS offers the largest global footprint in the market. No other cloud provider offers as many regions with
multiple Availability Zones, with 66 Availability Zones (AZs) within 21 geographic regions around the
world, and announced plans for 12 more AZs and four more Regions in Bahrain, Cape Town, Jakarta, and
Milan.

65 | P a g e
Each type of service here is categorized under a domain, the few domains which are widely used are:

• Compute
• Storage
• Database
• Migration
• Network and Content Delivery
• Management Tools
• Security & Identity Compliance
• Messaging

The Compute domain includes services related to compute workloads; it includes the following services:

• EC2 (Elastic Compute Cloud)


• Lambda
• Elastic Beanstalk
• Amazon LightSail

The Storage domain includes services related data storage; it includes the following services:

• S3 (Simple Storage Service)


• Elastic Block Store
• Amazon Glacier
• AWS Snowball

The Database domain is used for database related workloads, it includes the following services:

• Amazon Aurora
• Amazon RDS
• Amazon DynamoDB
• Amazon RedShift

The Migration domain is used for transferring data to or from the AWS Infrastructure, it includes the
following services:

• AWS database Migration Service


• AWS SnowBall

The Networking and Content Delivery domain is used for isolating your network infrastructure, and
content delivery is used for faster delivery of content. It includes the following services:

• Amazon Route 53
• AWS CloudFront

The Management Tools domain consists of services which are used to manage other services in AWS, it
includes the following services:

• AWS CloudWatch
• AWS CloudFomation
• AWS CloudTrail

The Security & Identity, Compliance domain consist of services which are used to manage to authenticate
and provide security to your AWS resources. It consists of the following services:

66 | P a g e
• AWS IAM
• AWS KMS
• AWS Shield

The Messaging domain consists of services which are used for queuing, notifying or emailing messages. It
consists of the following domains:

• Amazon SQS
• Amazon SNS
• Amazon SES
• Amazon Pinpoint

Introduction to AWS IoT

AWS IoT provides secure, bi-directional communication between Internet-connected devices such as
sensors, actuators, embedded micro-controllers, or smart appliances and the AWS Cloud. This enables you
to collect telemetry data from multiple devices, and store and analyse the data. You can also create
applications that enable your users to control these devices from their phones or tablets.

AWS IoT Components


AWS IoT consists of the following components:
Device gateway
Enables devices to securely and efficiently communicate with AWS IoT.
Message broker
Provides a secure mechanism for devices and AWS IoT applications to publish and receive messages
from each other. You can use either the MQTT protocol directly or MQTT over WebSocket to
publish and subscribe. You can use the HTTP REST interface to publish.
Rules engine
Provides message processing and integration with other AWS services. You can use an SQL-based
language to select data from message payloads, and then process and send the data to other
services, such as Amazon S3, Amazon DynamoDB, and AWS Lambda. You can also use the
message broker to republish messages to other subscribers.
Security and Identity service
Provides shared responsibility for security in the AWS Cloud. Your devices must keep their
credentials safe in order to securely send data to the message broker. The message broker and
rules engine use AWS security features to send data securely to devices or other AWS services.
Registry
Organizes the resources associated with each device in the AWS Cloud. You register your devices
and associate up to three custom attributes with each one. You can also associate certificates and
MQTT client IDs with each device to improve your ability to manage and troubleshoot them.
Group registry
Groups allow you to manage several devices at once by categorizing them into groups. Groups can
also contain groups—you can build a hierarchy of groups. Any action you perform on a parent
group will apply to its child groups, and to all the devices in it and in all of its child groups as well.
Permissions given to a group will apply to all devices in the group and in all of its child groups.
Device shadow
67 | P a g e
A JSON document used to store and retrieve current state information for a device.
Device Shadow service
Provides persistent representations of your devices in the AWS Cloud. You can publish updated
state information to a device's shadow, and your device can synchronize its state when it connects.
Your devices can also publish their current state to a shadow for use by applications or other
devices.
Device Provisioning service
Allows you to provision devices using a template that describes the resources required for your
device: a thing, a certificate, and one or more policies. A thing is an entry in the registry that
contains attributes that describe a device. Devices use certificates to authenticate with AWS IoT.
Policies determine which operations a device can perform in AWS IoT.
The templates contain variables that are replaced by values in a dictionary (map). You can use the
same template to provision multiple devices just by passing in different values for the template
variables in the dictionary.
Custom Authentication service
You can define custom authorizers that allow you to manage your own authentication and
authorization strategy using a custom authentication service and a Lambda function. Custom
authorizers allow AWS IoT to authenticate your devices and authorize operations using bearer
token authentication and authorization strategies.
Custom authorizers can implement various authentication strategies (for example, JSON Web Token
verification, OAuth provider callout, and so on) and must return policy documents that are used by
the device gateway to authorize MQTT operations.
Jobs service
Allows you to define a set of remote operations that are sent to and executed on one or more
devices connected to AWS IoT. For example, you can define a job that instructs a set of devices to
download and install application or firmware updates, reboot, rotate certificates, or perform
remote troubleshooting operations.
To create a job, you specify a description of the remote operations to be performed and a list of
targets that should perform them. The targets can be individual devices, groups or both.

AWS IoT Pricing at a glance

Connectivity

Connectivity provides a secure, authenticated connection between your devices and AWS IoT Core.
Connectivity is metered in 1-minute increments and is based on the total time your devices are connected
to AWS IoT Core.
Region:

• US East (N. Virginia)

Connectivity pricing: $0.08 (per million minutes of connection)

For example, in the US East (N. Virginia) region you pay $0.042 per device per year (1 connection *
$0.08/1,000,000 minutes of connection * 525,600 minutes/year) for 24/7 connectivity. In order to maintain

68 | P a g e
connectivity, devices may send keep-alive (“Ping”) messages at frequencies ranging from 20 minutes to
every 30s, and you do not incur any additional cost for these messages.
Messaging

Messages transport device data to and from AWS IoT Core. Messaging is metered by the number of
messages transmitted between your devices and AWS IoT Core.
Region:

• US East (N. Virginia)

Messaging pricing

Up to 1 billion messages: $1 (per million messages)

Next 4 billion messages: $0.8 (per million messages)

Over 5 billion messages: $0.7 (per million messages)

You may send and receive messages up to 128 kilobyte (KB) in size. Messages are metered in 5
KB increments. For example, an 8 KB message is metered as two messages.
Device Shadow & Registry

The Device Shadow stores the desired state or actual state of a device, and the Registry is used to name
and manage devices. Use of Device Shadow and Registry is metered by the number of operations that
access or modify Device Shadow or Registry data.
Region:

• US East (N. Virginia)

Device Shadow and Registry pricing: $1.25 (per million operations)

Device Shadow and Registry operations are metered in 1 KB increments of the Device Shadow or
Registry record size. For example, an update to a 1.5 KB Device Shadow record is metered as two
operations.
Rules Engine

Rules Engine allows you to transform device data using arithmetic operations or external functions such as
AWS Lambda, and then route the data to an AWS service such as Amazon S3, Amazon DynamoDB, or
Amazon Kinesis. Rules Engine use is metered for each time a rule is triggered, and for the number of
actions executed within a rule, with a minimum of one action per rule.
Region:

• US East (N. Virginia)

Rules Engine pricing

Rules triggered: $0.15 (per million rules triggered / per million actions executed)

Actions executed: $0.15 (per million rules triggered / per million actions executed)

69 | P a g e
Rules and actions are metered in 5 KB increments of the message size. For example, a rule that processes a
5 KB message and executes no action is metered as one rule and one action, and a rule that processes an 8
KB message and executes two actions is metered as two rules and four actions.

AWS Free Tier with AWS IoT Core

• 2,250,000 minutes of connection


• 500,000 messages
• 225,000 Registry or Device Shadow operations
• 250,000 rules triggered and 250,000 actions executed

For example, the Free Tier would allow you to run a 50-device workload, where each device:

• Connects for 24 hours a day


• Exchanges 300 messages per day (message size 5 KB or smaller)
• Makes 130 Registry or Device Shadow operations per day (Registry or Device Shadow record size 1
KB or smaller)
• Triggers 150 rule executions per day that invoke one action (processed message size 5 KB or smaller)

The AWS Free Tier is available to you for 12 months starting with the date on which you create your AWS
account. When your free usage expires or if your application use exceeds the free usage tiers, you simply
pay the above rates. The free usage tier applies across all AWS Regions except GovCloud (US). Your usage
is calculated each month across all regions and is automatically applied to your bill. Note that free usage
does not accumulate from one billing period to the next.

70 | P a g e
Introduction to Google Cloud Platform

Google Cloud Platform (GCP) is a collection of Google’s computing resources, made available via services
to the general public as a public cloud offering.

The GCP resources consist of physical hardware infrastructure — computers, hard disk drives, solid state
drives, and networking — contained within Google’s globally distributed data centers, where any of the
components are custom designed using patterns similar to those available in the Open Compute Project.

This hardware is made available to customers in the form of virtualized resources, such as virtual
machines (VMs), as an alternative to customers building and maintaining their own physical
infrastructure.

As a public cloud offering, software and hardware products are provided as integrated services that provide
access to the underlying resources. GCP offers over 50 services including Infrastructure as a Service (IaaS),
Platform as a Service (PaaS), and Software as a Service (SaaS) offerings in the categories of Compute,
Storage & Databases, Networking, Big Data, Machine Learning, Identity & Security, and Management &
Developer tools.

These services can be used independently or in combination for developers and IT professionals to construct
their own, custom cloud-based infrastructure.

GCP is hosted on the same underlying infrastructure that Google uses internally for end-user products
including Google Search and YouTube.

Regional Service Architecture


Each of Google Cloud Platform’s services and resources can be zonal, regional, or managed by Google
across multiple regions.

71 | P a g e
A zone is a deployment area for resources within a region. Zones are isolated from each other to prevent
outages from spreading between them, so each zone is considered a single failure domain within a region.

Zonal resources operate within a single zone; if a zone becomes unavailable all of its resources are
unavailable until service is restored. Regional resources are deployed with redundancy across zones within a
region. Multi-regional services (Google App Engine, Google Datastore, Google Cloud Storage, Google
BigQuery) are managed by Google to be redundant and distributed within and across regions.

All GCP service instances are configured such that maintenance events are transparent to applications and
workloads via live migration. Live migration moves running virtual machine instances out of the way of
maintenance that is being performed.

GCP services are available in 18 zones in 6 regions: Oregon, Iowa, South Carolina, Belgium, Taiwan,
and Tokyo¹.

In 2016, Google announced plans to make 22 zones and 8 new regions available in 2017: Sydney, Sao
Paulo, Frankfurt, Mumbai, Singapore, London, Finland, and Northern Virginia.

Within each region, traffic tends to have round-trip network latencies of under 5ms on the 95th percentile.

GOOGLE CLOUD IOT CORE


A fully managed service to easily and securely connect, manage, and ingest data from globally
dispersed devices.

Secure device connection and management

Cloud IoT Core is a fully managed service that allows you to easily and securely connect, manage, and
ingest data from millions of globally dispersed devices. Cloud IoT Core, in combination with other services
on Cloud IoT platform, provides a complete solution for collecting, processing, analyzing, and visualizing
IoT data in real time to support improved operational efficiency.

72 | P a g e
Make informed decisions at global scale

Cloud IoT Core, using Cloud Pub/Sub underneath, can aggregate


dispersed device data into a single global system that integrates
seamlessly with Google Cloud data analytics services. Use your IoT
data stream for advanced analytics, visualizations, machine learning,
and more to help improve operational efficiency, anticipate problems,
and build rich models that better describe and optimize your business.

Securely connect your existing device network

Securely connect a few or millions of your globally dispersed


devices through protocol endpoints that use automatic load
balancing and horizontal scaling to ensure smooth data
ingestion under any condition. Cloud IoT Core supports the
standard MQTT and HTTP protocols, so you can use your
existing devices with minimal firmware changes. Cloud IoT
Core runs on Google’s serverless infrastructure, which scales
automatically in response to real-time changes and adheres to
stringent industry-standard security protocols that protect
your business data.

Establish two-way communication with your devices

Bring device data into your everyday business through a secure,


intelligent, and responsive IoT data pipeline created by Cloud IoT
Core. Easily push your own device updates with Cloud IoT Core.

Get straight to work

Centrally manage your entire IoT data network from a single


pane of glass. Cloud IoT Core works out of the box with
devices from leading hardware manufacturers. You can easily
reduce capital expenditures on your IoT projects and
maintenance costs with a pay-as-you-go service.

Zero touch device provisioning to Cloud IoT Core

Cloud IoT provisioning service (early access) is an add-on service


for Cloud IoT Core that simplifies the device provisioning and on-
boarding experience for Cloud IoT customers and OEMs. It
performs secure, hassle -free device provisioning by leveraging
tamper-resistant hardware - based security, otherwise referred to as
a crypto chip or Secure Element (SE) from OEM partners, enabling
customers to provision millions of devices to the right Cloud IoT
Core without human intervention.

Google IoT Core pricing is not enough to understand the cost of


working with it. Every connection of cloud service with devices requires to utilize GCP’s multiple
other services.
73 | P a g e
We have worked on several hands-on sessions utilizing Google cloud platform and Amazon web
Service cloud Services such as IoT Core, Firebase etc.
We will not discuss the steps here as each of them are pretty long process to describe.

Here is a list of experiments and link of the steps:

Hands-on: Publishing Data from Raspberry pi to AWS IoT core using Python based Simulation via
MQTT protocol.

Hands-on: Subscribing Data from AWS IoT core topic to Raspberry pi via MQTT protocol using Python
based code.

Here is a link of the GitHub based tutorial created by our instructor which we have followed:
https://github.com/rudz4u/AWS-IoT-Basic-Codes

We have also completed all the Virtual labs Available on Qwiklabs for Google IoT based integrations:

https://www.qwiklabs.com/quests/49

Following Labs are performed:

HANDS-ON LAB
Internet of Things: Qwik Start
This lab shows you how to use Google Cloud Platform Console to create a Cloud IoT Core device
registry and register a device. It also shows you how to run a sample to connect a device and publish
device telemetry events.

HANDS-ON LAB

Streaming IoT Data to Google Cloud Storage


In this lab configure Cloud IoT Core and Cloud Pub/Sub to create a Pub/Sub topic and registry on GCP,
then use this topic to ingest data streaming from a simulated IoT device.

HANDS-ON LAB

Streaming IoT Core Data to Dataprep


Configure Cloud IoT Core and Cloud Pub/Sub to create a Pub/Sub topic and registry on GCP. Using a
simulated device, stream data to Google Cloud Storage, then design a Dataprep flow to analyze data.

74 | P a g e
HANDS-ON LAB

Building an IoT Analytics Pipeline on Google Cloud Platform


This lab shows you how to connect and manage devices using Cloud IoT Core; ingest the steam of
information using Cloud Pub/Sub; process the IoT data using Cloud Dataflow; use BigQuery to analyze the
IoT data.

HANDS-ON LAB

A Tour of Cloud IoT Core


In this lab you build a simple IoT system. Simulated devices publish data to their telemetry feeds, the
server then decides the devices' state using IoT Core.

HANDS-ON LAB

APIs Explorer: IoT


In this lab you will provision Cloud IoT and Pub/Sub services using the APIs explorer. These will be
used to create a temperature telemetry steam.

HANDS-ON LAB

Using Stackdriver Logging with IoT Core Devices


In this hands-on lab you configure CloudFunctions to send IoT Core device application logs to Stackdriver
Logging.

HANDS-ON LAB

Using Firestore with Cloud IoT Core for Device Configuration


Learn how to configure Cloud Functions for Firebase to relay document changes in Cloud Firestore
as configuration updates for Cloud IoT Core Devices.

HANDS-ON LAB

Streaming IoT Kafka to Google Cloud Pub/Sub


In this lab you create an instance of Confluent Kafka to communicate with Google Cloud Pub/Sub using
source and sink mechanisms.
75 | P a g e
Conclusion:

After this training session we have now got exposure of Internet of Things in advance level with
utilization of Cloud based services to take our application at scales.
We have additionally explored about Computer vision technology using Google
vision API via qwiklabs link : https://www.qwiklabs.com/focuses/1841?parent=catalog

We would now able to do our own IoT project works with a complete loop system from device end to
user end.

76 | P a g e
77 | P a g e

You might also like