You are on page 1of 40

What is an RTOS?

Simply put, an RTOS is a piece of software designed to efficiently manage the time of a central
processing unit (CPU). This is especially relevant for embedded systems when time is critical.

The key difference between an operating system such as Windows and an RTOS often found in
embedded systems is the response time to external events. An ordinary OS provides a non-
deterministic response to events with no guarantee with respect to when they will be processed,
albeit while trying to stay responsive. The user perceiving the OS to be responsive is more
important than handling underlying tasks. On the other hand, an RTOS' goal is fast and more
deterministic reaction.

Using an RTOS means you can run multiple tasks concurrently, bringing in the basic connectivity,
privacy, security, and so on as and when you need them. An RTOS allows you to create an
optimized solution for the specific requirements of your project.

How does the RTOS affect the development of


the design?
The choice of RTOS can greatly affect the development of the design. By selecting an appropriate
RTOS the developer gains:
 A Task based design that enhances modularity, simplifies testing and encourages code
reuse;
 An environment that makes it easier for engineering teams to develop together;
 Abstraction of timing behaviour from functional behaviour, which should result in smaller
code size and more efficient use of available resources.

Peripheral support, memory usage and real-time capability are key features that govern the
suitability of the RTOS. Using the wrong RTOS, particularly one that does not provide sufficient real
time capability, will severely compromise the design and viability of the final product.

The RTOS needs to be of high quality and easy to use. Developing embedded projects is difficult
and time consuming – the developer does not want to be struggling with RTOS related problems as
well. The RTOS must be a trusted component that the developer can rely on, supported by in-depth
training and good, responsive support.
The IoT technology industry has grown so huge that it has established itself as
the king of technology in every business and industry. The players who use this
technology to come up with their best products will benefit themselves a great
deal, and move miles ahead of the competition.
The leading IoT areas are transportation/automotive, healthcare, smart home
appliances, retail and wearables. Big players have already staked their claim in
the most lucrative of all consumer markets, but there is still tremendous
potential for new players.

Each year, innovations in the field of IoT have made it more exciting than ever.
Many of them are revealed through events like CES, the show that reveals to
the world what the tech world has been up to. In CES 2018, we were introduced
to the newest versions of groundbreaking technology. The best in the show
winner was The Wall by Samsung, while the People’s Choice was HTC Vive
Pro. Other interesting things on the show were rollable LG OLED TV, ultra-thin
laptops, Google Assistant, Amazon Alexa, smart thermostats & light bulbs,
Internet-connected garage door openers, GoPro cameras, and new Sony
smartphones. It means smart devices just got smarter.
This brings us to topic of wireless communication. There are so many
communication technologies around, so which one should you use? The idea is
to create user-friendly devices that can make lives easier, so the choice of
technology is very, very important.

What are the Options We Have?

Wireless communication technology has evolved to be an integral part of


communication devices, no matter what they are used for. Understandably, they
don’t need wires to send signals, and hence can communicate from even
remote areas. Perfect examples of wireless devices can be cordless
telephones, GPS units, wireless computer parts, satellite television, ZigBee
technology and many more. Major forms of wireless communication are
Satellites, Near Field Communications (NFC), Infrared (IR), Cellular
Connectivity, Wireless networking, WiMax, Li-Fi , Wi-Fi and Bluetooth LE (BLE).
With the surge of IoT apps, Near Field Communications (NFC) and Infrared (IR)
virtually became non-existent. Infrared communication showed its potential
when flip phones were used, but these days, you hardly see them, because
people mostly use smartphones. Infrared also requires the devices to be in
close range with each other, and there is very low bandwidth. Near Field
Communication, as the name suggests, allows a short range of less than 20
centimeters. Only very few cell phones support it as it has low transmission
capacity. Cellular Connectivity is a viable option for IoT devices with a 5G
network connection, but it will require a SIM card and the user has to pay a
subscription fee.

So that leaves us with the best of the others - Bluetooth LE (BLE) and Wi-Fi.

Which One Should You Choose? BLE or Wi-Fi?

BLE (Bluetooth Low Energy) such as iBeacons or Beacons are used to send
data over short distances. This wireless technology has become a recent
alternative for Wi-Fi, especially in IoT devices and apps. Let’s look at some
important factors that must be considered when making the choice between
BLE and Wi-Fi for wireless communication.
Privacy

Once a person turns on their Wi-Fi connection, the device will be on the
constant lookout for a Wi-Fi network. Retailers find this very useful, because
they track their customers and send them offers and discounts. It can even
track their physical movements, down to the exact location. Wi-Fi technology
does not necessarily ask the permission of the consumer to do this, because
there is no user intervention involved. If you want to be free of Wi-Fi, you will
have to disable it on your device.
For BLE technology, the consumer has to switch on the Bluetooth facility in their
phones and allow location detection. You can opt to receive in-store or indoor
notifications.

Users might want to choose a technology that gives them more privacy, more
freedom over the data they share in public. BLE offers more privacy.

Speed

BLE is more suitable for transmitting small amounts of data at 1 Mbps, like
sensor readings of temperature, acceleration details, GPS coordinates, etc.
However, BLE is not suited for sending data in real-time to a server. If real-time
data is required, a special gateway must be used to send the data.

The Wi-Fi standard 802.11ac can transmit at a speed of up to 1.3 Gbps, so it is


ideal for bigger files and data. Yes, the speed depends on different factors and
it also depends greatly on the provider your user decides to subscribe to. Wi-Fi
Direct provides maximum data transfer speed, about 10 times more than what
you get with Bluetooth Classic. But BLE is about 2-3 times slower than
Bluetooth Classic and 20-30 times slower than Wi-Fi Direct.

Location Detection Accuracy

When positioned indoors, BLE uses advertisement packets to provide additional


information which adhere to iBeacon, Eddystone standard. Beacons use BLE to
sense the proximity of the user and broadcast information to his device
(smartphone, tab, laptop, mobile app, etc) one-way. There is a unique UID
number that can be read by other Bluetooth receivers. Once the device
receives the signal, it will activate location specific information. The signals are
passed through radio waves that can penetrate physical barriers. Location
accuracy can be ensured this way, and Beacons can work even in poor radio
frequency conditions. The only requirement is that the user’s device must have
the Bluetooth switched on in his device.

Wi-Fi is a wireless Local Area Network (LAN) technology where two or more
electronic devices use the ISM radio bandto communicate. Bluetooth also uses
the ISM band, but Wi-Fi technology doesn’t rely solely on the proximity of the
user. Wi-Fi can triangulate the customer’s location when the device sends the
access point's BSSID (MAC address).
When it comes to micro-locating, Beacons are the best option, because Wi-Fi
signals are really not very capable of penetrating through solid objects,
including walls.
Proximity Detection

Wi-Fi is designed to correctly point to the exact location by measuring access


points in a device. Parameters like SSID and MAC address are used for this.

The user’s device should have Bluetooth facility. And once Bluetooth is
detected, the mobile device must be within a specified range because Bluetooth
is all about proximity, and not exact location. Both the devices should be paired
for the facility to function.

The proximity data provided by BLE is much more accurate than Wi-Fi, but not
very accurate either. The maximum range for BLE wireless connections is 30
meters, while Wi-Fi goes further beyond. It depends on the version, but you can
get well over 100 feet if you can extend the connectivity through external
antennas.

Transmission Range

Transmission range varies depending on the Bluetooth product that you use. If
you use class 2 transmitters, the transmission range is around 50 feet, but if
you use a class 1 transmitter, the range would be closer to 300 feet. But the
battery life could be affected. You can use a range extend circuit with sensitive
receivers to get a really long range.

A long-range BLE module (BLE121LR) provides a range of up to around 1,500


feet. On the other hand, Bluetooth Classic long-range module (WT41) gives off
a range up to 3,000 feet! BLE uses a wonderful technique known as mesh
networking, you can transmit over a large range by using very little power. It is
so amazing that you can connect more than 65,000 devices.

As it is said that IoT and Big Data: two sides of the same coin, however, BLE
will not be the adequate choice for every IoT device/scenario. You may have
devices that exchange a lot of data., BLE will not be able to accomplish this. If
you want to transmit large images, Wi-Fi is the answer.
Compatibility

BLE signals can be picked up any Bluetooth 4.0 enabled devices. For Android
devices, Version 4.3 or later would be perfect, while for Apple devices, the
technology runs on Version 4S or later. Wi-Fi works on WLAN 802.11 a/b/g/n/ac
devices. For Android devices, Version 4.0 or later is the preferred choice for Wi-
Fi connectivity, while for Apple devices, you might need Version 5S or later.

The main functionality of BLE beacons is its capability to discover compatible


devices so the distance measures turn out to be more accurate. This will give
you more accuracy regarding the user’s behavior within a particular scenario.

Security

Both the wireless networks offer good levels of user security. But yes, initially,
passive eavesdropping was an issue in BLE, wherein a third-party device
listens to the exchange between two devices. But this issue was cleared
through AES-CCM cryptography where the data is encrypted. The key
exchange protocols that were used by the BLE initially has severe security
vulnerabilities that allowed hackers to decrypt the data that was being passed.
Key exchange that we were talking about here refers to the “pairing method” or
the association model and affects the security of the connection greatly.
The passkey method offers a certain level of protection, wherein a 6-digit
number is passed between the devices. If the hacker is not listening when the
user is typing this passkey, then it offers fairly good protection. Even if a hacker
is able to listen in on the values, then the TK process, or the Temporary Key
process offers sufficient safety.

Wi-Fi uses 256-bit encryption, whereas Bluetooth (Classic and LE) uses only
128-bit encryption. This is the usual level of security users need, but if you need
high levels of security, you might have to choose Wi-Fi. Wi-Fi has two most
popularly security accesses, Wireless Equivalent Privacy (WEP) and Wi-Fi
Protected Access (WPA2-AES) that makes it much more secure. You can
secure the Wi-Fi networks through passwords that render them safe. WPA2 is
always recommended over its predecessor, WPA.

Power Consumption

The power consumption feature is next in our comparison list. Bluetooth


devices have lower power consumption, but Wi-Fi devices consume more
power. This is probably because the broadcast range of the both the
technologies are varied. Both the technologies emit a signal with a frequency of
2.4 gigahertz. The signals edited by iBeacon travels for about 30 feet, while Wi-
Fi signals can travel over 10 times more. And that’s why Wi-Fi requires 10 times
more power than BLE, even if they are performing the same tasks. Wi-Fi
devices need considerable power, about 500µW for ten messages per day,
while BLE consumes only 50µW.

Some applications call for more Wi-Fi electrical power, as much as 40 times the
power that BLE takes up. This may be insignificant in places where electrical
power comes cheap. But for computer users who need to generate their own
electrical power through wind turbine technology and solar cells (as they are off
the power grid), this could be expensive.
iBeacon is very easy to set up and use. It can seamlessly connect to devices
and can easily contain 7 devices within a single network. However, Wi-Fi
doesn’t do it so easily. Users need to have a little bit of technical knowledge to
set up a system, and might even need the services of a technical person.

Deployment Costs

Both BLE and Wi-Fi deployment entails that companies should be prepared on
where they are going to place their devices. It also depends on the software
that will be functioning in these devices.

BLEs are less costly, self-sufficient and can run on a single battery for over 2
years, depending on usage. No configuration is required. Wi-Fi needs router
configurations, and they have to be connected to a power source. The expense
also depends on the router used and of course, the manufacturer.

Conclusion

So, as you can see, wireless communication between smart devices can
happen when a number of good technologies remains in concert with each
other. BLE is probably the most commonly used one, and more capabilities are
added to it to enhance its performance. It is more suitable when you want to
exchange simple data, not any large files or videos.

If you want to send a live video or a bandwidth intensive data, then turn away
from BLE. However, iBeacons would be good if you want to connect to your
home Wi-Fi network as it can command your device’s Wi-Fi chipset, where the
scanning and connecting to a network happens through the user’s own mobile
app. This would undoubtedly give you a very seamless experience and saves
you the trouble of manually connecting and transferring.

LoRa is ideal for applications that transmit small chunks of data with low bit rates. Data can be
transmitted at a longer range compared to technologies like WiFi, Bluetooth or ZigBee. These
features make LoRa well suited for sensors and actuators that operate in low power mode.

LoRa can be operated on the license free sub-gigahertz bands, for example, 915 MHz, 868 MHz,
and 433 MHz. It also can be operated on 2.4 GHz to achieve higher data rates compared to sub-
gigahertz bands, at the cost of range. These frequencies fall into ISM bands that are reserved
internationally for industrial, scientific, and medical purposes.

LoRaWAN 

LoRaWAN is a Media Access Control (MAC) layer protocol built on top of LoRa modulation. It is a
software layer which defines how devices use the LoRa hardware, for example when they transmit,
and the format of messages.

Bandwidth vs. Range 


LoRaWAN is suitable for transmitting small size payloads (like sensor data) over long distances. LoRa
modulation provides a significantly greater communication range with low bandwidths than other
competing wireless data transmission technologies. The following figure shows some access
technologies that can be used for wireless data transmission and their expected transmission ranges
vs. bandwidth.

Why is LoRaWAN so awesome? 


 Ultra low power - LoRaWAN end devices are optimized to operate in low power mode and
can last up to 10 years on a single coin cell battery.
 Long range - LoRaWAN gateways can transmit and receive signals over a distance of over 10
kilometers in rural areas and up to 3 kilometers in dense urban areas.
 Deep indoor penetration - LoRaWAN networks can provide deep indoor coverage, and easily
cover multi floor buildings.
 License free spectrum - You don’t have to pay expensive frequency spectrum license fees to
deploy a LoRaWAN network.
 Geolocation- A LoRaWAN network can determine the location of end devices using
triangulation without the need for GPS. A LoRa end device can be located if at least three
gateways pick up its signal.
 High capacity - LoRaWAN Network Servers handle millions of messages from thousands of
gateways.
 Public and private deployments - It is easy to deploy public and private LoRaWAN networks
using the same hardware (gateways, end devices, antennas) and software (UDP packet
forwarders, Basic Station software, LoRaWAN stacks for end devices).
 End-to-end security- LoRaWAN ensures secure communication between the end device and
the application server using AES-128 encryption.
 Firmware updates over the air - You can remotely update firmware (applications and the
LoRaWAN stack) for a single end device or group of end devices.
 Roaming- LoRaWAN end devices can perform seamless handovers from one network to
another.
 Low cost - Minimal infrastructure, low-cost end nodes and open source software.
 Certification program- The LoRa Alliance certification program certifies end devices and
provides end-users with confidence that the devices are reliable and compliant with the
LoRaWAN specification.
 Ecosystem- LoRaWAN has a very large ecosystem of device makers, gateway makers, antenna
makers, network service providers, and application developers.

LoRaWAN use cases 


Here are a few great LoRaWAN use cases provided by Semtech, to give you some insight into how
LoRaWAN can be applied:

 Vaccine cold chain monitoring - LoRaWAN sensors are used to ensure vaccines are kept at
appropriate temperatures in transit.
 Water conservation- Identification and faster repair of leaks in a city’s water network.
 Food safety- Temperature monitoring ensures food quality maintenance.
 Smart waste bins - Waste bin level alerts sent to staff optimize the pickup schedule.
 Smart bikes- Bike trackers track bikes in remote areas and dense buildings.
 Airport tracking - GPS-free tracking monitors vehicles, personnel, and luggage.
 Efficient workspaces - Room occupancy, temperature, energy usage and parking availability
monitoring.
 Cattle health - Sensors monitor cattle health, detect diseases and forecast calves delivery time.
 LoRa in space - Satellites to provide LoRaWAN-based coverage worldwide.

What are Xbee Modules?


By  Aidan, updated on 08 November 2018
Wi-Fi, as we know it, is a form of wireless communication based on the 802.11 standards as
outlined by the IEEE (the Institute of Electrical and Electronics Engineers). If you're paying
attention to it, you'll notice an appendage to this standard that is a single letter suffix (a, b, g, n).
These letters correlate to internationally reserved frequency ranges of the radio spectrum for
wireless communication, usually in the 2.4GHz and 5GHz frequencies. Phones, tablets, Personal
Computers and the rest all rely on this standard of wireless communication to access local area
networks and establish a connection to the internet; these devices connect to a network via a
wireless hotspot that provides internet access (known as a star network topology).
And it works well; you'd be hard-pressed to find a modern day home/business without a wireless
hotspot today. It's the standard method that comes to mind when you think of Wi-Fi. There are a
couple of other options that aren't the generic 802.11 alphabet soup which can be used for wireless
transmission of data, Xbee/Zigbee being two of the popular ones.

XBee and Zigbee


There are some differences between the similar looking names to be aware of. First off, Xbee refers
to a family of devices from Digi that share form factor, host interface and a group of protocols you
can select from (Zigbee being one of these). Zigbee, on the other hand, is a mesh networking
protocol built upon the 802.15.4 IEEE standard. So Zigbee protocol dictates how devices can
communicate wirelessly and are one of the supported protocols of the Xbee products. Zigbee also
has their line of goods too; however, they only support Zigbee communication protocols.
With the naming difference out of the way, let's look at why we would set up a network of XBee
modules over a standard Wi-Fi network. Wi-Fi is the standard for wireless Internet connection
because of it's high data transfer rate (54MBits/s); the real downside being it has a high power
consumption. If you only wanted to have a collection of micro-controllers attached to a network to
share sensor data or something similar, standard Wi-Fi might be too thirsty for your project. Xbee
is a lot more reasonable; it's got a much lower power consumption (25% of standard Wi-Fi) and
similarly a lower data transfer (250kbit/s). Additionally, the ability to create a mesh network of
XBee devices means each device can transmit and receive data through itself, acting as a node for
the network. We call this network topology a mesh, and it's an entirely different take on a network
system. If you were looking to create your Smart House system, mesh networking could offer less
power consumption and greater range than the standard wi-fi s

etup we typically
see.

Sparkfun are our go-to when it comes to Xbee Modules/ZIgBee Mesh devices, we have their entire
range of Series 1, 2 and Pro boards available. 
When it comes to selecting a Xbee device for your network, there are a couple of compatibility
options to be mindful of, in particular, the series of the module you use. There are Series 1 and
Series 2 devices available from Digi. Series 1 devices are the simple to use connections that are
configured to operate in a peer-to-peer manner, meaning they can essentially replace an existing
serial communication with the wireless connectivity offered by Xbee. Series 2, however, are not
pre-configured and open up that configuration to you, allowing you to not only access the peer-to-
peer configuration of series one but also branch into all of the other networking configurations you
might be wanting to take advantage of. If you are just starting out with Xbee, it's more that fine for
you to stick with the Series 1 modules. They will work out of the box and be an excellent
introduction to the system. Series 2 modules have their place too, but if you're thinking you will
need a Series 2 module it is unlikely you would be reading this article. They require a lot more
configuration than the Series 1 modules. There is one other main option you have with Xbee, that
being the 900 series. Operating on a frequency of 900MHz gives you a much greater range (up to
15 miles with the Pro 900 series boards and a high-gain antenna in outdoor environments!) but
maintains all of the features of the other Xbee modules.

If you are
looking to take advantage of the outdoor range options with the Xbee modules, the antenna plays
an important role.
There are a few options when choosing your antenna:
1. The chip antenna is the standard option for your XBee module. It has the 'worst' performance
of all the options in regards to range and sensitivity, but it requires no extra space in your
project. For a typical series one board, a chip antenna will get you an outdoor range of 140m.
2. The whip antenna is an additional antenna option that can connect to the SMA connector on
your Xbee module. For the same module used in the first example, the addition of the whip
antenna will increase the range to 258m in outdoor environments. The indoor performance will
not change with different antenna options as the penetration of the signal is a function of the
frequency, not the antenna that transmits it.
3. The PCB antenna is another option that you can choose, where the antenna is built into the
traces of the PCB of the module. Its performance is within 5% of the whip antenna option in
outdoor applications.
If you want to attach an antenna to your modules, there is usually a U.FL or RPSMA connection on
board that you can achieve that connection with too. Essentially there are plenty of options for an
antenna with your boards; be sure to check with local radio communication guidelines and your
project requirements to find something that works well for you.
The Pro Boards are the premium category of the boards offered by Digi. They offer slightly greater
powered modules (increasing the range) for a higher price point. It's a similar story to the Series 2
board here, stick with the regular models unless there's a pressing need for the change in range.

What is MQTT?
MQTT stands for Message Queuing Telemetry Transport. MQTT is a simple messaging
protocol, designed for constrained devices with low bandwidth. So, it’s the perfect
solution to exchange data between multiple IoT devices.
MQTT communication works as a publish and subscribe system.
Devices publish messages on a specific topic. All devices that are subscribed to that
topic receive the message.
Its main applications include sending messages to control outputs, read and publish data
from sensor nodes and much more.

MQTT – Publish/Subscribe
The first concept is the publish and subscribe system. In a publish and subscribe
system, a device can publish a message on a topic, or it can be subscribed to a
particular topic to receive messages

 For example Device 1 publishes on a topic.


 Device 2 is subscribed to the same topic that device 1 is publishing in.
 So, device 2 receives the message.

MQTT – Messages
Messages are the information that you want to exchange between your devices. It can
be a message like a command or data like sensor readings, for example.

MQTT – Topics
Another important concept is the topics. Topics are the way you register interest for
incoming messages or how you specify where you want to publish the message.
Topics are represented with strings separated by a forward slash. Each forward slash
indicates a topic level. Here’s an example of how you would create a topic for a lamp in
your home office:
1. A device publishes “on” and “off” messages on the home/office/lamp topic.
2. You have a device that controls a lamp (it can be an ESP32, ESP8266, or any
other board or device). The ESP32 that controls your lamp, is subscribed to that
same topic: home/office/lamp.
3. So, when a new message is published on that topic, the ESP32 receives the “on”
or “off” messages and turns the lamp on or off.
The device that is publishing the messages can be an ESP32, an ESP8266, or an Home
Automation controller platform with MQTT support like Node-RED, Home Assistant,
Domoticz, or OpenHAB, for example.

What is LAN (Local Area Network)


LAN is basically a Data Communication Network. In this type of Network, several
computers and their peripherals like disc storage devices, printers are connected to a
single high speed data line within a limited area. Local Area Network is usually a privately
owned network. In LAN, data is divided and transmitted in the form of packets and
regenerated back by the receiving computer.

It provides high data rates extending from 10-100 Mbps and up. Latest LAN’s can provide
data rate up to 10 Gbps. The coverage area is less than 10 kms. Like any other Networks,
LAN also requires Hardware and Software components. Hardware consists of transmission
medium and connecting devices like Transceivers, Bridges, Switches, Repeaters etc.
Software has Application Programs which includes protocols defined by IEEE Standard. Fig.
2 shows schematic diagram of Ethernet LAN.
Fig. 2 – Schematic Diagram of Ethernet Local Area Network

Types of Local Area Network (LAN)


LAN’s can be implemented using:

 Ethernet LAN (Wired connection)


 WLAN (Wireless)

Ethernet LAN (Wired connection)


Ethernet LAN uses Ethernet cables to connect the devices in a network. In this type of
connection, the network installation is wired and the Switches and Routers are configured
using the network settings. Standard Internet Protocol is set, that allows the internet to
run on different devices within the network.
Fig. 3 – Ethernet Local Area Network

WLAN (Wireless Local Area Network)


WLAN uses Radio waves as the means of communication. It does not require cables to
connect the devices. The advantage of WLAN over LAN is the increased security it offers.
The users can access the internet without wired connection (wireless) if they are within the
range of the Router. With the help of WLAN connection, many devices can be connected
simultaneously, provided they all are within the range of the Router.

Fig. 4 – Wireless Local Area Network (WLAN)

LAN (Local Area Network) Topology


Topology is defined as the pattern of interconnection between the nodes of the network.
The three basic topologies of LAN are:

 Star Topology
 Ring Topology
 Bus Topology
Star Topology
In this network, all the nodes are connected to Central Node. The devices are not
connected to each other and transmits the messages to the Central Node. The central
node is responsible for transmitting the message to the required destination. It is the most
widely used topology for LAN’s.

Ring Topology
In this network, the nodes are interconnected to make a closed loop. Each node
communicates with the nodes on its either side with the help of Token (information
passing). The nodes with Token are allowed to transmit data. This topology eliminates the
connection of nodes with the central node i.e. there is no need of Network Server to
control other devices.

Bus Topology
In this network, all the nodes including computers and servers are connected to a single
cable termed as Bus. This network is easier compared to other networks and is
economical. Source node transmits a signal which is broadcast to all the other nodes via
Bus cable. Though the message is broadcast, the intended recipient receives the signal.
The recipient can accept the signal if its MAC Address or IP Address matches and data
transmission occurs in a single direction.

Fig. 5 – (a) Star Topology (b) Ring Topology (c) Bus Topology

a) Mesh Topology :
In a mesh topology, every device is connected to another device via a particular channel. 
 
Figure 1: Every device is connected with another via dedicated channels. These channels
are known as links. 
 
 Suppose, N number of devices are connected with each other in a mesh topology, the
total number of ports that are required by each device is N-1. In Figure 1, there are 5
devices connected to each other, hence the total number of ports required by each
device is 4. Total number of ports required=N*(N-1).
 Suppose, N number of devices are connected with each other in a mesh topology, then
the total number of dedicated links required to connect them is NC2 i.e. N(N-1)/2. In
Figure 1, there are 5 devices connected to each other, hence the total number of links
required is 5*4/2 = 10.
Advantages of this topology : 
 It is robust.
 The fault is diagnosed easily. Data is reliable because data is transferred among the
devices through dedicated channels or links.
 Provides security and privacy.
Problems with this topology : 
 Installation and configuration are difficult.
 The cost of cables is high as bulk wiring is required, hence suitable for less number of
devices.
 The cost of maintenance is high.

How does LAN (Local Area Network) Work


To understand how LAN works, consider Fig. 6, which shows the 7- Layers of OSI Model. It
is necessary to know the three lower levels of OSI Model i.e.

 Physical Layer
 Data Link Layer
 Network Layer
Fig. 6 – Seven Layers of OSI Model

Physical Layer
The Physical Layer transmits raw data bits over communication lines. It deals with
establishing physical circuit between devices. Physical Layer protocols and standards are
responsible for type of modulation to be used for transmitting digital data over
analog transmission lines. It accounts for the components of network like Multiplexers,
Repeaters, Modems etc.

Data Link Layer


The Data Link Layer is responsible for transferring data over the communication channel
provided by the Physical Layer. This layer breaks the data into data frames, transmits the
frames sequentially over the channel. Error detection and correction is done and the data
is transmitted to Network Layer.

Network Layer
The Network Layer helps in routing the data across the network from source node to
receiving node. This Layer provides interface between a host and the network. Based on
Topology used, routing of packets takes place to the receiving device where the conversion
of data occurs and the original data is obtained.

Read More About OSI Model, Characteristics of Seven Layers, Why to Use it &
Limitations
Applications of LAN (Local Area Network)
The applications include:

 LAN is used for school environment, offices, hospitals etc as it allows sharing of
resources like sharing data, scanners, printing and internet.
 LAN serves users at home to access internet.
 LAN’s are widely used in manufacturing industries where a central server coordinates
the activities of other machines.
 High speed LANs are typically used to connect many slower networks together.

Advantages of LAN (Local Area Network)


The advantages of LAN are:

 Provides high-bandwidth communication.


 Transmission medium is inexpensive.
 Bandwidth is utilized effectively.
 Maintenance is easy.

Disadvantages of LAN (Local Area Network)


The disadvantages of LAN are:

 Speed reduces as it includes sharing of resources.


 Less Secure.
 Requires skilled technicians to setup the network.
 Covers Limited area.

ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and dual-


mode Bluetooth. The ESP32 series employs either a Tensilica Xtensa LX6 microprocessor in both dual-core
and single-core variations, Xtensa LX7 dual-core microprocessor or a single-core RISC-V microprocessor and
includes built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power-
management modules. ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese
company, and is manufactured by TSMC using their 40 nm process.[2] It is a successor to
the ESP8266 microcontroller.
Robust Design
ESP32 is capable of functioning reliably in industrial environments, with an operating temperature
ranging from –40°C to +125°C. Powered by advanced calibration circuitries, ESP32 can
dynamically remove external circuit imperfections and adapt to changes in external conditions.
 

Ultra-Low Power Consumption


Engineered for mobile devices, wearable electronics and IoT applications, ESP32 achieves ultra-
low power consumption with a combination of several types of proprietary software. ESP32 also
includes state-of-the-art features, such as fine-grained clock gating, various power modes and
dynamic power scaling.
 

High Level of Integration


ESP32 is highly-integrated with in-built antenna switches, RF balun, power amplifier, low-noise
receive amplifier, filters, and power management modules. ESP32 adds priceless functionality and
versatility to your applications with minimal Printed Circuit Board (PCB) requirements.
 
 

Hybrid Wi-Fi & Bluetooth Chip


ESP32 can perform as a complete standalone system or as a slave device to a host MCU, reducing
communication stack overhead on the main application processor. ESP32 can interface with other
systems to provide Wi-Fi and Bluetooth functionality through its SPI / SDIO or I2C / UART
interfaces.
Z-Wave is a wireless communication protocol used primarily in smart home networks,
allowing smart devices to connect and exchange control commands and data with each
other.

With two-way communication through mesh networking and message acknowledgment,


the Z-Wave protocol helps alleviate power issues and brings low-cost wireless
connectivity to home automation, offering a lower-power alternative to Wi-Fi and a
longer-range alternative to Bluetooth.

How Z-Wave works


A Z-Wave network consists of internet of things (IoT) devices and a primary controller, also
known as a smart home hub, which is the only device in a Z-Wave network that is
usually connected to the internet. When a Z-Wave hub receives a command from a smart home
application on a user's smartphone, tablet or computer, it routes the command to its destination
device across networks of up to 232 devices -- including the hub.

Using source-routed mesh network technology, Z-Wave signals can hop through other Z-Wave
devices to reach the device a user intends to control. Each Z-Wave network accommodates a
maximum of four hops.

The Z-Wave protocol operates on the low-frequency 908.42 band in the U.S. and the 868.42 MHz
band in Europe. Though interference with other home electronics, such as cordless phones, is
possible, the protocol avoids interference with the 2.4 GHz band where Wi-Fi and Bluetooth
operate.

Z-Wave offers transmission rates of small data packets using throughput rates of 9.6 kbps, 40
kbps or 100 kbps. The Z-Wave PHY and MAC layers are based on the ITU-T G.9959 global
radio standard, and the protocol uses GFSK modulation and Manchester encoding. It also
includes AES 128 encryption, IPv6 and multichannel operation.

In terms of identification and authorization, each Z-Wave network is identified by a network ID


and each end device is identified with a node ID. The unique network ID prevents, for example,
one Z-Wave-equipped house from controlling devices in another similarly equipped house.

Communication between devices ranges from 98 to 328 feet; the 500 Series has a range of 130
feet and the 700 Series 328 feet. Because walls and other dense building materials limit the range,
the general deployment best practice is to place Z-Wave devices 50 feet or fewer apart for
maximum signal strength.

Using a Z-Wave repeater -- an additional Z-Wave device between other devices -- or using line-
powered -- not battery-powered -- devices in the network can also strengthen the signal and help
it reach its destination. The maximum range with four hops is estimated to be 600 feet.

In regards to battery life, some 700 Series Z-Wave devices can last up to 10 years on a coin cell
battery, while many other battery-powered devices last a year or longer.

All Z-Wave technology is backward-compatible.

To bear the Z-Wave branding, smart home products must become Z-Wave certified. This
involves meeting a number of requirements and, most importantly, being interoperable with all
other Z-Wave-certified devices.

Z-Wave vs. Zigbee


Z-Wave and Zigbee are two of the biggest names in smart home communication
protocols. Both use short-range, low-power radio signals and mesh network
technologies, and both are secured using AES. However, there are some notable
differences.

Z-Wave operates on the low-frequency 908.42 band while the Zigbee protocol operates
at 2.4 GHz. While the higher frequency allows Zigbee to transmit more data faster -- 40-
250 kbps to Z-Wave's 9.6 to 100 kbps -- it reduces the range of the signal. Z-Wave's
range of 98 feet is greater than Zigbee's 32-foot range. As an open standard run by the
Zigbee Alliance, Zigbee chips are available from multiple vendors, while Z-Wave chips
are only available from Silicon Labs.

Zigbee is often perceived as more complex due to its multiple protocols; for example, it
offers specifications for smart energy, healthcare, gateways and more -- which
historically do not communicate well together. However, the release of Zigbee 3.0 aims
to address this issue and address the complexity.
A Zigbee network, which doesn't have a maximum number of allowed hops, can support
more than 65,000 devices, while a Z-Wave network, limited to four hops, supports a
maximum of 232 devices.

Often considered an either/or situation, many smart home hubs today, including
Samsung SmartThings and Wink Hub, support both standards, allowing Zigbee and Z-
Wave devices to communicate with each other, so there is no need to choose one over
the other.

I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol


incorporated into devices for serial communication. It was originally designed by Philips
Semiconductor in 1982. Recently, it is a widely used protocol for short-distance
communication. It is also known as Two Wired Interface(TWI).
Working of I2C Communication Protocol :
It uses only 2 bi-directional open-drain lines for data communication called SDA and SCL.
Both these lines are pulled high.
Serial Data (SDA) – Transfer of data takes place through this pin.
Serial Clock (SCL) – It carries the clock signal.
I2C operates in 2 modes –
 Master mode
 Slave mode
Each data bit transferred on SDA line is synchronized by a high to the low pulse of each
clock on the SCL line.

According to I2C protocols, the data line can not change when the clock line is high, it can
change only when the clock line is low. The 2 lines are open drain, hence a pull-up resistor
is required so that the lines are high since the devices on the I2C bus are active low. The
data is transmitted in the form of packets which comprises 9 bits. The sequence of these
bits are –
1. Start Condition – 1 bit
2. Slave Address – 8 bit
3. Acknowledge – 1 bit
Advantages :
 Can be configured in multi-master mode.
 Complexity is reduced because it uses only 2 bi-directional lines (unlike SPI
Communication).
 Cost-efficient.
 It uses ACK/NACK feature due to which it has improved error handling capabilities.
Limitations :
 Slower speed.
 Half-duplex communication is used in the I2C communication protocol.
Serial peripheral interface (SPI) is one of the most widely used interfaces between microcontroller
and peripheral ICs such as sensors, ADCs, DACs, shift registers, SRAM, and others. This article
provides a brief description of the SPI interface followed by an introduction to Analog Devices’ SPI
enabled switches and muxes, and how they help reduce the number of digital GPIOs in system
board design.

SPI is a synchronous, full duplex master-slave-based interface. The data from the master or the
slave is synchronized on the rising or falling clock edge. Both master and slave can transmit data at
the same time. The SPI interface can be either 3-wire or 4-wire. This article focuses on the popular
4-wire SPI interface.

Interface

Figure 1. SPI configuration with master and a slave.

4-wire SPI devices have four signals:

 Clock (SPI CLK, SCLK)


 Chip select (CS)
 Master out, slave in (MOSI)
 Master in, slave out (MISO)

The device that generates the clock signal is called the master. Data transmitted between the
master and the slave is synchronized to the clock generated by the master. SPI devices support
much higher clock frequencies compared to I 2C interfaces. Users should consult the product data
sheet for the clock frequency specification of the SPI interface.

SPI interfaces can have only one master and can have one or multiple slaves. Figure 1 shows the
SPI connection between the master and the slave.

The chip select signal from the master is used to select the slave. This is normally an active low
signal and is pulled high to disconnect the slave from the SPI bus. When multiple slaves are used,
an individual chip select signal for each slave is required from the master. In this article, the chip
select signal is always an active low signal.

MOSI and MISO are the data lines. MOSI transmits data from the master to the slave and MISO
transmits data from the slave to the master.

Data Transmission
To begin SPI communication, the master must send the clock signal and select the slave by
enabling the CS signal. Usually chip select is an active low signal; hence, the master must send a
logic 0 on this signal to select the slave. SPI is a full-duplex interface; both master and slave can
send data at the same time via the MOSI and MISO lines respectively. During SPI communication,
the data is simultaneously transmitted (shifted out serially onto the MOSI/SDO bus) and received
(the data on the bus (MISO/SDI) is sampled or read in). The serial clock edge synchronizes the
shifting and sampling of the data. The SPI interface provides the user with flexibility to select the
rising or falling edge of the clock to sample and/or shift the data. Please refer to the device data
sheet to determine the number of data bits transmitted using the SPI interface.

Clock Polarity and Clock Phase


In SPI, the master can select the clock polarity and clock phase. The CPOL bit sets the polarity of
the clock signal during the idle state. The idle state is defined as the period when CS is high and
transitioning to low at the start of the transmission and when CS is low and transitioning to high at
the end of the transmission. The CPHA bit selects the clock phase. Depending on the CPHA bit, the
rising or falling clock edge is used to sample and/or shift the data. The master must select the clock
polarity and clock phase, as per the requirement of the slave. Depending on the CPOL and CPHA
bit selection, four SPI modes are available. Table 1 shows the four SPI modes.

 SEP 2018
VOL 52

Introduction to SPI Interface


by Piyu Dhaker Download PDF

Serial peripheral interface (SPI) is one of the most widely used interfaces between microcontroller and
peripheral ICs such as sensors, ADCs, DACs, shift registers, SRAM, and others. This article provides a brief
description of the SPI interface followed by an introduction to Analog Devices’ SPI enabled switches and
muxes, and how they help reduce the number of digital GPIOs in system board design.

SPI is a synchronous, full duplex master-slave-based interface. The data from the master or the slave is
synchronized on the rising or falling clock edge. Both master and slave can transmit data at the same time.
The SPI interface can be either 3-wire or 4-wire. This article focuses on the popular 4-wire SPI interface.

Interface

Figure 1. SPI configuration with master and a slave.

4-wire SPI devices have four signals:

 Clock (SPI CLK, SCLK)


 Chip select (CS)
 Master out, slave in (MOSI)
 Master in, slave out (MISO)
The device that generates the clock signal is called the master. Data transmitted between the master and the
slave is synchronized to the clock generated by the master. SPI devices support much higher clock
frequencies compared to I2C interfaces. Users should consult the product data sheet for the clock frequency
specification of the SPI interface.

SPI interfaces can have only one master and can have one or multiple slaves. Figure 1 shows the SPI
connection between the master and the slave.

The chip select signal from the master is used to select the slave. This is normally an active low signal and is
pulled high to disconnect the slave from the SPI bus. When multiple slaves are used, an individual chip select
signal for each slave is required from the master. In this article, the chip select signal is always an active low
signal.

MOSI and MISO are the data lines. MOSI transmits data from the master to the slave and MISO transmits
data from the slave to the master.

Data Transmission
To begin SPI communication, the master must send the clock signal and select the slave by enabling the CS
signal. Usually chip select is an active low signal; hence, the master must send a logic 0 on this signal to
select the slave. SPI is a full-duplex interface; both master and slave can send data at the same time via the
MOSI and MISO lines respectively. During SPI communication, the data is simultaneously transmitted
(shifted out serially onto the MOSI/SDO bus) and received (the data on the bus (MISO/SDI) is sampled or
read in). The serial clock edge synchronizes the shifting and sampling of the data. The SPI interface provides
the user with flexibility to select the rising or falling edge of the clock to sample and/or shift the data. Please
refer to the device data sheet to determine the number of data bits transmitted using the SPI interface.

Clock Polarity and Clock Phase


In SPI, the master can select the clock polarity and clock phase. The CPOL bit sets the polarity of the clock
signal during the idle state. The idle state is defined as the period when CS is high and transitioning to low at
the start of the transmission and when CS is low and transitioning to high at the end of the transmission. The
CPHA bit selects the clock phase. Depending on the CPHA bit, the rising or falling clock edge is used to
sample and/or shift the data. The master must select the clock polarity and clock phase, as per the requirement
of the slave. Depending on the CPOL and CPHA bit selection, four SPI modes are available. Table 1 shows
the four SPI modes.

Table 1. SPI Modes with CPOL and CPHA


Clock
Clock Phase Used to Sample
SPI Mode CPOL CPHA Polarity in
and/or Shift the Data
Idle State

Data sampled on rising edge and


0 0 0 Logic low
shifted out on the falling edge

Data sampled on the falling edge


1 0 1 Logic low
and shifted out on the rising edge

Data sampled on the falling edge


2 1 1 Logic high
and shifted out on the rising edge

Data sampled on the rising edge


3 1 0 Logic high
and shifted out on the falling edge

Figure 2 through Figure 5 show an example of communication in four SPI modes. In these examples, the data
is shown on the MOSI and MISO line. The start and end of transmission is indicated by the dotted green line,
the sampling edge is indicated in orange, and the shifting edge is indicated in blue. Please note these figures
are for illustration purpose only. For successful SPI communications, users must refer to the product data
sheet and ensure that the timing specifications for the part are met.
Figure 2. SPI Mode 0, CPOL = 0, CPHA = 0: CLK idle state = low, data sampled on rising edge and shifted
on falling edge.

Figure 3 shows the timing diagram for SPI Mode 1. In this mode, clock polarity is 0, which indicates that the
idle state of the clock signal is low. The clock phase in this mode is 1, which indicates that the data is sampled
on the falling edge (shown by the orange dotted line) and the data is shifted on the rising edge (shown by the
dotted blue line) of the clock signal.
Figure 3. SPI Mode 1, CPOL = 0, CPHA = 1: CLK idle state = low, data sampled on the falling edge and
shifted on the rising edge.

Figure 4 shows the timing diagram for SPI Mode 2. In this mode, the clock polarity is 1, which indicates that
the idle state of the clock signal is high. The clock phase in this mode is 1, which indicates that the data is
sampled on the falling edge (shown by the orange dotted line) and the data is shifted on the rising edge
(shown by the dotted blue line) of the clock signal.
Figure 4. SPI Mode 2, CPOL = 1, CPHA = 1: CLK idle state = high, data sampled on the falling edge and
shifted on the rising edge.

Figure 5 shows the timing diagram for SPI Mode 3. In this mode, the clock polarity is 1, which indicates that
the idle state of the clock signal is high. The clock phase in this mode is 0, which indicates that the data is
sampled on the rising edge (shown by the orange dotted line) and the data is shifted on the falling edge
(shown by the dotted blue line) of the clock signal.
Figure 5. SPI Mode 3, CPOL = 1, CPHA = 0: CLK idle state = high, data sampled on the rising edge and
shifted on the falling edge.
Universal asynchronous receiver-transmitter (UART) is one
of the simplest and oldest forms of device-to-device digital
communication. You can find UART devices as a part of
integrated circuits (ICs) or as individual components. UARTs
communicate between two separate nodes using a pair of
wires and a common ground.
UART Protocol Guide
As a “universal” setup, we can configure UART to work with many different types of serial protocols.
UART was adapted into single-chip units in the early 1970s, starting with Western Digital’s WD1402A.

In a UART communication scheme:


1. One chip’s Tx (transmit) pin connects directly to the other’s Rx (receive) pin and vice versa. Commonly,
the transmission will take place at 3.3 or 5V. UART is a single-master, single-slave protocol, where one
device is set up to communicate with only one partner.

2. Data travels to and from a UART in parallel to the controlling device (e.g., a CPU).

3. When sending on the Tx pin, the first UART translates this parallel information into serial and transmits
it to the receiving counterpart.

4. The second UART receives this data on its Rx pin and transforms it back into parallel to communicate
with its controlling device.

UARTs transmit data serially, in one of three modes:

- Full duplex: Simultaneous communication to and from each master and slave

- Half duplex: Data flows in one direction at a time

- Simplex: One-way communication only

Data transmission takes place in the form of data packets, beginning with a start bit, where the ordinarily
high line is pulled to ground. After the start bit, five to nine data bits transmit in what is known as the
packet’s data frame, followed by an optional parity bit to verify proper data transmission. Finally, one or
more stop bits are transmitted where the line is set to high. This ends a packet.

As an asynchronous protocol— no clock line regulates data transmission speed— users must set both
devices to communicate at the same speed. This speed is known as the baud rate, expressed in bits per
second, or bps. Transmission speeds vary dramatically, from the typical 9600 baud setting to 115200 and
beyond.

While something of an “ancient” protocol, and one that can only communicate between a single master
and slave, UART is well known, easy to set up, and extremely versatile. As such, you’re likely to
encounter this system when working with microcontroller projects. UARTs may be a part of systems that
you use every day, whether you realize it or not.

ADVANTAGES
 Only uses two wires

 No clock signal is necessary

 Has a parity bit to allow for error checking

 The structure of the data packet can be changed as long as both sides are set up for it

 Well documented and widely used method

DISADVANTAGES
 The size of the data frame is limited to a maximum of 9 bits

 Doesn’t support multiple slave or multiple master systems

 The baud rates of each UART must be within 10% of each other


Continue on to part three of this series, Basics of the I2C Communication Protocol to learn about
another way electronic devices communicate. Or if you haven’t already, check out part one, Basics of
the SPI Communication Protocol.

You might also like