IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Technology | Edureka



hello everyone this is Neil Frederica and welcome to this IOT tutorial session now IOT our Internet of Things as it's most popularly known is one of the greatest phenomena of this century it's gained a lot of popularity and in today's session we'll be getting a brief idea of what IOT is and we'll also be working on a demo using raspberry pi now going on to the agenda for this session we'll start off by first understanding what is Internet of Things and then we'll try to address the question why do we need Internet of Things going on from there we'll talk about the various benefits of IOT as well as the various features of IOT as well and finally we'll be moving on to the demo of this session which is basically creating a weather station using raspberry pi will mainly be measuring three things we'll be checking the temperature of the environment the pressure as well as the humidity present okay so these are the three things that we'll be measuring using raspberry pi and other comprehend known as censored okay so moving forward let's talk about the first topic of the session which is what is Internet of Things now to help you understand what isn't enough things let's look at an example of a mobile phones first okay our mobile phones has GPS tracking it also has mobile gyroscope you have adaptive brightness which gets adjusted based on the light falling on it you have voice recognition and you also have face detection which identifies who is the user now again iPhone X is coming with face detection so again these are a lot of features that are coming pre-built on the mobile as such and most of these have a common interaction between them because let's say one application can use all of these features I can also have these features in itself being interacting with each other let's say based on a GPS location my brightness could be adjusted or based on the direction my phone is being held the brightness in itself can also be addressed in as well so there are a lot of features but when they interact with each other these features come together to bring in a better system than anything that they can provide individually as such that's what Internet of Things is it basically is a platform where we can connect everyday things which are embedded with either electronics software or sensors to the Internet and this in turn enables us to collect as well as exchange between these things now then I say things it can be anything and everything let's say I have an internet platform wherein I can connect these things if I take the example of my house I can connect my lock I can connect my AC I can connect my light and all this can be managed on the same platform now since I have a platform so if I can also connect my car to this I can keep a track of my fuel meter I can keep a track of my speed limit I can also keep track of the location of the car as well now if there is a collector platform where all of these are connected wouldn't it be great because I would love to have the AC on and set a cool temperature at my home by the time I reach back from office if I have a platform that knows my preference and that keeps track of where I am and where I am going to then it can also identify that I'm going from work back to home and my preference suggest that it would be best if there was an easy temperature of about 22 or 23 degrees centigrade and this is something that is definitely possible through Internet of Things then this is just one of the examples now let's say tomorrow you come back home it would be great if I wouldn't even need a key to unlock my door my home system should be aware that I have come home and should unlock all the doors that are needed and now this can be done if my mobile and my home devices are connected onto the same platform based on the location of my mobile it can identify that I am at my home so will automatically unlock the door and let me come in as well these are some of the real-world implications of Internet of Things these are something that are already happening but going forward what we need to understand is that when I have a specific component with me which can do a lot individually wouldn't it be great if I can collaborate this component with my system of different components and build a better system this is what Internet of Things is helping us to okay you provide a platform through which all these things are connected through the internet so Internet becomes the medium through which you are connecting all these components work things to a platform okay moving forward let's try to understand why do we need Internet of Things now to help you understand why let's look at an example this patient at home okay he's on constant life-support where and his status is being checked to a health monitoring system present on the clock let's say at a point there is certain issue with respect to his health let's say there's some irregularity with his heartbeat or his blood pressure is low there is some fluid being there lap or sofa now what happens is since the system on the cloud is connected to a hospital as well this information would get passed on to the hospital as well there and what would happen is that they would get the complete details with respect to the patient and the important information with respect to the current situation of the patient as well we made aware with respect to what tissue exactly is the patient facing as well as enable them to dispatch an ambulance immediately to bring the patient back to the hospital as well now meanwhile once the patient has been picked up and brought back to the hospital that could be prescriptions there could be medicine there could also be an operating theater made ready in case of an emergency situation as well there'd be doctors on standby who have the complete history of the patient who have the complete details of the present condition of the patient as well so this in turn brings in a lot of transparency and reduces a lot of effort and time involved with respect to this same thing gets taken today scenario there has to be someone monitoring this patient's health and if there's a fluctuation they need to call the hospital they need to call request for an ambulance and meanwhile once the ambulance is here they take the patient and they're back into the hospital then again there needs to be a lot of checkups that need to be done because the doctors are not fully aware again there is a lot of tests that need to be run and this in turn leads a lot of delay as well in certain emergency cases as such now if a system can do this then this is exactly where our future lies it and what we have to definitely move forward to now Internet of Things basically is expanding the interdependence of humans to interact contribute and collaborate with things around us now what do I mean by interdependence of humans how we depend on each other like how I'm explaining this concept to you if you're not clear you would reach back to me you would request me for help okay this becomes an interdependence between us when I'm giving you knowledge when you now clearly coming back to me and you're helping similarly tomorrow if there's something that you can do for me I will reach out to you so we all are interdependent on each other for something or the other if we can expand this interdependence to interact collaborate and contribute with respect to the different things around us then we would be building a proper Internet of Things environment this would be a much more safer secure effortless and time-saving environment into existence moving forward let's talk about the various benefits of Internet of Things now the first thing that would be as a benefit of having an Internet of Things platform would that you could efficiently utilize the resources that are available if I have a smart system which can interact with empty if it has enough computational power if it has enough understanding of how things work between each other I'm quite sure the usage of the resources away will be more efficient as per this resource could be in terms of monetary it could be in terms of natural resource it could also be an input taken up by the thing as an input and so far okay so all this can be more efficient if I have a platform which is more smarter and interconnected as well apart from this it minimizes the human effort involved if my system is smart enough to interact it to filter smart enough to do things that I don't need to get involved with then my interaction is always going to be made this is same with everyone and that's one of the major reasons why Internet of Things has become popular today and the concept of smart home is always growing as well in the same perspective because if the system in itself is able to do most of my work at home then I don't need to put in much effort I can relax at home without having to worry about anything okay the next benefit would be it saves time if it reduces my human effort definitely it is going to save my time okay apart from that if the resources are utilized more efficiently then again it is going to save a lot more time as well all in all any benefit of Internet of Things will in turn help you save a lot of time as well ok so time is one of the major factor that can be saved on an Internet of Things platform now I have an artificial intelligence platform through which all of this is managed and maintained then the personalization and the human touch also comes into the picture now today most of us have had a level of interaction with an artificial intelligence or a virtual intelligence as well this could be a personal assistant like Siri or it could be an assistance application like Google assistant now if I have a system where all these components and things are interconnected then in turn all the security present on each of these things is going to get multiplied and it's going to build a much more secure system apart from that the level of security that you would be integrating to the platform in itself is going to be quite cute so the overall security with respect to everything is going to increase multiple times as well now let's look at some of the major features of Internet of Things now any technology that is available today has not reached its hundred-percent capabilities and it always has that gap to go Internet of Things is one of the major technologies in the world today that can help any other technology reach its true and complete potential as well now there are mainly three aspects to Internet of Things as to how it works first is the connect aspect here basically what you need to work on is you need to ensure that there's a connectivity between all the things around you all the necessary things to the Internet of Things platform ok then comes analyzed now I have my things around me they each are going to generate some amount of data now this data needs to be collected and it needs to be analyzed to build a business intelligence solution if I have a good insight from the data that is gathered from all of this then definitely I can call my system as a smart system finally what happens is in order to improvise and improve your system you need to integrate it with various models to improve the users experience as well let's say this a personalization module that is there or let's say there's going to be an aspect where I can directly connect to my providers now this provider could be Amazon it could be flip card it could also be my retail store that is next to me let's say I'm out of milk 3 we'll get a notification and he would send milk right away and the same thing can be done let's say my coffee machine requires special beans and this business is almost complete then what my system could do is it could go online to Amazon and purchase these beans for me as well so there are a lot of things that I can do when I integrate this with respect to various models and improve the overall experience to a single user or a group of users or the world itself as such okay now let's talk about each one of them one by one let's start with connect now the first stage of Connect is device virtualization because what you need to first do is that you need to standardize the integration of the device to the enterprise platform which is present on the clock okay now it could be present on a cloud it could be present on a server but again it's all going to be connected through the internet so what I need to do is that I need to ensure that certain level of standard is present on the device so that it can go on and connect to my Internet of Things platform now to help you understand this better there could be a standard power plug and there could be a power plug which has an inbuilt Wi-Fi support so that it can connect to my lab now to build a smart home system I need the second power point because there only I would have the acces to control it over the Internet and my system could integrate with respect to the same okay now if I take the first standard power point then what would happen is that I need to manually switch it on and switch it off how in the second case I could send a signal to it and this in turn will switch it on and switched off so there is supposed to be a level of standardization through which I can integrate all of these devices to my platform next comes high-speed messaging so now what I have done is that I have connected all these devices to my platform but these devices in turn generate a lot of data and this data is what is going to help us understand better on how we can improve the overall system and help and provide the user with better experience so for that we need to have high-speed messaging okay this basically means that there needs to be a reliable secure and a bi-directional communication channel between the devices and the platform well the purpose of it being bi-directional is because you need control each one of them as well let's say I want to switch on the AC then the signal would be going on from the cloud platform to the device so this is how it works on okay so every communication needs to be reliable it needs to be secure and it needs to be by a directional as well moving on to the third point of Carnac you need to have endpoint management if I don't have an endpoint much I have established a way through which all my devices can connect to my platform I've also ensured that the data is going to be sent from the device to the cloud and the cloud can send back to the device as well through a secure Channel but if I do not actually identify from which device which data is coming and how this data has to be processed then it becomes a failure of the system this is where endpoint management comes into picture endpoint management basically helps you in managing the devices endpoint identity the metadata and the overall lifecycle involved with respect to these things are such okay so to Paulo quite simply it basically helps you identify from which device which data is coming and what needs to be done with this data as well now coming on to the next feature is analyze and the first thing that you need to do for analysis is the stream processing now if the data coming from the device is not on a real-time basis then my system is off no use there is no use if I tell my system to switch on the AC at my home and by the time I reach there if the AC is not even turned on then it's a failure on my sister okay so real-time analysis of the incoming and outgoing data and must be done and with respect to different aggregations it filtering correlations processing and so forth okay now apart from this what you need to do is that this is raw data that is being streamed from all the things you need to identify which is contextually important information which is going to be taken forward so once I have the relevant information then I can even generate composite streams of information which can be taken ahead for future analysis and understanding as well now this is what your data enrichment process does then you have events tour now in events – basically any information that you want can be queried and visualized from the vassal amount dita which is present on my cloud platform okay now this in turn can also help me get a better insight analysis if I have all the enriched data present on my cloud platform I have a tool which helps me identify what is needed helps me analyze this data healthsome utilize it then definitely it becomes more useful aspect and when I have data coming from different things as such this in turn can also lead to being a collection of big data now when I talk about big data it's not just few GB of data it's going to be terabytes of data because because the data generated from the things around us is that was and if you're doing it over a period of time then definitely it is going to grow into a big data domain as well now coming to the third feature of Internet of Things comes enterprise connectivity so this is what I was basically telling you about let's say I have a requirement from my retailer or even an enterprise organization which is present it could be Amazon it could be flip card anything as as any enterprise organization which provides me a service if I can connect to them through this platform then definitely my overall process also becomes easier as well let's say there's a service provider okay let's say there's a leakage in my plumbing or let's say there's some issue with respect to my electricity then it can contact to the corresponding service provider it can send them a detail and corresponding they would be dispatched this would in turn reduce my effort of having to check the problem having to call someone wait for them to come back all that gets reduced to minimal required effort as well now how does this communication operate so for that we have REST API okay once I integrated my REST API with respect to the cloud application and my Internet of Things then communication between the enterprise communication between the platform and the communication between the things around us can be made more efficient and can be more easy as well the third aspect is command and control if I don't have command and control on my platform then it's off noise yes I build a very great environment I build something that's quite extraordinary but if we cannot command it if I cannot control it as per my requirement then the system in itself is not useful I cannot tell my door in my smart home to unlock when I want it then it becomes failure on my part if I cannot control the AC or my host motto then again it's a failure so always the major aspects when you integrate with respect to these things the major thing is that you need to ensure this a huge control on the system and you're able to command it as for your record and this command could either be through a voice based recognition you could also me a message that you can send through your mobile application and so forth as well okay so now let's start with the Raspberry Pi OS installation I'll help you to understand how you can actually install Raspberry Pi operating system once you've bought the Raspberry Pi ok so we will divide it into different parts first let me help you understand the different operating systems that are available at present ok Raspberry Pi in itself supports multiple operating systems as such but will mainly be working on raspbian ok so these are some of the most for a pillow operating systems supported on Raspberry Pi so you have RISC OS you have FreeBSD operating system you have net BSD operating system plan 9 is again from Bell Labs as well as Windows has its own Windows 10 IOT version okay so for this session we're not going to go into the Windows 10 we stick to the core raspberry pi operating system now for downloading the operating system you can go on to the original site that is Raspberry Pi dot o-r-g and there in the downloads tab you can download the operating system let me just show it okay so this is the Raspberry Pi homepage and here if you go on to the download section you can download the operating system now if you are starting off with raspberry Pi an Internet of Things trust me this is the best place that you can find a lot of informations with respect to it okay most people actually publish their details with respect to the projects that they are working many popular projects are also available you can find a lot of help as well as good information here okay so this is definitely the place to go to if you go onto the download section here okay this will either show you two options you have noobs or you have raspbian I would recommend that you go with noobs because this is a complete package with respect to the different operating systems as such so here again you have noobs and loops like so my recommendation would be you download nodes and make sure you using a 32 GB memory card this would be really helpful because it gives a lot of memory for your operating system so in case if you're going for a 16 GB or below I would recommend you go with the nope slide but make sure you keep the bare minimum of 16 GB in case if you are working with Raspberry Pi but do not mistake me when I say use a 16 GB memory card you can install it on an 8 GB Esper but again the operating system has less memory to work with so at least go for 16 or higher 32 is what I would recommend so once you download this zip file or you can even download it by a torrent ok but I would recommend download it as a zip file let me show you the file so this is the noobs file let me extract this okay it may take some time it's about a 1.5 GB file ok the Lites version is slightly lower in comparison but this is something that I would recommend in case if you're working with the Raspberry Pi so I have my noobs folder here so what you need to do is that you need to copy everything inside the noob folders and then paste it inside the SD card okay make sure you are not directly copy pasting the folder that you have extract so what happens is if you do that it does not actually recognize the operating system as part of the Raspberry Pi so copy everything that you've extracted and then directly paste it inside the SD card now again this is why I recommend that you use a high-speed memory card because in case if you are not using it then what happens is that it takes a lot of time with respect to fetching the data okay now as I had mentioned if you're going for a memory card for your Raspberry Pi you can use something like a 16gb at least and make sure it has a high transfer speed so this in turn will give you a lot of memory area to work around with as well as I would recommend you take something like a class 10 memory card that is available in the market today so these have a very good read and write speed issue so definitely this is something that you should consider while you're getting a memory card for your operating system okay now once you're done copying with this let's go on to install this memory card on to our Raspberry Pi and let's begin the installation process okay so now we've successfully copied all that is needed for our operating system so safely remove this make sure you're ejecting it safely because sometimes what happens is if we do not safely eject it the files get corrupted before you load it into your Raspberry Pi this is a certain issue with respect to the memory card so just eject this okay so this is my Raspberry Pi and if you actually flip it over this is the slot where you have to insert the memory card and we've copied the noobs folder into this memory card again let me just insert this into this and let's begin with respect to the installation process let's begin installing this memory card on to my Raspberry Pi and start with the setup so let me just turn though on my Raspberry Pi okay so this is a screen I'm getting by default again now what happens is the installation steps will be initializes so the raspberry pi is getting loaded okay now there are two operating systems that are present here by default and we want raspbian so let me just select raspbian and click on install option present here now if you see here it basically is telling me that it requires 4.5 GB so this is why I was recommending you to get at least 16 GB or more because if I have an 8 GB memory card if 4.5 GB goes off with the operating system itself then there's not much memory left for me to work around with ok now let me just click on install okay just before I do case if you are using a different language or if you want to use a different keyboard as well you make sure you're specifying that okay so there are written languages present here so choose the corresponding language as per your requirement okay once you selected that this click on install and this is just basically going to ask you whether you want to format your data and install the operating system on top of this so click on yes and the installation process has begun now it may take some time so I request you to be a bit patient because this is an operating system installation process so please be a bit patient and hope you have fun meanwhile okay so now as you can see the operating system installation has completed successfully once you hit on okay it's going to ask me whether I want to reboot automatically reboot asthma okay so yeah it's automatically rebooting at this point you okay now as you can see the Raspberry Pi operating system has successfully been installed okay so this is what your Raspberry Pi operating system would be looking like okay so this is raspbian as such so there are different operating systems that are available today for you to install that we have discussed already so let me go back to my slide and let me just summarize the installation process again now if you see here we started by downloading the noobs folder and then we move Anton to extract the folder and copy it into the sdcard okay make sure the SD card is empty as well once you're done with this insert it into the SD card slot and then we have completed with respect to the installation process okay now that we've installed raspbian on Raspberry Pi it's time we begin with the demo for this session now what we're trying to do is that we're trying to build a weather detection system to get the real-time weather analysis now when we talk with real-time analysis it basically is the pressure temperature and humidity and what we want to do is that we want to get a live mobile notification for this so for that will be first using sensor board which will help us measure the various metrics like temperature humidity and pressure onto our Raspberry Pi then we use raspberry pi to transfer this data and display it on the sensor as well so we will just be displaying the temperature as of now on the set side and finally we'll be using insta push API and python program through which we can send this notification across the internet to our mobile application so let's begin the stem apart first let me show you what sense artists and how you can assemble sense that on Raspberry Pi okay so this is my raspberry pi unit and this was what I was referring to this is some sample okay now if you see this is a simple additional board that you can add on top of your Raspberry Pi okay now it's quite simple but how it's different is that in comparison to your Raspberry Pi there is an 8 cross 8 digital LED display present here so you can use this for various different purposes as per your requirement ok now it simply sits on top of the Raspberry Pi ok just make sure the alignment is correct and once you've done with that just push it on top and the pins would merge accordingly once you do that you can just place the 4 screws across the different ends and tighten it up you're done with this you can integrate and use the sin site for various different purposes we'll use sensor to measure the temperature the pressure as well as the humidity across in this room that is present okay so this has different sensors present on it and we'll be using them for today's demo okay so let me just put this up and once it's all set up let's go back to our demo and let's begin with understanding the programs before we begin the execution okay so moving on now that you've understood our board class very pious and sat and we we also install raspbian on our Raspberry Pi let's move forward and start with respect to today's demo part so again going back just to remind you we're trying to create a better control system where are we trying to measure the temperature the pressure and the humidity around the sensor as such okay so the first thing we're going to do is that let me just connect to my Raspberry Pi okay so this is my Raspberry Pi interface now let me just show you the program as well so I've divided the actual program into three parts so that it's easier for you to understand how this program works as such now the first program that we are going to execute is the sensing environment so this is a simple program that's going to sense the environment variables that is the temperature pressure and humidity and then it's going to correspondingly display these values on the send side LED display panel now let me explain this program to you one by one now firstly we need to import the variables the values on the sensor so for that we're going to use this line from sense underscore hot import sensor so this will give me the corresponding values from the sensor to my raspberry pi interface then I am also importing type now the main objective of time is to help me keep a log of all the values that I'm measuring okay so that will be seeing little ahead after that I am going to assign the sensor values to a variable known as sense okay so through this variable I'm going to correspondingly relate to all the values coming from the sensor okay moving forward we have written a while loop and this is an infinite while loop who is going to continuously measure the temperature pressure and humidity and it's going to correspondingly be displayed on the sensor as well okay so let me help you understand how the temperature humidity and pressure are measured okay so what you need to do to measure the temperature is used the function sense dot get underscore temperature so this function that is get underscore temperature will give me the temperature value measured by the sensor in degree centigrade and here what I am basically doing is that I am just converting it into Fahrenheit okay so the value in degree centigrade into 1.8 plus 32 is just a Fahrenheit representation of the current temperature I am using a round function to round off the corresponding value I don't need any decimal point values here I want a whole number so what I am doing is that I am using a round function and once I have the temperature then I am going to be storing it inside a temp variable okay similarly we are going to use sense not get humidity and sense dot get pressure to get both the humidity as well as pressure and store it in humidity and pressure variables as such so basically I have all my three variables that are needed now what I'll do is I'll create a string called message okay into which I'm going to store the temperature you and pressure with a specific notation so T is going to be equal to the temperature H is going to be equal to the humidity and P is going to be equal to the pressure now comes the part where I have to display this value on to my Sansad display screen okay so here I'm going to use the function sense dot show underscore message so this is basically a call through which I can send any message to my sense and display screen okay now here I am just passing the message with respect to the temperature humidity and pressure variable and then I'm also defining a scroll speed now this is something that you can play around with if you want to have a faster scroll you can modify it I have chosen a 0.08 scroll speed then the other two factors are the font color and the background color okay now the text color I have set as 200 240 and 260 um so this is something that I have said as per my requirements you can player on as well as background color is something that I have set to zero zero and zero okay so you have the complete freedom to modify this as per your interest I would definitely recommend that you try playing around with this to get a better feel of how it works okay now what I am doing is that I am putting my system to sleep for four seconds this is basically to introduce a delay between the measurement carried out from the sensor now if I don't do this since it's a continuously running infinite loop it's going to keep measuring it one after the other so I want a simple delay between the measurement so I'm putting the system to sleep for four seconds after that what I'm doing is that I'm opening a file called weather dot txt now Here I am going to create the log into this file I'll take the present time and then pass the message as well so these both with respect to the present time as well as the message are going to be stored in form of a law okay so in case in future if I want to refer to the measurement this is something that will be really helpful finally I'm also going to print message on my console now this is something just for our understanding asthma we'll be saying it on different places we'll see it on the console we'll see it on the sensor as well as we will be seeing it inside the log file as well finally I am closing the log and then I am putting my system to sleep for five seconds so these sleep delays are just to ensure that the consistent values are being measured in real well and there is no hindrance with respect to that okay I hope you guys are clear about this because I'm going to go on to execute this program so let me open my console okay here let me write the command for executing a Python program and it's very simple it's this Python followed by the filename okay now in our case it's sensing environment okay so let me execute this and now if you see the values are being computed and on the same side the values are being shown as well so you can see here the change with respect to that okay firstly it showed me all the temperature humidity and pressure and now it's already come on the console as well similarly it's going to have a simple delay and then you can see already it's showing me the next values on my sensor and it's going to be stored in a log file and then it's going to come on to my console so very interesting right so definitely you can play around with respect to the font you can play around with respect to the background color as well as if you are interested you can try bringing different temperature items near the sense that to see the variation with respect to that as well let's say if you have a glass of hot water and you bring it near the sensor the temperature value will correspondingly change as well okay so this is something that you can really experiment on and have a good understanding of how things work on so let me just close this program and let's see the log file okay so this is my weather dot txt file so I have taken different temperature and measure variables it's been logged from a long time that we've been trying this out on so definitely there are a lot of values here okay so let me just show you the latest value so this is a range of values that I had just tried out some time back so all the log all the temperature and pressure log are being stored here continuously okay and if we come down this is the latest log that we have just created with respect to the three values this is the current status as such okay so again this is something that you can experiment on I am just stored it because of my future reference as well okay so I hope you guys have got a simple understanding of how you can connect to your sense at measure the temperature pressure and humidity and also display it on the console as well as on your sex act now coming on to the second part second part is a slightly advanced version of the same program here we're trying to do something little more apart from just seeing it on the screen okay now I want to send an email with respect to all the logs that I have or let us say at a regular interval I want to have an email which notifies me with respect to the present temperature and the current pressure and humidity now this is something that you can definitely use while you're working on a social experiment as such usually in laboratories it's important that you always keep a check on the temperature pressure and humidity so this is something that you can try out so let me show you the code alright so here I've been just including something new as well apart from our previous code okay now if you see our previous code is still present here I'm taking the temperature I am taking the pressure humidity storing into a message and then I'm also printing that message but apart from that I'm using a few libraries which are very essential for mailing me this detail okay so for that I'm going to use first SMTP library okay because your mailing protocols are SMTP based protocols so these are something that I will be using in case I need to send a mail with respect to all the details ourselves so these are standard protocols through which I will be communicated okay now coming down with respect to what a Miami is a Miami basically is an extension a multi-purpose internet mail extension through which I can send emails with support text characters non text characters audio video images and so forth so sending a mail this is an essential important library as such okay moving on forward let me explain you the code now here we're repeating the same thing we are also importing the time function and then we are establishing a communication between the sensor and the program okay so here first you need to specify the from address that is from Coos mail ID you're sending this so I have created to test mail IDs one is a Eureka test 11 at gmail.com so from this address the mail is going to be sent and the address which is going to be receiving this is a Eureka raspberry pi okay so from this email ID I'm going to send a log with respect to the data that is measured from my sense that Raspberry Pi ok 9 I'm going to use my a Miami multi-part function from here I'm going to distribute my mail to multiple parts so this is what your M IME multi-part function will help you to that so in my message part the from is going to be the from address that is from whom it is going the to is going to be the to address and the subject I am defining it as temperature Raspberry Pi so temper ASP then I am measuring all the temperature as well as the pressure and humidity and storing it in inside a message variable so here what I am doing is that I am basically going to attach the message in a plain format to my message variable which is going to be the details of the temperature and pressure okay now let me come down and help you understand this part of the cook now I'm going to establish a connection to my server so I'm going to use your server variable wherein I'm establishing an SMTP protocol to Google okay that is your smtp.gmail.com so this is a standard mail protocol SMTP for Gmail it is smtp.gmail.com burr so again with respect to SMTP this is a standard port that you would be using for communication that is 25 okay then I'm going to start my server so that is server dot start TLS okay once I start this then I'm going to specify the login credentials this is basically for authentication factor so server dot login you have to provide the username and password so my from address is my username and my ID eureka api is the password for this email ID okay once i've specified this then what I'm doing is that I'm converting the message as a string okay sometimes what happens is while you are trying to send this it may not get sent as such because it has values also associated with it so I'm directly converting it completely to a string okay and then storing it inside a variable known as text then I'm calling the function send built through which I am specifying from which address it is going to which address it should go and the text which is part of it finally I'm quitting the connection between the server I hope you understood till here with respect to the program now it's time we execute this program okay so let me call Python email dot py so now what it has done now it's connecting to my server that's the delay here okay it's measured the temperature it's measured the humidity as well as measured the pressure and then it's going to sender me so let me show you this mail ID as well so as you can see here I've already received a mail from a Eureka test lab it's called temp rasp that we had set and it's given me the corresponding value of temperature humidity and pressure so this is what I was referring for so you can do this across now let me show you my sent box as BA okay now if you see near sent box I can actually see that this meal has been set so there are two ways for me to verify this as well so this is something that is really helpful for me now coming back to my Raspberry Pi let us now see the final program in which we're gonna incorporate this and do a little more so let me explain you the code a little more better here there are few things new here so first you have pi Cole and Jason being imported now PI call basically is going to help you establish a connection between your API so we're going to use an API through which I'm going to pass my data so for that I'm including PI Korea apart from that you have a string IO which is a standard string input output management package and you have your RP i dot GPIO so that is a raspberry PI's general input/output I'm just referring to it as GPIO okay so moving forward whenever you see GPIO it is the general input output from the Raspberry Pi and then you have the similar function you have sense i underscore heart from sensor and time function and i am establishing a connection here as we have done earlier between my sensor and my application and i'm clearing the screen on sensor now what happens is sometimes if you've executed a program before and you've stopped the execution of the program then what happens is the display will still have the remaining data present on it it stays stuck on the sensor so before we move on to with respect to a program will clear the data out I guess that's what sense dot cleared us now here there are two things that are present here hot and cold okay now why they are being used I'll come back to that a little ahead okay apart from that there's also a new variable known as push message so we'll be talking about this also when we come down later and you'll understand what the push message is used for now let's try to understand the code which will help me display numbers on my sensor now you might be wondering if I have already displayed number and data on my sensor why do I need a separate part of this core because here we are trying to do something different from what we have already done so here firstly what we are doing is that we are setting an offset from the left and the top let me go back to my presentation here okay now here this is the standard program that we were talking about but let's see this is what we need okay so this is what we're going to explore ahead now this is my actual sense at okay this is an eight cross eight LED display function okay so here what I'm going to do that I'm going to eliminate the first column and the first two rows from the top okay so this distinctively will give me a six cross 7 matrix area remaining with me okay this is where I'm going to do all my operations from now onwards so this is something interesting and I'll help you understand why I am taking this 3G now before we move on let's take a simple look with respect to the core present here okay now before I do that let me try to help you understand why I have taken a six cross 7 matrix area now this was the remaining area I have divided this remaining area into two parts okay I'm just going to give a gap of one column between these two and the left-hand side is going to represent the temperature or that value in tens place and the right hand side segment is going to give me the value in ones place so this basically is a 3 cross through 5 matrix wherein I have 15 positions to play around with remember this number again this is 15 areas that I can play around with in a 3 cross 5 matrix now let's go back to our code now let me help you understand how it works now I have basically 10 numbers with me ok so each one is going to have a specific way of representing in a 3 cross 5 matrix so that's what I have written here in this number matrix as such okay so each of the line is a representation of a corresponding number in a 3 cross 5 matrix and this 1 and 0 basically is the configuration for the led to be either turned on or turned off so normally when we write 0 the first line will always be full the first three numbers are 1 okay then you have 1 0 ok again 1 0 1 1 0 1 and my last three numbers will be again 1 so as in when you represent 0 in a normal form this is how you do that so it may not be so clear to you right now ok so what I would recommend is before you try to understand how each of the numbers are displayed set an offset on your sensor there try playing around with respect to different values to understand how you can represent each of the numbers once you've made two or three mistakes then you'll get a clear-cut understanding of how each of the numbers can be displayed now if this is for a 3 cross 5 matrix tomorrow you want to try it across the 8 cross 8 you can do that as well so definitely make sure to try out make mistakes only then will you learn ok so each of the line is a representation for a digit in a 3 cross 5 matrix now let's try to understand how we can display a single digit for that I'm going to define a function called show digit okay so this is the function it takes a value as an input okay it takes a value for XD okay XD is the x-coordinate for where the digit has to be present yd is again the y-coordinate as to where that did it has to be represent and the last is a simple RGB value present here now first thing what I'm going to understand is that I want to compute the offset position okay why do I need to compute an offset because each of the numbers are present in different rows of the column so I need to understand which is the present number and which value do I need so for that what I'll do is the incoming value into 15 will always put me at the start of that row let's say the value is 3 okay so 3 into 15 tells me that I need to move 45 positions so as I said each row has 15 so 15 okay then I have 30 in the next row okay and once I'm done with the 45th transfer then I'm here this is the standard representation for 3 so I have this complete row at my disposal presently I am pointing to the start of 3 value ok so this is something important to remember so this is why we are computing an offset by multiplying the value into 50 so I have the complete access to this row ok now we will try to execute a 4 through which I place these values into the different parts of the LED display okay now see I have three cross 15 area so I need to identify in which area should which value come that is which led should be turned on I have three rows and five columns so I need to identify this let's go back now the first thing that I'm going to do is that I am going to compute X T okay X T basically is going to be the value of P modulo 3 okay this basically is going to give me value of zero one or two okay so if you go back to our presentation it's either going to start from this 0th position or it is going to be in the first position or in the second position okay similarly in the left-hand side also it could be this 0th position first position or second position so basically we are dividing this that's what you need to understand okay coming back let me just remove this okay similarly I'm going to compute my Y of T Y of T basically is to help me understand which value should I take from this complete row so this will basically start from zero and go all the way till 14 as such okay so it will basically represent which column value should I take okay so I hope you understand from this which column value should I keep taking for my next value once I have this then what I will do is I am going to call the sense dot set pixel remember how he had called sense dot show message so there and we had sent a complete message now what we're doing is that which is sent take each of the pixels individually as such okay so we're going to use the x coordinate okay which is going to be my XT plus XD okay remember this okay we'll define XD little ad but just keep this in mind XT plus XT is going to give me the x coordinate y T plus y D is going to give me the y coordinate and then basically my RGB number comes so here I have just done a multiplication of P into R so whichever I want I will just convert it according okay now comes the choice of when you have to display two digit number so instead of going back to the same function I have defined a new function which is called a show number now show number is actually the original function that will be caught because the temperature measured is most often a two-digit number so this is where the actual code was going to start from okay true number takes four values it takes a variable called Val which is the present temperature I have my RGB value as well as I am going to begin the function here firstly I'll begin by taking the absolute value of the given input okay when I say absolute value I am basically trying to identify the number present in the tens place okay so this is what absolute value will be whatever the digit is present in the tens place I'm going to store it in my ABS underscore value so that I'm just providing it here to the tens place then let me also identify Waterson units place and this is simple mathematical operation where I divide the number by ten I'm going to get a remainder and that's what I want so I'm going to use a model illusion so my absolute value divided by ten is going to give me the unit's place as well now what I'll do is I'll run an if condition so here what I'm going to do if the value is greater than nine then I'm going to call the show digit function which I had defined earlier and I'm going to pass the tense value okay the value present in the tens place so and then I will also pass the XD and why D in this case XD + yd is going to be the offset left and offset pop-y let me help you understand here my offset top is going to be with respect with this position it's going to start from here okay so it will point to the third row okay my offset left will point to the second column here so I know that this is where my tens place has to come so that's why I am passing it here okay I also I'm going to pass the standard RGB value that I have got input here then for a second time I'm going to call the show digit function wherein I'll pass the unit place but with an offset of additional four spaces okay so this coming back to our segmentation this is going to be four positions from our left so offset left is going to give me the first place but offset left plus four is going to be the start place where I have defined for my unit's place when I say from top it's both going to be the same because I'm not separating with respect to different levels so I'm just going to change with respect to my offset left okay so that's the only difference present now coming down we are computing the basic temperature the humidity and pressure and then storing it into a message string now comes the place where I need to do my actual implementation now if you remember our problem statement we have to send the pressure temperature and humidity as a notification on our mobile device okay so for that I'm going to use insta push which is an application through which I can send notifications across my mobile so my Python application that is the final application will communicate to insta push and that will in turn communicate to my mobile application that on which I have configured it okay so the notification will be received on my mobile application now coming down let me remind you again why we are using this in a real-world scenario this is something that is being used by NASA ok there they're using it to identify if the exterior temperature is falling between a specific range or even let's say if there's a change in the pressure inside the cabin or if the humidity is too high so all this can be measured and you can get notified with respect to any change that you want okay now come back to our program this is why I have defined a range of cold and hot if it falls below 37 degrees I want a notification if it goes beyond 40 I want a notification so this is my range by value it should either be only 38 or 39 okay so this is why I'm using cold and hot variables now let me help you understand how the insta push application is working for that let me open my browser and show you how you can configure in stop push for your raspberry pi application okay so this my insta push homepage okay now first thing what you need to do is that you need to begin by creating a user ID credential here and it is very important when you logging into your application you use the same credentials so make sure you do not reuse this because it's very important only if you use the same credential will you get this notification so remember that so you have an option to sign up for free as well okay all you need to do is provide your username provide your email address and then specify a password now we just log it okay so I'm just logged in okay now here you can see there's already a time line because I've already configured this application let me help you understand how you can do this now in my application I already have a temp notifying application okay which we'll be using as part of our understanding okay firstly let me click on add application now once I do this I need to specify a name so let me just call it sample once I click on sample once I press our application sample gets created now it is asking me to add event here so click on add event so let me call this temp rasp okay and then tracker would be message make sure you put a tab here after you specify whatever it is that you are specifying and here push message will be message so make sure it's present inside curly braces whatever you're specifying once this is done just click on add event and this event is going to get added okay so the event has been added now it's time I help you understand why I had specified message there so Roma let me go back to my code remember we had defined something known as push message so this is why I have defined message here so this is what is going to be sent between my final program application and my insta push application so this is why we had defined this way ad bill earlier as well okay now coming down with respect to this let me go back to my insta push and let me help you understand what all do you need before you move ahead okay just go to the basic info tab and here there are two things that you need okay first you need your application ID and then you need the application secret so this is very similar to how you have a user ID and password so this is what you're going to use in case you're working with an application okay so make sure you note this application ID and the corresponding application password now if you come back to my program you can already see I have mentioned the application ID as well as the application secret and here the push event is to my temp notify so this was the previous event that was already set so I'll be referring to that as well now what you need to do is that you need to use curl to post whatever data that you have to the insta push API so for that you're going to use Pikul dot curl function okay and this in turn will help you communicate between your application and insta push okay so all the communication is going to be through a variable called C now C dot setup okay here what I am going to specify is that I'm going to specify the URL first okay the URL is going to be HTTP colon slash slash API dot insta push dot I am slash version 1 slash post okay this also another alternative URL which is HTTP colon slash slash API dot insta push dot I am slash post itself now in case the other is not working you can use this or vice versa okay moving forward I need to set up the customer headers basically for my authentication and content type specification okay so for that you're going to use the command C dot set top followed by C dot HTTP header I'm going to specify X – install push – API ID + my app ID which I have specified earlier so this will help me identify to which up this has to be pushed okay the next is going to be X – install push – app see so basically the app secret your your password in this case okay then comes the content type that is what type of content I equal to pass so this is going to be application dot J's so I'm basically going to pass adjacent file to my API okay so I hope you guys are clear till here okay now what I'm going to do is that I'm going to define the function through which the message is going to be passed okay so here what I'm going to do first is that I'm going to use a dictionary structure for passing the data as Jason in my post function so Jason – field is going to create a dictionary and in through that I'm going to send this data okay now what I have to do is that I have to specify the field values so first comes to the event okay which is basically what event I need to relate to then comes my tracker now I have not specified any tracker as such then comes my message wearin I'm going to pass the push message push message basically is the temperature the pressure and the humidity as such now if you want you can print this but I'm not going to print it here finally I'm going to use Jason dot dump to make adjacent file I'm going to assign it to post fields variable okay so post field is the variable which I am going to pass to my API okay next to send your Jason file with post use the following command C dot set top okay inside which you're going to specify C dot post field and you're going to pass this post field which is the Jason file as such then if you wish to capture the response then you can capture it inside a buffer so for that I am also going to use a buffer not write operation and this can be done with the following command C dot set top inside which I'm going to write C dot write function and buffer right that is the right back has to be into my buffer okay now if you want to be updated whether the post has been sent then you can use the following command that is C dot set top followed by C of C so this will make sure that I am getting posted on my terminal with respect to the communication finally comes our operation of checking the temperature this is very similar to what we have done earlier where we are running an infinite loop I'm measuring my temperature in degree centigrade I'm measuring my humidity measuring my pressure storing this value inside of message variable and then putting it to sleep simultaneously I am also writing into a log file and this is going to be stored with respect to the present time okay so till here I hope you guys are clear now comes the part where I have identified my temperature I am just making sure it's an integer and then I'm going to call my show number function remember we had defined a function based on which it is going to be displayed on my raspberry pi so this is a call to that function okay once I have done through this I am going to store it into temp 1 then I'll make sure that I am writing it into my file and then comes the interesting part if my present temperature is either greater than or equal to the hot message or if it is lesser than or equal to a cold temperature that we have defined remember the two variables we had defined earlier this is where they are being used okay the push message will start with either if it's hot or if it's code following that would be the present values okay the pressure the temperature and the humidity okay then what I'm doing is that I'm going to pass this push message to my P function that I have just defined so basically you will first convert the push message into adjacent data and then it will pass it through the communication so this is what is happening here okay same thing will happen in case it is the temperature falls below the cold range as well okay then I'm going to create a JSON file and then call C dot perform so this basically will initiate the curl operation to start finally to capture the response from the server you can actually use the buffer rage okay so with this we've come to a conclusion let me just show you the final part of this okay so make sure that you're closing the communication through curl so you see dot close okay this will ensure that the communication done through curl is closed as well as you ensure that the general purpose input output is cleaned up so that new values are being so now let's execute the final program that's Python find a program dot people now as you see on the Raspberry Pi it's showing me that it's presently 35 degrees centigrade okay started getting notifications on my phone let me just share this phone screen with you okay and you can see there's a variation with respect to the temperature shown on the Raspberry Pi as well okay let me show you first my phone screen now if you see here it's actually showing me multiple notifications being generated okay it's showing me that it's cooled presently and here's the complete list of the temperature notifications so I'm getting a constant notification with respect to the change in temperature so you can see it's continuously being generated here as well so this is something that is really helpful when you're working on R with respect to a real-time scenario so like I said NASA extensively uses this for their own purposes of measuring the temperature pressure both in their scientific research area as well as the shuttles and space stations that they use okay so with this we come to a conclusion of our demo session okay let me go back to my presentation and let's just have a summary of what we've discussed as far as a session okay so let's just summarize what we've discussed as part of the session we started off by first understanding what is IOT then we moved on to understand why we need IOT as well as the various benefits and features of IOT and then we started with the demo where we installed raspbian on raspberry pi and finally we created a weather detection system in using raspbian and sensor so with this let's end this session meanwhile if you do have any questions as well as if you have any feedbacks feel free to pull it up in the chat box so with this thank you and goodbye hope you have a great weekend I hope you enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply to them at the earliest do look out for more videos on our playlist and subscribe to our ad rekha channel to learn more happy learning

49 Comments

  1. edureka! said:

    Got a question on the topic? Please share it in the comment section below and our experts will answer it for you. For Edureka IoT Course curriculum, Visit our Website: http://bit.ly/2Qlej4v Use code "YOUTUBE20" to get Flat 20% off on this training.

    May 17, 2019
    Reply
  2. Tech Make said:

    Thanks sir for this good information

    May 17, 2019
    Reply
  3. Mrutyunjaya S Hiremath said:

    i relay helpfully for all engineering students ,,thank you soo much

    May 17, 2019
    Reply
  4. SHRIKANTH Y said:

    Thank you and explained well

    May 17, 2019
    Reply
  5. Vijaya Kollapaneni said:

    Thank u so much

    May 17, 2019
    Reply
  6. Govind Gopalia said:

    Awesome video on iot …..

    May 17, 2019
    Reply
  7. Amir Astin said:

    Great video introduction to IoT. Thank you for sharing.

    May 17, 2019
    Reply
  8. Limon Khan said:

    thank you

    May 17, 2019
    Reply
  9. Richard Mortimer said:

    Great explanation, thank you very much.

    May 17, 2019
    Reply
  10. Sujeet jaiswal said:

    thank you

    May 17, 2019
    Reply
  11. Venkatesh Achar said:

    Once you copied the Raspberry Pi OS in to SD card, the SD card is plugged in to Raspberry Pi board. how did you booted the Raspberry Pi board with Raspberry Pi OS. What are the physical connections made between your host machine and Raspberry Pi board?
    please explain.

    May 17, 2019
    Reply
  12. INFINITY Knowledge said:

    After b.tec in ECE going with us iot for better future or not

    May 17, 2019
    Reply
  13. VIJAYAKANNAN R said:

    How do I connect a AWS device Simulator with IoT?

    May 17, 2019
    Reply
  14. Raghu Yadav said:

    Great demo sir, Big Thanks to you for this presentation, keep rocking…

    May 17, 2019
    Reply
  15. Siva said:

    Hi, to learn iot what are the prerequisites.

    May 17, 2019
    Reply
  16. hanumantharao konakanchi said:

    what are the prerequisites to start IOT it course

    May 17, 2019
    Reply
  17. Sheetal k said:

    Is it classroom training or online

    May 17, 2019
    Reply
  18. Anantwar Gangadhar said:

    Superb video & interesting…

    May 17, 2019
    Reply
  19. Daya Hadiya said:

    thank you good video……
    provide more IOT videos

    May 17, 2019
    Reply
  20. Thomas Ludot said:

    nice tutorial, fun and valuable πŸ™‚ Thanks

    May 17, 2019
    Reply
  21. bhaskar garg said:

    learned a lot from it, upload more videos like this

    May 17, 2019
    Reply
  22. Narender Reddy Vanga said:

    good lecture.. thank you

    May 17, 2019
    Reply
  23. madwaraj sandeep said:

    Jst fabulous. The way u explained the code nd everything is really good. Try to upload more and more videos on IOT.

    May 17, 2019
    Reply
  24. STATUS FREEKS said:

    which rasberrypi module and sensors did you used in this session??

    May 17, 2019
    Reply
  25. Ines A said:

    Hello! Thanks a lot for this helpful statement. I have some questions though. Did you make any other settings on your phone in order to link it to that particular program. I got confused when you opened INSTAPUSH, you just specified "message" , why not "pushMessage"? Thank you

    May 17, 2019
    Reply
  26. Winarno Abdullah said:

    good job

    May 17, 2019
    Reply
  27. Akshay Pandey said:

    how to send image to flask server from python project

    May 17, 2019
    Reply
  28. bjag12345 said:

    Very nice video

    May 17, 2019
    Reply
  29. Karthiga At_Almonds said:

    Made a grt nd cool job. tats great

    May 17, 2019
    Reply
  30. Hans zimmer said:

    is that a TESLA ROADSTAR?At 2:34? Well nice explanation .

    May 17, 2019
    Reply
  31. shekhar nandanwar said:

    Upload more videos on IOT
    Great learning experience on edureka keep it upπŸ‘

    May 17, 2019
    Reply
  32. nikhil dhanashri said:

    Tqsm for this video. It reduced my half of work for presentation on IoT .tq

    May 17, 2019
    Reply
  33. Renuga Devi said:

    Really it is very nice video. The instructor is giving clear explanation… His pronunciation and voice is good. i want to do on line course on IoT, guide me in this…

    May 17, 2019
    Reply
  34. Kiran Varri said:

    Very good one…thank you !! πŸ™‚ #IoT made easy…

    May 17, 2019
    Reply
  35. Harunur Roshid said:

    i want to know about IoT but how? please share your next lecture of your channel

    May 17, 2019
    Reply
  36. Devansh Sharma said:

    I wanna contact you. Give me your email id.

    May 17, 2019
    Reply
  37. Bvn Rao said:

    Good one on basic concepts of IoT

    May 17, 2019
    Reply
  38. Midhun Koithodan said:

    Great effort in this ..looking forward for moreπŸ‘

    May 17, 2019
    Reply
  39. metalgear32 said:

    Thanks.

    May 17, 2019
    Reply
  40. aneesh vr said:

    Thank you so much.
    Very helpful tutorial

    May 17, 2019
    Reply
  41. Bhagyashree Mohanta said:

    Dear sir. I need the PDF of all ur tutorial. Please reply how do i get this.

    May 17, 2019
    Reply
  42. Rakhi soni said:

    this was so great. I seriously want some suggestions from you for future work in iot as i am a research scholar and working in IOT. suggest me some thesis topic I can work on. it would be a big help. please or for the communication can I call on the given number you have provided for Indian region.
    please reply.

    May 17, 2019
    Reply
  43. janu shaik said:

    I want to learn IOT I don't no any thing please help me

    May 17, 2019
    Reply
  44. BK Rajendra said:

    hii sir. I am student of tyit .& I have subject iot ..can you plz send lecture notes of iot..

    May 17, 2019
    Reply
  45. Pavankumar K said:

    It's need any programing Knowledge to learn LoT

    May 17, 2019
    Reply
  46. Narasaiah poolathota said:

    Hi
    I want learn iot can please suggest me what are the skills I should know

    May 17, 2019
    Reply
  47. bhola singh said:

    very nice video

    May 17, 2019
    Reply
  48. Srity ROY said:

    Does IOT has good future and scope in jobs?

    May 17, 2019
    Reply
  49. Pavankumar K said:

    I need traNing about iOT…

    May 17, 2019
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *