Arduino Library
The Library is considered as the advanced feature, which extends the capabilities
of the Arduino IDE. It means that the libraries provide extra functionality to the
programming platform of Arduino.
The libraries in Arduino are written in C
or C++
(.cpp). These libraries allow us to manipulate data and work with the hardware.
To implement any Library in the Arduino IDE
, go to the Sketch -> Import Library.
There are several libraries available for download. We can also create our own
library.
Let's discuss some of the libraries.
Standard Libraries
The standard libraries are listed below:
EEPROM
It stands for Electronic Erasable Programmable Read Only Memory. The
EEPROM is associated with the microcontroller present on the AVR or Arduino
Boards
. The EEPROM library allows us to read the bytes stored in the memory when the
power of the board is off.
The size of EEPROM varies in different boards, such as 1KB or 1024 bytes on the
ATmega328P. It can also be of 4KB or 4096 bytes on the Microcontroller
ATmega2560, etc.
The library is declared as:
#include <EEPROM.h>
For example, EEPROM Read, EEPROM Clear, EEPROM Write, EEPROM Get,
EEPROM Update, EEPROM Put, EEPROM Iteration, etc.
Ethernet Library
The Ethernet library works with the Arduino Ethernet shield and other related
devices. The Ethernet library allows us to connect the Arduino board to the
Internet.
The SPI bus acts as an intermediate between the board and the shield.
The associated library is:
#include <Ethernet.h>
#include <SPI.h>
For example, TelnetClient, WebServer, WebClientRepeating, WebClient,
ChatServer, DnsWebClient, UdpNtpClient, UdpSendReceiveString, etc.
Firmata Library
For the programming environment, we can create custom firmware without
producing our own objects and protocols.
It is used to implement the firmware protocol, which communicates with the
software on the host computer.
The associated library is:
#include <Firmata.h>
GSM Library
The GSM library exists on the IDE version 1.0.4 and up.
The GSM library allows us to perform the operations on the Arduino board similar
to the GSM phone, such as internet connection, send and receive messages, and to
place voice calls.
The library is declared as:
#include <GSM.h>
Liquid Crystal Library
It is a library that permits Arduino
to communicate with LCDs, which are based on a compatible chipset called
Hitachi HD44780. Such chipsets are found on most types of text-based LCDs. It
works with either an 8-bit mode or 4-bit mode. Here, the bit mode signifies the
data lines in addition to the enable, rs, and rw control lines (optional).
The library is declared as
#include <LiquidCrystal.h>
The examples are Hello World, Cursor, Blink, etc.
SD Library
It allows writing to or reading from SD cards. For example, Arduino Ethernet
Shield. The file names include the paths separated by the forward slashes, which
are passed to the SD Library. But, SPI is used for the communication between the
SD card and the Arduino.
The library is declared as:
#include <SPI.h>
#include <SD.h>
The examples are Dump files, List Files, Read Write, etc.
Servo Library
The Servo library permits Arduino to work with servo motors. It allows controlling
the integrated shaft and gears. We can also position shaft at different angles
between 0 and 180 degrees. The servo library on Arduino boards can support upto
12 motors, while on Arduino Mega board
, it can support upto 48 motors.
The library is declared as:
#include <Servo.h>
SPI Library
The SPI (Serial Peripheral Interface) is a serial data protocol.
The microcontrollers
use the serial protocol to communicate over short distances with one or more
peripheral devices quickly.
The required connection of SPI is a full-duplex that allows devices to
simultaneously sent and receive data.
The library is declared as:
#include <SPI.h>
The examples are Dump files, List Files, Read Write, etc.
Stepper Library
The Stepper library in Arduino permits to control of bipolar or unipolar stepper
motors.
The library is declared as
#include <Stepper.h>
The Stepper includes stepper speed control, stepper one revolution, etc.
Software Serial Library
The Software Serial Library permits serial communication over digital Input/output
pins. The 0 and 1 pins are inbuilt on Arduino for the serial interface. We can
include multiple serial ports in our code that can operate with speed upto 115200
bps (bits per second).
The library is declared as
#include <SoftwareSerial.h>
TFT LCD Library
The TFT LCD
library is included in the IDE version 1.0.5 and later. It allows the Arduino to
communicate with the TFT
LCD screen. It further helps to draw images, shapes, lines, and text to the screen.
The SD card slot present on the onboard screen can be used by implementing the
SD library.
The TFT library for communication depends on the SPI library with the SD card
and screen.
The library is declared as
#include <SPI.h>
#include <TFT.h>
WiFi Library
The WiFi library permits Arduino to establish a connection with the internet. It can
either be a server to receive the incoming connections or a client to perform
outgoing connections.
The personal encryptions supported by the WiFi
library are WPA2 and WEP except for WPA2 Enterprise. Arduino uses the SPI bus
to communicate with the WiFi shield.
The library is declared as
#include <WiFi.h>
The examples include WiFiWebClient, WiFiWebServer, etc.
Audio Library
The Audio library is compatible with the Arduino Due board
only. It enables the board to playback .wav files from the specific storage devices,
such as the SD card.
It plays sounds by using the DAC0 and DAC1 pins.
The library is declared as:
#include <Audio.h>
The example is a Simple Audio Player.
Audio Zero Library
It enables the board (Arduino Zero, MKR1000, and MKRZero) to playback .wav
files from the storage devices, such as the SD card.
Arduino Zero and MKR1000 board play sound by using the DAC0 pin.
The library is declared as
#include <AudioZero.h>
The example is the Simple Audio Player Zero.
Arduino Sound Library
The Arduino Sound Library permits the board to analyze and play audio data,
which is provided by Arduino on SAMD21 based board using the I2S bus. The
SAMD21 based boards are Arduino Zero, MKR1000, MKRZero, or Genuino Zero.
The library is declared as:
#include <AudioSound.h>
The examples include WavePlayBack, ClapDetector, WhistleDetector, etc.
Now, let's discuss the process to install the library in Arduino.
How to install a library in Arduino?
The steps are listed below:
Arduino Library Manager
o We need to open the library manager to install a new library in Arduino.
Click on Sketch -> Include Library -> Manage Libraries, as shown
below:
o A dialog box containing various libraries will appear, as shown below:
o A list of libraries will appear that are ready to install. We need to select the
specific library -> select the version -> click on Install button, as shown
below:
Sometimes there is only one version available for download. In such case, the
dropbox of the version will not appear. Hence, it's normal.
We need to wait for the library to download. The downloading will depend on the
connection speed.
The 'INSTALLED' tag will appear in front of the library that is already installed on
our computer.
Importing a .zip Library
If we want to add our own library, we can select the desired folder from our
computer. The particular zip file containing the library can be imported in the
Arduino.
It is shown below:
We can also recheck from the option Sketch -> Include library to see that the
added libraries are present or not on the list.
We are not required to unzip the downloaded library. The file will remain in
the .zip format.
We can download the 3rd party libraries starting with the Arduino IDE version
1.0.5.
Top Applications of IoT in the World
The most important characteristic of humans is that we can work with each other
as a team and gain knowledge from each other. What if this was true for machines
as well? What if they could interact with each other and share information and
data. That would lead to a truly connected world! And that is the central concept of
the Internet of Things. This concept just means a connected network of various
devices that can collect data and share it with each other to obtain meaningful
insights from the data. There are various applications of IoT in the modern world
and these are so diverse that you cannot imagine.
There are endless possibilities for having an interconnected web of “things” that
can interact with each other over the internet. IoT can be used for all types of
applications ranging from connecting all the devices in your house to create a
smart home or even connecting all the government and civic services in a city to
create a smart city! Who knows, we may even have a smart world one day!
So let’s see all these applications of IoT in different facets and industries of the
world.
1. Smart Agriculture
Food is an integral part of life without which we cannot survive. However, it is an
unfortunate fact that a lot of food is wasted in developed countries like America
while people starve in poorer countries like Chad, Sudan, etc. One way to feed
everyone is better agricultural practices which can be enhanced using IoT. This can
be done by first collecting data for a farm such as soil quality, sunlight levels, seed
type, rainfall density from various sources like farm sensors, satellites, local
weather stations, etc. and then using this data with Machine Learning and IoT to
create custom recommendations for each farm that will optimize the planting
procedure, irrigation levels required, fertilizer amount, etc. All this will result in
better yield or crops with a focus on reducing world hunger in the future. This is
done very efficiently by SunCulture, which is an initiative by Microsoft AI for
Earth.
2. Smart Vehicles
Smart vehicles or self-driving cars as they can be called are pretty dependent on
IoT. These cars have a lot of features that are integrated with each other and need
to communicate such as the sensors that handle navigation, various antennas,
controls for speeding or slowing down, etc. Here the Internet of Things technology
is critical especially in the sense that self-driving cars need to be extremely
accurate and all the parts need to communicate with each other in milliseconds on
the road. Tesla Cars are quite popular and working on their self-driving cars. Tesla
Motors’ cars use the latest advancements in Artificial Intelligence and the Internet
of Things. And they are quite popular as well!!! Tesla Model 3 was the most sold
plug-in electric car in the U.S. in 2018 with a total yearly sales of around 140,000
cars.
3. Smart Home
Maybe the most famous application of IoT is in Smart Homes. After all, who
hasn’t heard about connecting all the home applications like lighting, air
conditioners, locks, thermostat, etc. into a single system that can be controlled
from your smartphone! These IoT devices are becoming more and more popular
these days because they allow you complete freedom to personalize your home as
you want. In fact, these IoT devices are so popular that every second there are 127
new devices connected to the internet. Some popular ones that you might have
heard have, or even have in your home, include Google Home, Amazon Echo Plus,
Philips Hue Lighting System, etc. There are also all sorts of other inventions that
you can install in your home including Nest Smoke Alarm and Thermostat, Foobot
Air Quality Monitor, August Smart Lock, etc.
4. Smart Pollution Control
Pollution is one of the biggest problems in most of the cities in the world.
Sometimes it’s not clear if we are inhaling oxygen or smog! In such a situation,
IoT can be a big help in controlling the pollution levels to more breathable
standards. This can be done by collecting the data related to city pollution like
emissions from vehicles, pollen levels, airflow direction, weather, traffic levels, etc
using various sensors in combination with IoT. Using this data, Machine Learning
algorithms can calculate pollution forecasts in different areas of the city that
inform city officials beforehand where the problems are going to occur. Then they
can try to control the pollution levels till it’s much safer. An example of this is
the Green Horizons project created by IBM’s China Research Lab.
5. Smart Healthcare
There are many applications of IoT in the Healthcare Industry where doctors can
monitor patients remotely through a web of interconnected devices and machines
without needing to be in direct contact with them. This is very useful if the patients
don’t have any serious problems or if they have any infectious diseases like
COVID-19 these days. One of the most common uses of IoT in healthcare is using
robots. These include surgical robots that can help doctors in performing surgeries
more efficiently with higher precision and control. There are also disinfectant
robots that can clean surfaces quickly and thoroughly using high-intensity
ultraviolet light (which is pretty useful these days!) Other types of robots also
include nursing robots that can handle the monotonous tasks that nurses have to
perform for many patients day in and day out where there is little risk to the
patients.
6. Smart Cities
Cities can be made more efficient so that they require fewer resources and are
more energy-efficient. This can be done with a combination of sensors in different
capacities all over the city that can be used for various tasks ranging from
managing the traffic, controlling handling waste management, creating smart
buildings, optimizing streetlights, etc. There are many cities in the world that are
working on incorporating IoT and becoming smarter such as Singapore, Geneva,
Zurich, Oslo, etc. One example of creating smart cities is the Smart Nation Sensor
Platform used by Singapore which is believed to be the smartest city in the world.
This platform integrates various facets of transportation, streetlights, public safety,
urban planning, etc. using sensors in conjugation with IoT.
7. Smart Retail
There is a way to make shopping even more exciting for customers and that’s to
use the latest tech like IoT of course! Retail stores can make use of IoT in a wide
range of operations to make shopping a much smoother experience for customers
and also easier for the employees. IoT can be used to handle the inventory,
improve store operations, reduce shoplifting and theft, and prevent long queues at
the cashiers. A prime example of this is the Amazon Go stores which provide an
IoT enabled shopping experience. These stores monitor all their products using IoT
so that customers can pick up any products and just walk out of the store without
stopping at the cashier’s queue. The total bill amount is automatically deducted
from the card associated with the customer’s Amazon account after they leave the
store.