Let's get Started!
Shrey Sharma
Founder, CEO - SmarDen | Entrepreneur | Author | Trained 10K+ students on IoT
Internet of things, this technology is booming nowadays and a hot topic among the students. Here is all you need to know before getting your hands into IoT.
Internet of things generates a large amount of data, this data is the information around us, from the state of your door to the temperature of your living room. IoT is a network of connected devices that shares the data on the internet and the devices performs different operations depending upon that data.
The data around us is not in a form that the machine could understand it. for example if the door of you room is open or closed, then the state of that door is the data i.e. "open" or "close", here in IoT we need to perform different operations on the this data. As this data is not in digital form so we need some kind of device that convert this physical data into digital form so that the machine or the micro-controller could understand it, such devices or modules are known as Sensors.
The sensor collects the data from the environment and send it to the micro-controller. Now the question arises that how will you integrate the sensor with the micro-controller. In order to do that one must needs to understand the interfacing options. There are different ways by which the sensors are connected to the micro-controllers or we can say that there are different interfacing options for a sensor or any other module to connect it to the micro-controller. There are 4 different interfacing options - 1-wire, UART, SPI and I2C protocols. These interfacing options depends on the sensor or module, different sensors and modules use different interfacing options.
1-wire sensors are the simplest sensors, they only need one wire (other than power supply i.e. 3.3/5v and gnd) to connect to the micro-controller. These type of sensors only return the values in either 0 or 1 and these values can be read by micro-controller on any digital GPIO. Now coming to the second mode of interfacing which is UART - Universal Asynchronous Reception and Transmission which can be connected with the help of Rx and Tx pins which must be present on both the sensor and the micro-controller unit. Third method is to use SPI - Serial Peripheral Interface, this mode of interfacing requires 4 pins- MOSI(Master out Slave In), MISO(Master In Slave Out), CLK(Clock) and CS(Chip Select). Then we have the I2C- Inter Integrated Circuit mode of interfacing which is done by two pins - SDA (Serial Data) and SCL(Serial Clock).
Now lets move on to the micro-controller, according to the definition the micro-controller is a device which has on board RAM, ROM, memory, clock, interrupts, processing unit and general purpose input and output pins(GPIOs) and is programmed to perform a specific operation according to the user. In order to learn about micro-controller one must understand its Pins, as all the tasks are performed on these pins. There are different types of pins in a micro-controller, generally categorized by-
- Power pins (3.3v, 5v, gnd, vin, RST, EN)- These pins are known as power pins as they are used to supply power to the board and are involved in all the power related operations.
- General Purpose Input Output (GPIOs)- As the name says these pins are used to perform the general purpose input and output operations, they are also known as Digital Pins as they are only able to read or write digital values only i.e. they only understand 0 or 1. Everything between 0-0.8v is considered as 0 and anything between the value of 2.5-3.3v is considered as 1. There are only two functions that we can perform on these digital pins and they are either Read or Write, either they read the data or they write the data and no other operations.
- Analog Pins- The analog pins uses the in-built Analog to Digital Converter(ADC) circuit of the micro-controller and is able to sense different voltage levels. These pins only used to READ the data. They detects the voltages from 0-5v or 0-3.3v(depends on micro-controller) and after that they convert the analog signal in digital signal using in-built ADC and send it to the micro-controller's processing unit, they return the value from (0-255).
- Pulse Width Modulation(PWM) pins - PWM uses the in-built digital to analog converter(DAC) of the micro-controller. They are only used to WRITE the data, they output the values between (0-1023) different values between 0-1023 represents different voltage levels. The voltage varies between 0-5v or 0-3.3v depending again that depends upon the micro-controller.
other than that we have some pins that can be used as GPIO pins and we can also perform some other operations with them. They are used to interface various sensors and modules with the micro-controller. there are different types of interfacing protocols as we have already discussed above.
- UART- Universal Asynchronous Reception and Transmission. This mode of serial communication can be used to interface different sensors and modules to the micro-controller other than that we can also program a micro-controller with the help of these pins and they are also used to run the hardware serial monitor in the micro-controller for the purpose of debugging.
- SPI- Serial Peripheral Interface. This mode of serial communication is also used for the purpose of interfacing different sensors and other modules and it uses 4 pins which are- MOSI(Master Out Slave In), MISO(Master In Slave Out), CLK(Clock) and CS(Chip Select).
- I2C- Inter Integrated Circuit. Another interfacing protocol that only uses two pins for communication- SDA (Serial Data) and SCL(Serial Clock).
So these are the common pins which are present in a micro-controller and we can perform various operations on these pins.
So we have discussed about the GPIOs and other important pins that are present on the micro-controller. Now that we know that the sensor is the device which will convert the physical data into digital signals and send it to the micro-controller by any of the interfacing options, so now we have the data in our micro-controller. here we have the again three different operations to perform.
1. Read the data and perform any operataion according to the data.
This operation includes the operations performed on the micro-controller according to the data received from the sensor. For example, if a door sensor is attached to one of your doors, then the sensor will give the information about the state of the door which is either "open" or "close" and the sensor will send this data to the micro-controller. Now the micro-controller will read the data coming from the sensor with the help of GPIO pins or we can say Digital pins and at the same time we can also perform any other operation on that micro-controller according to the data it has, for example we can glow and LED when someone opens the door and we can turn off the LED as soon as the door is closed. so in this way we can perform any operation on that micro-controller according to the data received from the sensor.
2. Machine to Machine Communication
We can also transfer that data from that micro-controller to another micro-controller, this process is known as machine to machine communication where two machines (microcontrollers) share their data to one another. We have two ways to transfer this data from one machine to another or from one microcontroller to another- WIRED or WIRELESS.
2.1 Wired - Again there are only a few options by which we can integrate another micro-controller/module/sensor to a micro-controller i.e. UART, SPI and I2C.
2.2 Wireless - There are different wireless technologies or different wireless modules by which we can transfer the data from one micro-controller to another, there are different factors one must consider in order to choose the appropriate technology. Various wireless modules includes- wifi, Bluetooth, BLE, Z-wave, RF, Zigbee, nRF, LoRa etc.
There are certain factors to keep in mind in order to choose a wireless technology for your project which includes -
a. Bandwidth : it is the range of frequencies within a given band. it is used for transmitting signal. in computing bandwidth is the maximum rate of data transfer across a given path.
b. Latency : it is the delay or the time taken for the data to go from the sender to the receiver.
c. power : Every electronic device takes power to communicate and to transmit electrical signals rom on e place to another.However Energy is more important than power. Energy is power consumed over period of time.
d. Service Level: Service level agreement or SLA is a type of agreement that the industrial customer will request from their wireless carrier. it is the agreement regarding the wireless connectivity and its installation and maintenance.
e. Topology: You must define the topology of your devices whether you need point to point connections or one server many clients or any other type of network topology.
f. Range: the maximum distance between the client and the server in which the signal can travel easily.
g. Value: value is how much a working device is worth to the end customer or how much the customer is willing to pay for the connectivity.
h. Product life: Industrial devices last longer than the consumer devices because the product life is definitely greater in industrial products than the consumer products and so does the wireless technology they use in the industrial products.
i. Form factor: The size of device can limit your choice of communication technology so before choosing a wireless technology take a look at the size of the device.
j. Security: Security must be considered when choosing your wireless tech. certain networks are more secure than others.
And to integrate these modules with the micro-controller again we have to choose interfacing options either from UART, SPI or I2C.
3. Uploading the data directly to the internet.
IoT is all about accessing the useful data from any part of the world and in order to achieve this, we first need to upload that data to the internet. The First step includes collecting the data with the help of a sensor, Second step is all about transferring the data to the micro-controller. Now in the third step we are discussing about transferring this data to the internet. To transfer the data to the internet the micro-controller needs to establish a connection to the internet and this can be done either with the help of 'Ethernet module' which helps the microcontroller to establish a connection to the internet via LAN port (RJ-45), second method is using 'WiFi Modules' the wifi modules we have comes with integrated micro-controllers so we don't require any other micro-controller to use the WiFi module. The most popular wifi modules are - ESP8266-01, We-mos, Nodemcu, ESP-32 etc. they all comes with an integrated MCU(Microcontroller Unit).
Ethernet and WiFi are the medium to establish a connection to the internet, now we need to define the path to actually upload this data to the internet. These paths are the protocols that we follow in order to transfer the data on the internet. We have various protocols to choose from in order to upload the data some of the mainly used protocols are - MQTT, HTTP, TCP, CoAP, UDP etc. and out of these protocols MQTT is defined as the protocol for Internet of things.
So in this article we had an overview on what is IoT, sensors and micro-controllers and how to interface different sensors to micro-controller and what other operations we can perform on micro-controllers. This article will help you to create a picture about these things and will clear your confusions regarding IoT and micro-controllers in order to get started with the IoT.
Thank You!
-Shrey Sharma
Create a BIG (+) Impact;
5 年shrey sharma sir, this content is worth more than the achedamic content