Building Arduino IoT Projects using the Arduino IoT Cloud | Lee Assam | Skillshare

Building Arduino IoT Projects using the Arduino IoT Cloud

Lee Assam, University Instructor, Software Developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
54 Lessons (6h 14m)
    • 1. Introduction

      3:36
    • 2. What to expect

      6:25
    • 3. What is the Internet Of Things?

      3:10
    • 4. What is the Arduino IoT Cloud?

      3:34
    • 5. Understanding Arduino IoT Cloud Terminology

      3:18
    • 6. Overview of the Setup Process for your MKR Board

      1:57
    • 7. Creating a free Arduino IoT Cloud Account

      1:41
    • 8. Using the Arduino Desktop IDE or the Arduino Web Editor

      2:55
    • 9. Installing the Arduino Create Plugin and Setting up your Arduino MKR Board

      10:25
    • 10. Overview of the Arduino MKR WIFI 1010

      4:26
    • 11. Project Overview - Controlling an LED from the Cloud

      0:59
    • 12. Wiring the Circuit

      4:06
    • 13. Configuration in the Arduino IoT Cloud

      2:11
    • 14. Making Code changes

      6:39
    • 15. Testing it out

      2:18
    • 16. Reviewing Project Files

      6:05
    • 17. An Overview of the Web Editor

      10:04
    • 18. Detailed Code Review for our LED Project

      8:53
    • 19. Project Overview - Taking Analog Readings

      1:37
    • 20. Wiring the Circuit

      13:13
    • 21. Configuration in the Arduino IoT Cloud

      6:12
    • 22. Making Code changes

      18:51
    • 23. Testing it out

      5:55
    • 24. Project Overview - Detecting External Button Press Events

      1:37
    • 25. Wiring the Circuit

      13:13
    • 26. Configuration in the Arduino IoT Cloud

      6:12
    • 27. Making Code changes

      18:51
    • 28. Testing it out

      5:55
    • 29. Using a Third Party Library to handle Debouncing

      6:57
    • 30. Testing our Debouncing Changes

      2:12
    • 31. Project Overview - Motion Sensor Alarm that calls your Cell Phone

      1:37
    • 32. Wiring the Circuit

      13:13
    • 33. Configuration in the Arduino IoT Cloud

      2:41
    • 34. Making Code changes

      18:51
    • 35. Testing out the Alarm

      3:40
    • 36. Overview of If This Then That (IFTTT)

      4:22
    • 37. Enabling an Applet on IFTTT

      7:34
    • 38. Creating an IoT Webhook to IFTTT

      12:35
    • 39. Testing our Custom IoT IFTTT Applet

      3:41
    • 40. Project Overview - Measuring Temperature and Humidity

      1:37
    • 41. Wiring the Circuit

      13:13
    • 42. Configuration in the IoT Cloud

      6:12
    • 43. Making Code Changes

      18:51
    • 44. Testing it Out

      5:55
    • 45. Project Overview - Temperature-Controlled Self Regulation IoT

      1:37
    • 46. Using a Transistor as a Switch to Control our Fan

      5:39
    • 47. Parts Needed for the Project

      1:56
    • 48. Reviewing the Circuit Diagram

      3:08
    • 49. Wiring the Circuit

      13:13
    • 50. Configuration in the IoT Cloud

      6:12
    • 51. Reviewing the Dashboard that will be created for the project

      6:34
    • 52. Reviewing the Algorithm that we will use for our Project Code

      8:33
    • 53. Making Code Changes

      18:51
    • 54. Testing it out

      11:12

About This Class

0fbad081

In this course you will learn about the NEW Arduino IoT Cloud Platform that allows you to easily build Internet of Things (IoT) applications and projects that connect to the Cloud.

Go from Zero to Hero and learn how to quickly build secure Internet of Things (IoT) apps and dashboards using Arduino that connect to the Cloud.

In this course, you will build projects like:

  • Creating a motion sensor alarm circuit that calls your cell phone when motion is detected

  • Creating a self-regulating temperature controlled system

What you will Learn

In this course, you will learn:

  • A basic understanding of what is the Internet of Things

  • IoT Terminology

  • What is the Arduino IoT Cloud Platform

  • How to setup your Arduino MKR boards to connect to the Arduino IoT Cloud

  • How to use the Arduino Internet of Things (IoT) Cloud Platform to build IoT apps with minimal code

  • How to build dashboards to monitor your Internet of Things (IoT) projects , peripherals and sensors

  • How to incorporate Webhooks in your Internet of Things (IoT)  Applications

  • How to use the If This Then That (IFTTT) to integrate services into your IoT Applications

  • How to use Arduino MKR Boards to prototype Internet of Things (IoT)  Projects

  • Securely connecting your Internet of Things (IoT) device to the Cloud

  • The ins and outs of the Arduino Web Editor

Who this course is for:

  • Students

  • Internet of Things (IoT)  Hobbyists

  • Electronics Hobbyists

  • Electrical Engineers

  • Makers

  • Tinkerers

What previous knowledge should I have:

  • A basic understanding of Arduino

  • A basic understanding of Programming (C preferred)

  • Be willing to learn

Why is the Arduino Internet of Things (IoT) Cloud Platform important?

We all know and love Arduino Platform for tinkering and building prototypes. But when it comes to building IoT projects that connect to the internet, using Arduino by itself gets messy.

Here are some of the challenges with Building IoT Apps with simple flavors of Arduino Boards :

  • You need to use an Arduino board that has Wifi built-in or use additional modules like the ESP8266 or ESP32 to enable internet connectivity

  • You have to worry about how to secure connections to the internet from IoT devices to prevent hackers from intercepting your IoT data

  • Connecting to the Cloud is also challenging as you have to write custom code to handle integrations

  • Building Dashboards to monitor and control your IoT apps requires writing additional custom code and programming and this can get messy very quickly

The Arduino IoT Cloud was created to solve these issues.

The Arduino IoT Cloud allows you to:

  • Easily, Securely and Seamlessly build Arduino Internet of Things (IoT) projects that connect directly with the Cloud

  • Quickly allow Arduino MKR Boards to connect securely connect to the Cloud

  • Create WebHooks to easily connect backend APIs and Services to your Internet of Things (IoT) Projects

  • Monitor your projects in real-time by creating dashboards and widget with a few mouse clicks

Join the Arduino IoT Cloud Bootcamp Course today and learn to build Arduino Internet of Things (IoT)  apps that connect to the Cloud the easy way!

What you’ll learn

  • Build working IoT Projects that connect to the Cloud
  • Learn how to use the Arduino IoT Cloud Platform
  • Learn how to use the MKR WiFi 1010 Arduino Board
  • Build Arduino IoT Applications in the Cloud
  • Build Dashboards for your IoT Applications with minimal code
  • Use If This Then That (IFTTT) to integrate Webhooks into your IoT Applications

Are there any course requirements or prerequisites?

  • Basic knowledge of Arduino
  • Basic understanding of any programming language (C Programming Language preferred)
  • Basic knowledge of Cloud Concepts
  • Willingness to learn

Who this course is for:

  • Arduino makers that want to learn about the Arduino IoT Cloud Platform
  • IoT Hobbyists
  • Students
  • Electrical Engineers
  • Electronics Hobbyists
  • Makers
  • Tinkerers

Transcripts

1. Introduction: Arduino is the platform we have all come to know and love. It allows us to easily get tinkering with electron ICS learned programming on build some really cool projects. When it comes the building Internet of things applications, however, things get a little more challenging. With Arduino, you probably have to use boards which have WiFi functionality built in, or use additional modules like shields or the DSP family of adults allow Internet connectivity. Then we have to worry about how to secure communications to prevent hackers from intercepting our hyoty data. Connecting to the cloud is also a little challenging, and we have to write custom code toe handle. These integrations also building dashboards, the monitor and control your I A D EFs requires writing additional coolant programming, and things get messy very quickly. Well, thankfully, the folks that brought us aren't we know that some thinking about all of us on thus was born the artery? No, I ot cloud. This is a cloud based platform that allows you to easily, securely and seamlessly filled IOC projects that connect directly with the cloud we are doing. No, I ot cloud is built quickly. Allow your art window maker boards to connect securely with the cloud. With a few lines of code, the platform allows you to create Web hooks to easily connect back and AP eyes and services and the quickly build out dashboards and widgets for your things, the monetary applications and sensors in real time. In this course, you will get a world wind tour of the Artery notoriety, cloud platform and go from zero to hero after first getting a good understanding of what the Internet of things is. On the Arduino I ity cloud, you will learn how to set up your board and connected to the cloud. With a few clicks and minimal coat. We will start off with simple I ot projects and advance the building applications. Make a motion sensor alarm that calls your cellphone when it is tripped. We will also cover. We get this than Bats services platform that allows you to build cool I ot integrations from your icy projects. We will also build some rather complex projects like a fully self regulating, temperature controlled i ot system that harnesses the power of the Arduino I ity cloud. This could be used for greenhouse, your raspberry pi heat exchangers system your bedroom or virtually anywhere you want to regulate temperature, complete with a fully managed dashboard. At the end of the course, you'll be confident in using their Torino priority clouds pat for toe quickly and easily prototype and build out I ot projects and applications that integrate seamlessly with the crowd. We will also learn how to create dashboards and widgets, monitor and interact with our sensors and IOC peripherals in real time with a few clicks and a couple of lines of code. So what are you waiting for? Let's get started learning to build our dream. No coyote applications for the cloud. See you in the course. 2. What to expect: Hello. Hello, everybody. And welcome to the Arduino I ot cloud boot camp Course. I'm so so glad that you have decided to join the course. And I'm looking forward to all the exciting things we will build and all the things we're going to learn. My name is Lee Assam on I will be your instructor. I'm an electrical engineer and I d software architect with a passion for the Internet of things. I'm also an inventor and hold up multiple patterns and I have over two decades of professional industry experience before we begin the course. I wanted to give an overview of what to expect on what you will need. Let's talk a bit about who this course is. Four. The ideal student for this course is someone who is a beginner to the Arduino variety cloud platform, but someone who also has a little bit of previous Arduino and programming experience. They could be a student and I o t hobbyist. Oh, an electrical engineer or an electron ICS hobbyists maker or tinker. Now we know about who the causes for. Let's dive into what you should expect toe learn in this course. This course covers Thea hard. We know Coyote Cloud platform and how it makes it easy to build and prototype your piety projects in the crowd. We will first cover some basics about I ot and Yard we notoriety cloud platform so you'll be introduced to some foundational concepts from which will build upon. Then we'll tackle how to set up your Arduino maker board and show how to connect it to the Arduino lt Cloud platform. We will then look at building projects and dashboards that can be controlled from the Internet, starting with simple examples and then moving on to more complex projects. We'll also learn how to integrate Web books to the if this than that platform to extend the functionality of your Rieti ups with additional services and e p eyes. Then we will also learn to build a more complex, self regulating I ot project, complete with a dashboard that could be managed from the clothes so you'll get the entire picture of how the ecosystem works. Here's a look at what the course will not cover. The course assumes you have some prior experience and knowledge about the Arduino platform . We will discuss in detail. However, the new maker boards that work with the Arduino Cloud. But we will not cover the basics of Arduino itself, although we explain in detail and go through line by line code reviews for all the projects that we will build. The course doesn't teach you programming from scratch. All court and resource is will be provided unexplained. But I'm assuming you have some basic programming knowledge. C and C Plus plus is a language will be using in the course. Here's a look at what you will need for the course. The course uses the new Meeker WiFi 10 10 Arduino board, in addition to several other components that form the basis off any starter kit for Arduino , I have compiled a parts list for the course, complete with links to get items from online retailers. You may also shop for components based on your per food electron ICS provider in your location. I would also ask that you have a willingness to learn please actually build out the circuits and write the code. Along with the videos have provided step by step instructions to build circuits, and we will write to court together. I also review sick it diagrams and schematics, so you'll understand how things are wired together. Be patient, double check your circuits and just have the willingness to learn, and you'll reap the most rewards from this course. As I mentioned, I will not be teaching programming and quoting from scratch. But if you have prior programming experience in any language that will help, I still explain cool for projects in detail. But if you've never programmed before things maybe a little more challenging for you as we work through projects, the project overview videos will contain on additional linked resource as a PdF presentation for the project, complete with parts needed for that specific project. Learning objectives on a circuit diagram or schematic for the project. Please download these and you can view them as a reference. I have provided all the code we will use for the projects. Here's a link to the get help report to get all the code. There are two ways to down with the court. First, you could just head over to the get repolling in a browser. Then you can click on the clue or download link. Then they downloads it, and you can see this a file Once that saved, you can open it up and double click on it to extract the project files. Here you'll be able to see all the various projects on all the code associated with those projects. So inside the Beach folder, you'll actually see a ZIP file, which contains the entire project packaged up. And if you are going to import this into the Arduino Webster, it's already packaged up for you. And there's also an unzipped version of the project, where you can directly access the code. Another option is if you have get installed, you conclude the repository. So from a terminal or a command print he can take and get Cloonan. And then you can put in the link to to get help, repository for the code for the course and then hit. Enter Onda. As you'll see the repository will be pulled down and you'll get all the files. So those are the two different ways that you're able to pull down the code and the resource is for the course. So with all those housekeeping rules behind us, let's get the show on the road and get started with the Arduino I ot cloud boot camp 3. What is the Internet Of Things?: so you may have heard about this buzzword. The Internet of things. Well, what is it simply to find it? Is the interconnection fire the Internet of computing devices embedded in everyday objects , enabling them to send and receive data? Another way of putting it is that the Internet of things is the extension of the Internet connectivity into physical devices and everyday objects. These devices can communicate and interact with others over the Internet, and they can also be remotely controlled and monitored. So why is Aled this important? And why should this matter to you? Chips and sensors that are embedded in the things that surround us can collect untranslated valuable later. This data helps us better understand how these things work helps us to sense the environment around us and also helps us to understand how things collectively work together . By combining these connected devices with automated systems, it is possible to govern information, analyze it and create action toe help someone with a particular task, or learn from a process. Here. Some practical examples of the Internet of things in terms of home automation I ot devices can include lighting, heating and air conditioning, media, UN security systems. Wearable technology. Such a smart watches can enable us to monitor our personal health and even warn us of health conditions to be addressed. Self driving car technology also employees sensors and cameras, which analyzed the surroundings in the manufacturing field. Io teak and helped drive efficiencies by using data from devices equipped with sensing identification. Processing communication on actuacion problems in an assembly line can be proactively identified on trouble shooted without human intervention. It all starts with the devices themselves. These devices contain sensors which take measurements and securely communicate the data with an Internet of things platform. This platform can collect and aggregate the data from many different devices on comm. Provide analytics and machine learning. To help us understand the world around us, this convention feed into business applications that address industry specific needs. It is estimated that they will be over 75 billion I ot devices by 2025 on the global market value of I. O. T. Is projected to reach 1.6 trillion by 2025. There has never been a better time to learn about Coyote as the job market for I ot developers architects on engineers is expected to skyrocket in the next few years. This can be a lucrative career opportunity 4. What is the Arduino IoT Cloud?: Arduino as we knew it is the popular open source electron ICS platform based on easy to use hardware and software. Over the years, Arduino has been the brain off thousands of projects from everyday objects toe complex scientific instruments. It has gained a massive following with a worldwide community of makers, students, hobbyists, programmers on the professionals would be growing popularity of the Internet of things on the adoption of public cloud infrastructure by the ICTY community. The next logical step for the makers of our dreams was to offer a platform that allows our DWI no beast hardware to integrate seamlessly with the cloud. Thus was born the Arduino I ot cloud. The court tenants of the Arduino Coyote Cloud platform are that it is easy for beginners and fast for professionals. It is based on the Arduino environment, which we are all familiar with. It is geared to allowing you to quickly build a remote sensor. Monitoring using widgets under you are allowed the flexibility to easily connect spreadsheet, database or trigger automated alerts using Web books. It is also secure and robust, and that devices are secured using X 509 certificate based authentication, more on that a little bit later on on. It is based on open hardware and open I ot standards. In order to take advantage of the platform, you will need a maker. Board options include the maker 1000 which has WiFi built in, or the newer maker 10 10 which has both WiFi under Bluetooth capabilities built in. Other variations of these boards will soon be available and even open source options will soon flood the market. The prices of open source Clunes of these boards will become less over time. Currently the original Arduino maker 1000 and then you are Do we know Maker 10 10 runs for about $34? Thes are still very affordable boards. Either of these boards can be used for this course. These boards were designed to enable easy prototyping of Internet of things, projects that connects seamlessly un securely with the cloud. Using the yard, we know I d cloud platform. In order to use the Arduino ality cloud platform, you will need the first sign up for an Arduino Coyote Cloud account, which is free. We will walk through this process later on. The Arduino multi cloud platform allows you to get your device up and running quickly connected to a WiFi network and then communicate with it from anywhere he's in the cloud. You can then prototype your priority applications and use widgets to easily create a user interface, allowing you to monitor on remotely control your device Later on. In the course, we'll go through the process off. Setting up a device on will build projects from scratch so you will become approve at these concepts. But before we dive into the hardware and set up in the next lesson, we're going to review a few of the Arduino priority cloud components and terminology, and this week you will understand the ecosystem of I ot as we build out our priority applications. 5. Understanding Arduino IoT Cloud Terminology: when using the Arduino variety platform, there are few concepts we need to clarify. I o T. Applications are typically made up of a few basic components. These include devices which collect detail or control something, things which defined the logical representation of what is being sensed. Properties which to find the rigatoni or read write characteristics of a system. Events which are notifications when something has occurred. Software which defines the behavior of the hardware and, finally, a cloud application to store data or remotely controlled their equipment. Let's look at these in a little more detail. Devices are physical objects, like a hardware board that can be contained inside a product. Example. The maker WiFi 10 10 They are the physical hardware, which runs the software, reads sensors, controls actuators on communicates with the Arduino I ity cloud the next component. You need to be aware of these things. Things represent the inherent properties of the object, with little reference to the actual hardware used to implement them. You can think of things as a logical representation of what is being sensed. Each thing is represented by a collection of properties, for example, temperature, light speed, moisture and humidity up next. Our properties properties are the quality that the finally characteristics of a system, so as an example, your property can be a read only setting to indicate that they are doing no. I ot Cloud can read the data but cannot change the value of the property. Ah, property can also be read and write, which means that the Arduino anti cloud can remotely change the property's value and send an event notification to the device. So, for example, a device could have a sensor which will measure room temperature. This would be Riedel. Me. A thermostat, however, will be able to change the room's temperature. This would be a read write property. Next our events. The Arduino variety cloud becomes aware of events when it receives application messages that indicate something has happened. For example, if the temperature changes by a certain amount, this message can be sent to the I o T cloud, and a cooling system can be turned on to regulate the temperature. Next is software, which is essentially a nard we know sketch. This defines how measurements will be taken and how your hardware device will communicate with the Arduino piety cloud on the finally these old form part of a cloud application which packages everything together. So now that we have all those concepts down, let's move on to creating our heart. We know cloud account, installing the software we need to build our I ot application and go through the process of setting up our board. 6. Overview of the Setup Process for your MKR Board: Let's quickly go over this steps. You need to get started working with the art we know Coyote Cloud platform. We will go through each of these steps in detail, but first, here's a high level overview of the entire process. First, we will need to create on Arduino account. This is a free account and set up is a breeze. We will need to do this as we will be using the Arduino Web editor and this is how we will set up and manage our board and I ot projects. Next, we will need to install the Arduino create plug in. This plug in allows us to upload sketches from the Bowser unto our boards fire USB cable or network. Once the plug in is installed, we will then move on to the process of setting up our Mick aboard the Arduino Create website makes this easy for us and provides a step by step process to guide us through everything we need to do. Finally, once our borders set up, we can then jump in and start building our Arduino cloud I ot projects just a general note to be aware of as we progress through the course, and we walk through various Web browser screens. There is a possibility that the screens may have changed as updates may have occurred. The general concepts should remain the same, however, and you should easily be able to follow along. Things may have moved around a bit, but if you look around the screens, you will find the settings and options we discuss. Also note that I have recorded this course when the Arduino Hyoty Cloud was released in beta mood. So changes, tweaks and updates are possible as the platform goes into general release, which me makes screens look slightly different. I'll be sure to keep things up to date, but you should still be able to follow along with the steps as we progress in this course. 7. Creating a free Arduino IoT Cloud Account: in order to get started using the Arduino I ot cloud platform. One of the first things that we'll need to do is to create an Arduino I OD cloud account, So head over toe, create dot Arduino dot cc in the browser, and from this page, you can click on the sign in link on a top right. And here is where you would normally log in to your Greenoe rt cloud account in order to create a new account. You can sign in with Google with this link at the bottom of the screen here. Or you could go ahead and click on the Create a new account icon here. You just need to provide a few pieces of information so you will create a user name, provide an email address and then set up a password and confirm your password. After you have provided those pieces of information. There are a few radio button options here that we have to look over. So the only one I would advise to check here to sign up is the 1st 1 where you, of course, would confirm that you have read the privacy policy in terms of service and there are links here where you can click on the privacy policy and terms of service toe Read those finally check that I'm not a robot that link a department of the screen and then you go ahead and click on Create account. So go ahead and completely steps to create your heart. We know already cloud account. I have already created my account. So complete these steps as we will need this account later on, when we build our Arduino coyote cloud projects. 8. Using the Arduino Desktop IDE or the Arduino Web Editor: When working with Arduino boards, you have a couple of options for the programming environment that you use the food choices , the yard we know best up I D E, which is software that can be downloaded and installed on your computer to download and install the I D from the mean are Greenoe webpage. You can click on the software link at the top and then click on downloads. This is the option that new start we know users are familiar with. There's a version of the I. D for Windows, Mac and Linux. The benefits of this option is that once it is installed, he don't necessarily need an Internet connection toe work on your Arduino projects. However, the newer approach is using the Arduino Web editor. In fact, that is the approach we will be using for this course. To get to the editor from the top software menu, you can click on online tools. Alternatively, you can enter the link create that Arduino dot cc and a browser. Both of these options get you to the mean Arduino Create page. You can then click on the Arduino Web editor using the Web editor instead of the desktop I D is beneficial for a variety of reasons. The first is the Web I. D. E is always kept up to date by the Arduino group. You no longer have to install updates or worry about incorporating the leaders Developments in your projects. These will be available automatically for you once you use the Web editor. Another reason is that the Web I D E integrates seamlessly with the Arduino Coyote Cloud. Since we will be working with coyote projects, you can work on your code and manager properties and things and tie all of these easily together on the Web and cloud packed words. Finally, your projects reside in the cloud, and once you have access to a browser and the Internet, you'll be able to view and work on your projects from anywhere. The Web editor also makes it easier to export your projects, import existing projects, find third party libraries and as well as collaborate with others on projects. There is still a small component called the Arduino create plug in that has to be installed . But working with the Web editor is very flexible and convenient. We will become very familiar with the weapons ER and its capabilities as we progress through this course, and there's an entire section devoted to describing its various features. Let's now move on to installing the Arduino Create Plug in, which is needed to allow our Web browser to communicate with our Arduino board. 9. Installing the Arduino Create Plugin and Setting up your Arduino MKR Board: Welcome back, everyone. In this lesson, we're going to go through the process of setting up the yard we know create plug in and setting up our maker board and getting it connected to our WiFi network. From a Web browser perspective, I would highly recommend you install and use Google Crume. This is the browser that works best and supported by the Arduino. Create plug in. So if you don't have Google crewman stored, please pause the video at this time and do that. Now, when you're done installing Google Chrome, we can get started. Okay, so now that you have Google, Corman's told, or if you have it installed already, open it and head over to create dot Arduino dot cc in the address window. This will bring up the Arduino, create console to get started on the install and set up process quick on the getting started tile. Remember, icons may have changed a bit and features me of moved around as thesis itis updated. But in general, if you look around on the screen, you should still be able to follow along and find the features we discuss. So click on the getting started tile here on the getting started page, you're given an option of boards to choose from, since we're working on the Arduino maker WiFi 10 10 word click on the option to set that particular version up. So this is the second option here on our screen. So go ahead and click on that link, and next we are presented with a summary of what is involved in the set up process. So first we'll need install. The hard we know create plug in. This essentially is a tool that would allow us to upload sketches from the browser unto our boards, fire a USB cable or the network. Next, we will work on connecting our maker board to our WiFi network. Then we will configure a thing in the Arduino create Coyote Cloud to be attached to our board. Onda. Finally, we'll demonstrate how everything works so they get started. Now I'm going to click on the log in button at the bottom of the screen, so that would load up the mean screen, which shows all the steps that are involved in our set of process. So the first thing that we need to do is download the Arduino plug in. So I have a Mac running Mac OS and I get the option for a Mac. And of course, if you're running a Windows or the Knox machine, you'll get the appropriate choice for those operating systems. So I'm gonna click on the download button here, and I'm just pointed down. Go back to my desktop. So once that is downloaded going, going to open it up and I'm just going to double click here on the installation file, Onda basically double click again. And of course, I on the mark. I get a warning that this enough that was downloaded from the Internet and it's OK, we know that what we're installing. So I'm just going to click on open. I'm just going to click on OK here on this message, and now I am presented with a set up menu on. We're going to go through the steps of installing the plug in someone and go ahead and click next. I I'm going to accept the agreement like next. I'm gonna leave the installation directory here by default. Whatever it shows up here as weaken, leave that the fall sitting click on next. Next we get a warning. Do you intend to use the agent with a browser oven on Google, Crume or Firefox? Let's leave no selected, since we will be using Crume going next. And now we got a message saying that it's now ready to begin installing the Egypt on your computers. I'm going going to go ahead and click on next year and let's let it run through the installation process. So that's it. It's finished it around pretty quickly. I'm going to click on finish, and here we can actually close off this window. And what it does is it was actually trying to detect that the plug in was installed on. And of course, we timed out because we were going through the installation process. But now that we actually install the plug in, let's go ahead and click on, try again and see if it will detect it. So I'm gonna click on Dragon Onda looks like it was able to detect it, and there we got the message that the plug in was correctly installed. So next up I'm going to click on the next button, and here it's prompting me to connect the Arduino to my computer so I'm going to go ahead and do that. No women of the U. S. B cable is plugged into the maker board and the other end I'm going toe connected that to my computer. So I'll do that now and it timed out. So let's go ahead and click on track again. Okay, so it did detect my board, and now we are asked to give our board a name. Now you could name this anything that you want. You can have any customized, namely aboard, but I'm just going to use Thebe fault That's given their maker WiFi 10 10. The make things simple. So I'm going to enter into here Meeker WiFi 10 10 And it actually inserted the underscores for us, so this should be acceptable maker on the score. WiFi and score 10 10. So once that's done, let's go ahead and click on next. So now it's going to go through the process off, doing some configuration to make our maker board I ot ready. So there is a crypto chip on the board, so it's going to go to the process of configuring that and basically the benefit of the integration of Meeker boards to the Arduino Authority Cloud is that we can have secure communication between the device on the cloud And of course, for i o t devices on dire. The things being ableto communicate securely with the cloud is off apartment importance. Because we were doing one hackers sort of getting access to our devices, be able to listen in on any communication that is happening between the device and the cloud, so that should all be encrypted. So let's go ahead and click on configure. Now, This process could take up to five minutes or so as we see here. So I am just gonna pause the video, let this run, and we're gonna pick it back up. When this process is complete, let's let the process run is so Now the process is completed as far as a crypto, and now we have to enter WiFi data, and this is to get our board connected, our WiFi nips. And when I click on enter WiFi data and what it actually did, it navigated to the secret top here. So it's at this point you would enter the WiFi name or your SS I d. For your WiFi network here in this stop textbooks, and then Baloo would be the password for your WiFi network. So I'm going to enter the values for my WiFi network now. So once those values have been entered, I'm going to click on the upload button. So now it's uploading those credentials to my ward securely. Let's give that a few seconds to complete here and now. The board is currently connecting to the Internet and the yard we know already cloud. So it's validating our credentials, and it looks like we are good to go. So it was able to connect it aboard, and nowhere at the point where we can test that our board works and actually that we're able to send instructions here from the consul to the board. So now let's go ahead and test this out. So from the council here, I'm just gonna put in on the message on and click on, Send on if you'll notice on the Arduino board the on board led turned on. So it was able to send that instruction successfully over the Internet starboard to turn it on. So let's go ahead and try taking it off. So I'm just gonna type in all FF or upper keys here and then click on Send Andi. You'll notice that the led came off, so that means that all our set up was successful. Andare board is now connected to the Internet. Our WiFi network, the Arduino create plug in, was able to successfully upload a sample sketch toe aboard and everything is working. So at this point, we are good to go to work on our I ot applications. And this would complete the set up process that's needed to get our maker WiFi 10 10 board all enabled and ready to go. So from here can click on next. And here we are, all set. So it says, Congratulations. You're all set and we are done. So this completes the set up process for our maker board. 10. Overview of the Arduino MKR WIFI 1010: Hi, everyone, and welcome back to the course in this lesson. We're going to dive a little deeper into talking about the main hardware we will be using for this course. Although there may be several options that are available on more. Meeker boards continue to be released from the Arduino consortium. For this course, we're going to be focused on the Arduino maker WiFi 10 10 board. The maker WiFi 10 10 is a powerful board packed in a tiny package. It also study two bit computational power, low power WiFi and has a crypto chip for secure communication using shar to 56 encryption. It also easily integrates with the Arduino software i d E for code development and programming. Both the desktop are doing No i d. On the Web editor. It has a U. S report that could be used to supply fight bulls power to the board on the light pole charging circuit that allows the board to run on battery power or an external five bold source charging the lipo battery while running on external power. Switching from one source to the other is done automatically warning. Unlike most Arduino boards, the maker WiFi 10 10 board runs at 3.3 volts. The maximum voltage that the I opens can tolerate is three point revolts, so applying voltages that are higher than 3.3 volts as inputs toe, any pin can damage the board output. The 54 devices by a D five old pin from the board. The digital devices is permissible but bi directional communication with fireable devices. But those fi pulled signals coming back into the board needs proper level, shifting down to 3.3 volts to prevent damage to the board. Let's take a look in a little more detail about the tech specs for the Arduino maker wife fight and 10 board. Here I am at the Arduino website and I'm on the maker attention WiFi page and here we're taking a look a tech specs. So, as you can see, we mentioned before that the board is powered by foibles on this congee through the USB connector, or V. In the operating voltage, as we mentioned of depends are three point revolts. There are eight digital eye opens and of for Pwr more pulse width modulation pins. We have 12 of those. It supports you art SP I I squared C and I two c communication. There is a new onboard low power WiFi chip toe. Allow WiFi connectivity. There are seven analog input pins and one analog output pen, and this analog output pen also allows for 10 but digital to analog conversion. It also has eight external interrupts, and the maximum DC current put I open is seven million times from a flash memory perspective. The board has 2 56 K flash and 30 to keep s RAM. However, unlike traditional Arduino boards, there is no E. Prum. So what this means is you can't actually store any information on the board. Wants to. This powered off. There's a built in led that's a lying to pin six on. But also there is a full speed USB device, unembedded host, which is included. So those are a little specifications about the board. So it is a very inexpensive device on the packs, a lot of power in a tiny frame, allowing you toe robustly and securely connect to the Iot T cloud. And it's a great device for prototyping your hyoty applications. So now that we have an overview of the maker wife fight and 10 board. Let's get the show on the road and start building our first priority application using the Arduino Coyote crowd. 11. Project Overview - Controlling an LED from the Cloud: offers project is going to be very simple. We will be controlling on led from the Arduino I ity cloud. We will be able to turn are led on and off using a property that we create, although it is a simple project. By completing it, we will get a very good overview of the entire process and sequence of steps of setting up a thing in the Arduino I ot cloud configuring properties, building a circuit and modifying cool so that our project in the cloud can be loaded unto our maker board. We will eventually be controlling our led over the Internet. There are a lot of moving parts and components to our simple project, but understanding these basic concepts creates a foundation for us to move on to building more complex I ot applications. If you're ready to get started, let's jump right in 12. Wiring the Circuit: here are the parts that we're going to need for our project. So first we have an Arduino maker WiFi 10 10 board, of course, a USB cable to connect all aboard some connecting wires. An led any color of led will work for this project and a 3 30 ohm resistor. You can also use a to 20 only sister, but a 3 30 would be ideal and finally, a bread board. So these are all the components that will need for this project. Better view the circuit diagram for our project. So first from our led the longer pin or the animal is connected to pin to on Army Corps Board. The other end of our led, the shorter pen or the cathode is connected to our 3 30 whom resistor and the other end of our resistor is connected to ground on our maker board. So that's it. Very simple circuit with two components. Let's proceed, tow wire up our circuit. First, we want to insert our Arduino Meeker WiFi 10 10 board into our bread board, so let's go ahead and insert it, and what would probably be a good idea is just to insert it with the USB connection on the outer end of the bread board. That way we can easily connected. And then let's go ahead. An insert our led Remember forever ladies, we have a longer in, which is our mood and the shorter and is the cat food. So just remember the orientation of the animal Danny cathode on your led so that when you inserted in your bread board, you will be able to make the correct connections. So I'm just gonna insert it here next from the pin to on our maker board that goes to the analog or the longer pin on our led. So let's make that connection. You'll notice on the side of our maker board. You can easily see the pin connections, so let's go ahead and insert that into up in two. The other end of that goes to the a node of our led. Make that connection there. Then let's insert our 3 31 resistor to the cat food, so we want to make sure it lines up neatly here in this line. Make that connection there. We could connect to the other end anywhere else on the bread board, then last connection would be to connect the end of that resistor to ground. Now we can use to wires where you can connect the end of the resistor here to the ground rail and any ground wheel to the ground, the pin on the maker board. But that's simply just used one wire and we'll connect to that again. And he seemed rule as our resistor and the other end can go to the ground pen if you notice here that ground pin unarmed Meeker board. So that is it. That's how we can use just three wires, tow wire up our circuit. And, of course, we just need to connect to the end of our USB cable here in tow, aboard, and that completes the wiring of our circuit. 13. Configuration in the Arduino IoT Cloud: Now we're going to dive into the process of creating our thing and configuring a property for our project. So head over to create that Arduino dot cc in a browser on you'll want to log in with the user name and possible you created for you are doing your account So once loved in head over toe Arduino Coyote Cloud and click on the link here at the bottom. Since this is the first time that will be coming in, we will not have any things that have been created. So go ahead and click on the new thing button and we have to give our thing a name so you can enter Hyoty Nash Cloud Dash led dash thing for the name of our thing. Next, we have to select a board so you can leave your maker. WiFi 10 10 Ward selected here. It should show up by default and then click on Create. So now that our thing has been created, let's create a property for a project. So click on the plus sign and the name of our property would simply be light. L I G h t. And this would represent the L E D that's in our circuit. So for the property type, let's go ahead and select on off bullion because we'll be using this property to turn are led on and off from the cloud permission. Let's go ahead and leave, read and write checked. Since we will be actually changing this value for update, let's leave when the value changes checked, as that would be the condition that would trigger an update to be sent to our project, and we can click on the create button so that completes the configuration of our thing on our light property. 14. Making Code changes: Now we're going to go ahead and modify the code for our project. So go ahead and click on the edit Court button here from the IRA. T Cloud page this ludes up our Web editor. And we have to make a few code changes in order for our project toe work. So the very first thing that we should do if you click on the secret tub, here's where you would want to enter the SS I. D and password for the wireless network that you want your padrino maker board to connect to. So let's go ahead and do that. Now I'm going to enter my S s I d and the password of my wireless network. Now I'm going to enter the password for my network. So once that's entered, let's go ahead and switch back over to the first tab for our project, and this contains the main cooled for our project. So the first thing that we have to do is to define our led pin so we can do that here at the top just after our include statement weaken, type in, define led underscore pin. And let's specify that as being pinned to next. That's cool down a bit and we need to. In our set up function, we need to specify that Led Penn is an output so right under the art we know cloud that print the bug and full well type in pin road. And here it's our Kelly deep in and it is an open. But in our semi colon in our loop function, we don't actually have to make any modifications because aren't we know Cloudar update that's going toe automatically sync any updates that are made to the Arduino authority cloud to our project. But if we scroll down will notice there is an on light change function here. Now if we click on the thing properties that each and I will go over these files in detail in another lesson. But here we can see that we have added a property that was called light. It was really right if you remember, and we also had specified that when value changed or on change here in our code, the on light change function is going to be called, so you can think of it as a callback function that will be invoked whenever we change that bullion value from our Arduino I ot cloud council. So if we head back over, let's go ahead, make some modifications to this Kobach function so we can actually tuggle are led depending on what the input is. So one other point is that light What a variable light as we see here which we named in our green authority cloud That value contains the Boolean true or false value that we set in our Arduino variety cloud. So we're able to refer to that light to variable here in our mean program as it will be set for us. So here, weaken, do digital right to our led pin and remember, the value of light will be true or false. So if we but the light variable there, if it's on or true, it will turn are led on on if it's falls or off, it's gonna turn are led off. So that actually is going to toggle the led beast on the value that came from that lighter setting in the yard. Minority cloud. Something else we can do here is just to a serial, that print line and here we can see the light is Eva Space they're cynical and and if light meaning, if the value of light was true, weakened Dua cereal, that print line on health cereal, that print line off, right? So that's it. Those are the cool changes that we need and just a quickly recap we define our led Penn variable has been to in our set up function. We defined our pin mood led pin as an output. We're seeing that we are going to be sending a output signals of that pin. We don't make any changes to a loop function on our main changes are in the armor like change callback function. Here's where we actually tuggle the led beast on that light variable that was passed into us. So we do a digital writerly deep in light, turning our led pin owner off, depending on the value of light that was sent us from the Arduino anti cloud. And here we just right out to the serial monitor cereal. That print line the light is and we write on or off. If light is true, we write own otherwise. If it's false, we write off. So those are the court changes that we need so we can go ahead and click on the check mark to verify and Seve. And since we didn't connect our board, notice that we don't have a board that selected here, So let's go ahead and plug in our USB cable. Once we do it, you'll notice that it recognises our maker WiFi 10 10 board. We can go ahead and click on that check mark to verify and compile. Once that's done, let's go ahead and click on the right facing arrow toe, upload and save, and this is actually going to save our code, and now it's going to the process of uploading the code toe our board. 15. Testing it out: So now it's the moment of truth. Let's go ahead and test out our project. We have set up our thing. We have configured our property and we have made our code changes. We also put in the credentials for our WiFi network on the secret tub. And now that such back over to the charity cloud to be able to change our light curable. So go ahead and click on the photo Coyote cloud, but not the top, right. And now from here, if we click on this, which it's tub, we'll be able to see this light double switch here. So this was the variable we set up, if you remember, or I should say this was the property that we set up. And here is the on off toggle switch since it was a bullion. And now if we clip on this double switch to turn it on batches sent a signal from the ality cloud down to our Arduino maker board over the Internet to turn our led on. So let's check that out. So I'm gonna pick on on and there you have it. How are led turned on and I'm gonna click on off and it turned off. So I'm turning it back on again. And as you see it's coming on and then I can turn it back off and it is coming off. So there's quite a lot happening here. It's a simple project, but we were successfully able to create our thing. We were successfully able to create the property. We made the appropriate cool changes and now from the Arctic Cloud were able to control a peripheral O. R led that's connected to our maker board over the Internet. Really cool, really exciting. This is just the beginning. We're going toe, explain a little more recording and the concept and so on. But this forms the foundation for our Arduino anti cloud projects, and we're going to keep building on this experience to make even more fun rt applications and ones that are a little more complex. Let's move on and continue our learning process 16. Reviewing Project Files: Let's take a more in depth look at the code and project files that were generated as part of our project. First, let's switch back over to the Arduino Coyote Cloud Consul from our Web editor, we can click on the go to Coyote Cloud button here at the top. We can then click on the I O T Cloud Beta home Link at the top. And if you remember, the first step for us when we build the project was to create a thing. We created a thing called the i O T Cloud led thing. Once that is done, it actually initialize is a project in the Web editor for us, this project will essentially have four files. Let's click on edit Cool to see the files that will automatically created for us in the Web . Editor. As you can see the Web editor and loads up here for us and by the fault, your sketch will be the name that you gave your thing followed by it a month and day that you create the project. This can be changed by clicking on the down arrow where you'll see options, and one of them is to rename your sketch. Now let's take a look at the files. The first file is the main file which will contain the mean cool for our project. This is where most of our logic will reside for the project. The next file is our documentation file. It is called by the fold. Read me that. A doc here we can put all the documentation about our project. There is some the full documentation that is created for us. And this file is written in the asking doc format, which is a markup language to describe documents when you export your project in the case where you might want others to use your code. This documentation comes in really handy to describe what your project is about in the standard way that makes it easy for others to read. The next step is our thing Properties that each header file and this had a file. We define all the constants on variable declarations that our project will use. You'll notice that when we created the light property from the Arduino authority cloud, let's switch back over here. We specified it as a Boolean and also that it was read and write just go ahead and click on the edit symbol here, and this shows the configuration of our like property by making it a bullion and by making it read and write, this means that we can change the value in the I t. Cloud itself. Andi, in our code. We want to be notified when an event occurs so we can handle it appropriately. When a change is made, let's come back into the core. So hit council here and click on add. It could. So we're backing nothing properties that age file, and we see that a Boolean light variable was created automatically for us, which refers to the value off our light property. In addition, the property was added itself on a callback function. Own light change was defined for us. Let's head back over to the mean file. If we look towards the bottom, you'll remember that we configured the code for the on light change callback function. What this means is that whenever we tuggle that bullion value for the light property in the Arduino authority cloud, our callback function is automatically called for us in that we we can access the value of light That was sent us and we can Tuggle our led according me. Hopefully it is all coming together. That's jumped at a last stop, which is the secret tub. Here is where we want to put any sensitive information like passwords, WiFi networks or any information we want to be secret for every project. Variables for the SS I. D and password of our wireless network automatically created for us or we have to do is plug in the corresponding values for our network. As you can see, the information is accessed and stored and character or re variables and off being properties that h file. So if we want to add in a new value, see an A p I key or secret for calling secured a p I services, we can simply at Baton. Let's go ahead and add in that variable. So here I'm gonna make a const character every and let's call this a P I key Onda that would be equal to secret underscore ap a key and this is the convention that we used. Typically, when we want to create a secret variable, we just give the variable a prefix name of secret underscore and then the name of the variable. And if you switch back over to the secret tub, what you'll see here is that secret on the school. A P I key field is automatically created for us, so we can then enter that value and we footed in our code. The main benefit of this is that when we export our projects, we do not have sensitive information and passwords embedded as part of our cool. Also, the information uploaded here to our project is encrypted on the maker board and it's stored securely. So hopefully that gives you an overview off all the moving parts and the relationship between the thing we create in the Arduino I ity cloud and a code that has generated for us that we modify to make our Arduino I ot cloud projects work. 17. An Overview of the Web Editor: Let's quickly review the Web editor, so we will understand the various features that are available to us. So from the left, you'll notice that there are a few tabs by the fault. Typically, when you come in, these catch book tab will be selected for us, and here you'll see all these sketches or the projects that you have created. So this was the cloud led thing project we created. And, as you can see, here are the files that are associated with that project. Next, there is an example stab. So if you go ahead and click on that example, Stab, you'll see a lot of built in examples that are available for us so you can actually drill down into any of these. Let's, for instance, quick on the Centre's examples. And here you'll see some example projects. I'm gonna go ahead and click on Ping and Ping is a popular sketch that's used with regards to ultrasonic sensors to calculate the distance of an object from an ultrasonic sensor. And there are lots more other examples here. For instance, on basics, there is the popular blink sketch, and these are just the sample codes and programs that you can run to see how things work. If you're new to the platform and you're trying to understand some of the basic according practices and get an idea of what you can do with the maker board on our do we know in general. Next up is the library stab, and we will actually be using the library Stab a little later on in one of our projects. But here's where. If you have 1/3 party libraries that you want to include a spot of your code for your sketch, you can search for those libraries here, and you can quickly include them in your project, and we'll see how to do this A little later on before we go into the next tub will go ahead and click on sketchbook and let's just reload our project. So next up is the serial monitor. Let's go ahead and click on that tub. And here's where the serial monitor, any outputs that we send from our program can be displayed. No, if you remember gonna just scroll down here in our mean cooled in our on light change callback function, we actually did a serial that print line to the serial monitor. We didn't actually test that out. I didn't demonstrate that when we're troubling are led. So let's go ahead and do that now so you will see how the serial monitor works. So right now my maker board is disconnected. I'm just gonna go ahead and plug it in and connected to the U. S B port of my computer. So once it's connected, it's going to start initializing on you notice here at the top that the maker WiFi becomes enabled. As the board was connected and the serial port was picked up or identified. I'm gonna go ahead and click on monitor again for that to reload and you'll notice here, this is where any communication that's coming from more board to the serial monitor would be displayed. So in order to show that output coming to Assyria monitor, let's go ahead and open up the Arduino cloud. I'm gonna open it up in a new window and I'm just gonna move it here to decide. And let's go ahead and click on that which it stab. And here I'm gonna tuggle my led. So when I click on on as you will see the light is on, that shows up on the reason again that shows up if you look at our code. Once light is on, we print out again once or callback function is called, we print out. The light is on, depending on if it's true, our own you'll see upon. And then if it was false or off, he'll see off. So you see that being printed out there when we talk lit on the Now let's stop it off and there you see it So the light goes off on our circuit, and then you have that lightest off being the skates. So again we can talk about on and off and so on. So again, cereal monitor. Very, very useful. Very handy for the bugging and checking the state of our program. And here's where we can send a serial open. Also, we can accept input from the cereal monitor. If you want the user to send information, data or instructions to our Arduino maker board, they can go ahead and enter that here and click on Send, and our program could handle that. According me and this upper, it's exactly like the traditional desktop or do we know I d that we're familiar with. So that is the monitor tab. Next up, we have the help tub, go ahead and click on here. And, of course, he can find a lot of information and helping tutorials about aren't we know about the maker boards and so on so you can feel free to explore this and the last. There's a Preferences tub. And here there are a few options that you can change, such as enabling auto seve and always showing the output panel and so on. So other than that, if you want to minimize this tab interface, you can click on the X, and that sort of goes away without minimizes. If you want to maximize just the cord on his screen, you can click on this full screen. As you can see, it minimizes the left hand side. Makes Ah, small sort of compact view on your code takes up most of the screen. Let's go ahead and accept full screen. The other thing that I wanted to mention was, of course, we've seen it before. There's go to charity Cloud Button. I'm gonna click on that, and it's very handy. And that we're able to switch back and forth between the aridity cloud and editing our thing and working on our properties and so on. And we could from here we can jump back into the court by clicking on edit cooled so that there's a nice transition that happens. The last thing that I'd like to talk about is actually exporting and importing projects. So here, for instance, if we wanted to export our project that see it's completed, we're done with it, and we want to package it up. If we hover over this icon to the left of the go to authority cloud button, we can click on download sketch. So if we ce Donald sketch going to select my desktop here will receive it off and let's go ahead and take a look at that, it actually creates a ZIP file for us. And the name of the ZIP file would be the name of our project, basically dot zip And that's quite an owns up this far. So I'm just gonna double click on it here to extract the folder contents. And here are the files that we spoke about earlier. So we have the that I am no foul, which is a mean file that contains all the cold or the mean logic of our project. Then we have the read me that a doc file. We have the Arduino on the score secrets dot h file header foul. And this was the variables that was set up on a secret stop. Then we have our thing properties dot h on another file, you'll see as the sketch that Jason and I'm just gonna go ahead and open that up. This is just a G son configuration file that contains information about a project and that has generated for us. So those are the files that actually make up ah, project. So if I were to let's go back here and that's when the leader projects, I'm gonna click on this arrow here and I'm going to the leader sketch. We'll get a confirmation asking that if you really wanted to lead the sketch, but the action is irreversible, I'm gonna go ahead and click on OK, so our project is now gone. There is. There's no project there. This is just a default project that's created for us. Let's go ahead and import or I should say reload that project from our zip file. So in order to do that, you can click on import. And here it basically tells you that zip files are the four months that we are looking for and I'm gonna click on the import button. I'm just going to select a ZIP file that we created before Click on Open and it is going to be pulled in. And here we got a success message and here we go. We're back to where we started Often these are our project files. So that's essential due process off importing and exporting. And in this editor as well, you can also create full there's to organize your projects and so on. So that was an overview of the Arduino Web editor Onda. Hopefully, this gives you some insight into some of the features that are available to us from the Web editor. It's very flexible. And again, the benefit of using the Web editor is that as changes and updates army to the Arduino platform itself, those will automatically be pulled into the Web editor. We don't have toe be concerned with doing updates and so on, as we would with the traditional desktop I D. So it's a really handy tool for us to use. The only caveat, of course, is that you have to have a Internet connection in order to use the Web I D. But using the Web I D in conjunction with the create plug in as a very robust tool set when working with our Arduino programs. 18. Detailed Code Review for our LED Project: hi, everyone, and welcome back Before we continue in the course, I wanted to give a little more detailed code review of some of the boilerplate code that typically is included with your I O tee applications. When you create them in the yard, we know Haiti Cloud. For the most part. As we progress through the course, I'll just be focusing on the mean meat of the program. I should say the content of the program, that we have to change all the code changes that we have to make that really pertinent to the specific application that we're building. But you'll see some boilerplate code that's generated again and again on. I just like to spend a little bit of time to go through this code so that you have an understanding of how everything works together. So as you remembered in any particular project, there are generally four tabs that you'll see when you're in the Web editor. And the first tub, of course, is the mean project, followed by the documentation time they read me that Iraq. There's a thing properties that each file And then, of course, there is the secret tab where you put in the society and password for your wife right network. So first, let's take a look at thing properties that age, and we're gonna go through each line of code here to describe what's exactly is going on. So at the top were first include the Arduino IittIe Cloud Library, and also there's a WiFi Connection Manager library. Now, this is automatically created for us, and these are libraries that were included at the top of this file. So remember when you create your thing and you generate your project, this thing properties that each file is created for us. So one variable you'll see in here is a thing i d. And this is a unique identify rare that is created onda associate ID with your thing So this string is generated for you on. Typically, you'll see this at the top of your thing properties that each next is the S s I D and password. So here is a character array that stores thesis E crit underscore a society and secret on the score password on those worthy feels that were populated here from the secret time. So here we just have a reference to those fields then there is on on, like change functions to remember specifically, This is a cool for the led project that we created on this. On my change was a callback function that will be executed when we change the value of the widget from the Arduino variety cloned. So that is typically the fine here Next up, of course, we have a light property on and actually this is a bullion light variable here, but it refuse toe the property that exists in the OT cloud. And here we have a function that's defined in it properties. So it does a couple of things. The first thing it does is it sets the thing I d toe that unique thing. I d character ary and we call the Arduino Cloud that set thing idea. And this just registers our unique thing with the Arduino Cloud library Next up in this function, we do aren't we know cloud that at property And here we add that light property that we had created remember that we had specified that it was going to be read, write, and that we're going to be able to change that value from the i o t cloud. And once it's changing the charity clone, that signal will be sent down over the Internet to our actual maker board. So that's why it's the finest read write on dawn change here. We're specifying that the callback function that's going to be executed is on like change. And of course, we're going to implement this guy in I won't mean program. So the last bit of code here and ping properties that ages, we actually set up that connection toe a WiFi network. So we do a connection manager, and here we have Arduino 80 per foot connection. We open or be sheets, I should say we in stanch it a new WiFi connection monitor, and we pass in the S S I. D and the password and connect the device to our network. And of course, these values would have been extracted from that secret tub when here there pulled into these variables here. So this sets up our WiFi connection, and from there we're going to be able to re food to this in our mean program. So that's essentially thing properties that each Andi you'll see as we create various projects throughout the course. The court and here looks very similar. And of course, depending on the properties that you create for your things, you'll see different values here. But typically the Kool, she looks very much similar to this. Now let's jump into the mean program on Dhere again. Remember, we're looking at the code for our a simple led project where we're controlling or toppling or led, turning it on and off from the Edwina Variety cloud. And it's going to turn on and off on our maker board. So at the top, we included thing properties that h file. And of course, we just reviewed that. So all those values would be set up on our connection to the WiFi network would be in Stan sheeted unavailable. Tow us. So then up next up, we define our early deepen on. We reviewed this already andare set up function. A few things cereal that begin 9600 were just initializing the cereal and waiting for a port toe open. And then we have a small delay here of 1.5 seconds, 1500 milliseconds and this Basically, this delay gives a chance toe wait for a serial monitor, which, without blocking So these are some boilerplate actions that are done in every set up function. Next up, we call innit properties. And remember, in that properties just gonna quickly jump over here. That was this function where we set our thing and we register our property. So this is going to be called on that's going to be executed, and then we're going to do are doing a cloud that begin and we're going to pass in our we know, I ot preferred connection object. So that's the connection manager object that we had set up. So we passed that in here and that and Stan, she it's the connection to the Arduino variety cloud coming down here. We set the bug message level. The maximum level is four. And if you set it to zero on the errors will be the bug. But we put it Why should see it? The folds to typically when you create a program, when you're able to see messages in the serial monitor, the bugging open messages and then we have Arduino cloud that print the bug in four. So we set a word, the bug level. And here we are printing out that the bug information to this year Monitor as items are sent to the serial monitor, then we have our pin mood on. This is our custom sort of code that we added in here for specific to the led project. In our loop function we have are doing a cloud out update on essentially this gets our project ready aboard connects the dead. We know cloud and we're ready to go. So anything that or any special cool that you need typically comes after here. Generally, when we create an I o. T. Thing and when he sketches created for us, this is the boilerplate code that we'll see in a lot about projects. So I just wanted to take a couple of minutes to go over this to explain what was going on on then. That way, as we do the other projects in the course and simply focus on those specific pieces of court that's Britain into the project, he would have an idea of what's happening behind the scenes. I will see you in the next lesson. 19. Project Overview - Taking Analog Readings : This is one of the coolest projects that we will be building in this course on. It is a fully fledged practical I ot application. We're going to tackle a temperature controlled, self regulating system that is controlled and monitored from the cloud. Essentially, our application will be able to set a desired temperature on our fun will automatically kick on and off toe. Cool the area surrounding our temperature sensor toe the desired temperature setting. I will also show how you can create a dashboard that not only allows you to set the desired temperature range, but also allows for Emmanuel Override enabling you to control the fund from a console. The dashboard will also contain real time This please that sure, the temperature of our sensor. We simply have to set the system on forget it itself regulates on its own. Around the we, we will learn how to control a fun electronically using a transistor as a switch. We will also learn how to create an I O T. Dashboard to fully control our fan and set a desire temperature range. The project will also show how we can implement a feedback group in the cloud that allows our sick it to self regulate the control temperature. All I will work culminates in this final project, and it's going to be a lot of fun. Everything we have learned will all come together. Let's get started. 20. Wiring the Circuit: No, it's time for us. The wire up our circuit. So first, let's create the ground, Really? Or maybe ground connection on our bread board, someone taking when I'll be connecting wires. And here, of course, the ground pin from our maker board. It's clearly highlighted here, and White will make that connection there. And we're gonna connect back to the ground really on our bread board because we're gonna have a couple of connections that are coming off of that. So let's first do that. Then let's wear a power the HD sensor and, of course, without DHT sensor. As you can see, there are three pins and it pin here. On the left is the positive pin or the visi seep. In the middle pin is a signal pin, and then deep in here on the right is ground or it's connected the ground. So I'm just gonna insert this sensor here in tow bread board and the first let's make the VCC connection. So that positive been here? I'm going to connect that here. As you can see, make sure it lines up in the same rule here, gonna make that connection here, and that we're going to connect to that to five folds on our meager board. So if we look here for the five old men, it is the pending here at the top. When I make sure that we like that in So that is in place. Next up the middle pin here on our DHT 22 sensor is Thesiger Nall pin and that is going to pin seven on our maker board. So just make that connection now and ensure that we get that middle pin lined up here and pin seven on Arduino board here is actually the second to last Been a Zaken see here in seven. So when I make sure that that lines up on it goes into the second to last socket here and it's been seven, and then, of course, finally depend here on the right had been on our sense of goes to ground. So I'm gonna make that connection Now I want to ensure that it lines up in a row with that pin Onda. Once we get that in weaken, just connect about two grown and again, this is all ground real going all the way across here at the top, and it will be grounded. So those any connections that we need for our sensor Next up, let us do the connections for our transistor. So here is our to end 39 or four transistor. And as you can see, what the transistor there is a flat surface here, Andi, When it's oriented with a flat surface facing you, of course I'm gonna turn it here. Here, the round sort of curved out there surface. And then here's a flat surface. Would be actual rating. Spring a little closer here with the actual writing on the transistor. Um, the left most pin here is going to be the emitter. The middle pin is going to be the base, and the right pen is going to be the collector. So I'm just going to insert this into the circuit and the make sure it's oriented that way with the flat side. As you can see, the curve, the site is on the outside, the flat side facing me or facing us agency. And that way we can know the orientation of dependence. So from our emitter, we have to make a ground connection. So the materials directly the ground, so I will make that connection now, So I just want to make sure they've been here and it left you line it up. We insert that where There to depend on the left. And we want to ensure that we grown that image or pin. So that is the ground for emitter. Next up the middle pin is the base spin and from the base, we actually have our one key res sister. So I'm gonna connect to that here to the base. That's when I ensure that we lying that up here in the middle. As you can see, I'm gonna connect back to another point here and bread board somewhere else on the bread board, I mean, and the other end of that base resistor goes to pin six on our maker board. So I will make that connection now. And here is that again we connect the other end about resistor along that same room, and we're going to go to pin six and then six on the maker board if return it here is actually the very last pin here on just below the pin seven. So we just want to make that connection here. That is the base for our transistor. I should see it's the end of the resistor that's connected to DB seven transistor and then from the collector, we go to the negative of our funds. So here is my CPU fund. Let me just quickly show it. And as you can see from their reading, it's a 12 volt DC fun, an iterated at 120.2 amps. So we're going to use as I mentioned to battery packs to get up to 12 volts. And if we look at the fun connections here, you'll see a series of wires. But what we're concerned with is theblaze choir and the red wire so they black would be the ground or negative wire, and the red wire is going to be our positive wire. So coming off of the collector here on our transistor, we're going to the negative or the black wire of our fun. So depending on whatever fun you have, just look out for the black and red wires, and that will give you an indication of the polarity. So I'm going to take a wire connected to the collector of or resistor. That's 1/3 pin. Make sure it is lined up. Connect that and and the other end of the wire goes into the black wire off our fun. So here, I mean that connection here. So the black wire is the outermost wire, and as you can see here on the left, that's where that connection went into out the most wire here on the left, the wire. Dustin. Right. Next it is the positive on that is actually going to go to the positive of our battery. But the phone connect our battery. Let me just show you here. These are two battery packs that we're using. On that they are for 1.5 bull batteries. And if you add up the 1.5, you'll get six folds per battery. And here is a six full butter proxy. Put them together in series and it's gonna be 12 volts. So let me show you. Actually, how are we going to do that? And if you look here in this particular body here, battery holder is pretty nifty. It has ah, sort of a female plug at the end on ditz. Once you put your batteries and your ableto come off of this female and meal again It's labeled Block I should see and a red wire. So if we're connecting batteries and Siri's remember, earthy negative of one battery has to go to the positive of the other. So I'm just going to make that connection Now, here, off the black wire, which is this end here Gonna push in. My connecting wire actually should go in a little more firmly. Right. So here is the end, and you should try to needing this up and actually put some tape so that this wire isn't exposed toe prevent shorts, but the black wire here it's connected to my connecting wire, and that has to go into the positive of the other battery pack. So here, that goes into the red wire. So if you look at the red wire, is this wiring inside? And I'm going to make that connection here to the inside. So that is on the insane. Let me just fix that. There you go. So that's the inside. And then, of course, the outer wire is going to be our negative wire. That's going to go the ground. So I will use another connecting wire here. Okay, so this goes to ground this one. Insure, push this in and on this side. Here we have it. Positive wear, which would go to the positive section for a second. So just a shoe that these two battery packs are connected in Siris. But shoes on multi meter. And that's strictly footage. So I've connected them here. Here, I have. Ah, generic multi meter, and I'm gonna turn it on on its own. Actually, these e Volz size. Put it on the 20 volts setting, which should be enough. Take the measurement. I was gonna put this here on and let us check the voltage of our battery. So I'm going to check this out here. Here is the negative. So I'm gonna put the terminal there and what the terminal to the other were. And if you look at our multi meter, it says 12.74 bolts. So we're right, right? About 12 bullets all over 12 volts. So, as you can see, we connected our battery packs in Siris. Andi, it looks like we're good. So once that is set up to move the multi meter here out of the me. And now if you go back toe a circuit remember, the positive of our fan has to be connected to the positive of our body repack. So let me just do that right now. Here is the positive of our body pack, and we go back to the fan connection. Remember, we had the negative connection and the bread is the positive. So I'm gonna make that connection now. So now a Nazi positive of our fund and the other end of our battery has to be grounded. So again, here is the ground, the connection on our circuit. I guess when I ensure that that's grounded and that is it. So here, just uneaten things up. We have our body re peck. It's connected to a circuit. We have our fun connected. We have our DHT 22 sensor. We have our transistor and everything is connected upto a maker board. So they very last thing, of course we have to do is use our USB cable and connected into our maker board and the other, and it is going to go into our computer. So I knew that was quite a lot of wiring there, but hopefully you're able to follow alone with me and with the circuit diagram, please double check all your connections double and triple check. And of course, make sure that your Arduino maker borders powered off. There's no power supply tit as you are things up and when you have everything ready, will proceed to make all the co changes that we need, and then we will upload those cool changes to our circuit to test out our project. 21. Configuration in the Arduino IoT Cloud: Okay, you welcome back, everybody. And now we're going to set up the thing for our temperature control project. And we also have to set up a couple of properties that are associated with our thing that will use the monitor and control our circuit. So head over to create that Arduino dot cc and your chrome web browser and gonna click on Arduino Piety Cloud. So from here, if you have a project that was already created, you have to delete it on. This is in the beat aversion I'm working in. So let's go ahead and delete it, since it only allows one thing at a time. So I'm gonna just delete this existent thing, and we're are going to create a new thing. So click on the new thing button. We're going to give our thing a name, so I'm going to call it i o t Dash Cloud Ash temp Dash control Bash thing again. You could name it anything that you want, but this is the name all use for our project. So of course it's the maker WiFi 10 10 board on. Just leave that selected by default and we click on create so As you have noticed, this interface looks a little different from some of the projects at the beginning of the course and match because, as I mentioned, the Coyote Cloud is still in. Beta on day are making updates. So this is the latest version of the interface on Glad, actually a change in us, so I can get to show you that the functionality is similar. It's just that things have been moved around a little bit. So from this Properties tab, we can click on Add property, and we need to add a couple of properties that we will be referring to include as well as interacting with from the dashboard. So the 1st 1 is max temperature, and this is a property that we will use to set or control the maximum temperature range for our system. So the name over this marks on the score temp, and we can select from the property type. It's afloat since we'll be measuring temperature, the range will be using here is minus 15 to 80 degrees, and that's simply the Celsius range for our DHD 22 center. We want this to be a read on right permission because We want to actually set this temperature from the screen or from the cloud itself. And that will be the max temperature that would be allowed for our circuit onda the rest of the other properties. We can simply leave them as the fault, and we can click on at property. So once that's added, we have to add another property. So I'm going to click on that property again. And the name of this one is override Underscore fan control. And we will be using this property when we want to take control of our fans so our system is going to be self regulating. But if for any reason we want to take control of our fun and turn it on and off, regardless of what the temperature is, we'll be able to do that in our project, so the type is going to be on off bullion on. The permission is going to be read and write, so boots are only settings that we'll need for this particular property, and we can click on add property. The next property we need to create is fun on, so go ahead and click on add property again and the name of this is fun underscore on. And this here for the property type is going to be a boolean value, and it's going to be read and write. So essentially, this is what we're going to use to manually control, are fun and actually tune it on and off when we enable the override. Or this property is going to be set based on the current state of our system and whether our fun is currently owner off. So had serves a dual purpose. So that's a fun on property on Go ahead and click on that property Onda Last but not least , we need to add a temperature property, so I'm going to click on that property. And in the name of this, of course, is going to be temperature. And this simply reflects the current temperature of our circuit. So the DHD sensor is going to take a temperature reading. We're going to figure out what that is in code, and we're going to set this on a screen off our dashboard. So it's actually just going to be read on me. We're not going to be changing it, Onda. The type is going to be a float on seeing that it's a temperature value or should see the temperatures Sensor has a range of minus 40 degrees on it was all the way up to 80 degrees on. Of course, this is in Celsius. So three other thing that we want to do is when the value changes. We wanted one update and let's do every half of a degree. So 0.5, we're gonna change that to 0.5, and that will be the temperature property that we need for our project. So go ahead and click on that property. Andi, this would complete the properties that we need that we actually are going to interact with in code and as well as on the Coyote Cloud dashboard when we work with our project. 22. Making Code changes: Welcome back, everybody. And now it's time for us to dive in to some code and make the cool changes that are necessary for project toe work and for everything to come together. So here we're at the Coyote Cloud page and we have created four properties on and these properties we're going to refer to them in the cud. Onder, just a quickly recap we have our fun on which would be responsible for or I should see this is where we would tune are found on and off the marks temperature setting. We also have the override fun control when we want to take control of our circuit and then we have a temperature setting, which is just a read only value. In fact, it's the only read only property which reflects or updates with the true value of the temperature of our I T system. So those are the properties, and I'm just gonna click on the dashboard here, and these are how they are going to show up. And when we actually write our code and we're testing out our sick, it will come back to the dashboard so you can see all of these in action. So no, let's go ahead and write some code. And to do that at the top there is a button, that school edit sketch so you can go ahead and click on that button. And that should banned us in the Arduino Web editor. So let's click on that button now. So I'm just gonna maximize this window here a little bit so we can see our cool a little easier. So again, our first step as we come in here should be to click on a secret tub. And here we're going to enter the SS I. D and the password for our wireless network. So let's proceed to do that now, in order for our maker board to connect to our WiFi network. So when I enter the SS, I d hear of my network and the password. And once you have entered those values for your wife or a network, we can click on the mean tab here for our project. So once we're back here, the first thing that we need to do is we need to include the DHD Library, third party library, so we're able to use some of the convenience functions in there for our temperature sensor . So if we click on the library's tab, that should load up the library manager for us, and I'm going to click on the custom tub. And here I'm going to search for just teach T so you can type in DHT and hit Enter. And here we see the DHD Sensor Library. We want to go ahead and click on the include button, so that should include the DHT library at the top of our program here for us. So once that's done, let's cool down of it. And we have to declare a few constants here in our program. So right under thing properties that each where we include our thing properties that each file let's set up some constants. So the 1st 1 is we're going to define our DHD pen, and that is going to be pin seven. If you remember that was connected from the temperature sensor, the hope up in tow, our Meeker board. Then we're going to define the DHD type on. That's going to be DHT 22. This is what we will be using to a foot of which vision of the library or I should see which specific censor the DHD 22 a. D h d 11 were using. We're using the DHD 22 from this library, so we have to define a variable there that we will use. Then Stan sheet the DHD object and then next we can define our DHT object, and it's going to be the HD. We're gonna call it DHT. You can name it anything you want. But since it's the DHT library, we're just gonna use Boquillas tht and it's going toe granita pass and the d h depend that we're using, which was seven above on the DHD type. So this would clear our DHT variable or I should say, are in san she ate r GHT object on. This is what we will be using to take our temperature readings. Couple of the variables you wanna set up is define our fun six. And the positive pin of our fine is connected to pin six on our maker board. And the last variable we wanted to find is a default marks temperature. So let's see, e temperature was not set or a maximum temperature was not set from our i o T cloud interface that which it had no value. We want to ensure that we just have a default temperature that our program will use on and that we wanted variable changes or a set. Then it's picked up. So we just want to account for a null value or nothing mean the and let's set our default max temperature to 30 degrees. So once those of variables are defined, that's cruel down here in our program. And we need to add some additional cool right after the printed a bargain for here to initialize our objects and so on and to get things ready for execution. So the first thing that we do is we do a DHT, not begin, and that's going to just initialize our teach the object and make it ready to take readings . And we're gonna set up a pill mood for our fun pin as output. So we're seeing that are fun. Pain is going to be used as an output and will be sending no one high signals of that. And that, actually is what will go to the peace of our transistor to turn our fun on and off. Initially, we also want to turn our fun off so we can do a digital freight to our fan, and we could write a little signal to it on. Essentially, this initially tunes off our fund on here. We check if mocks temp is equal to no meaning that property was not sent. We want to set max temp until it afford max temp, which is that value at the top of our program. So just switching over here quickly to think properties that each remember Max temp was that property that we have, where we specify the maximum temperature. It we have a reference to that variable here from all thing properties that each and here were initially checking. If that value is MT. Or there wasn't anything in there, we're going to set it to the default max temperature, which would be 30 degrees. So that's the end of the set up that we need to do in our set up function after initializing variables and our fan pin and certainly max temperature and now we get into the loop function where all the magic happens for our self regulating system. As I mentioned, though, to make things easier before we get into loop there are a couple of convenience functions that we're going to write, and I covered that in the previous lecture when we discussed some of those functions and logic that would be in there. But before we start writing that, I just wanted to highlight those callback functions that go created for us. So on Max Temp change again. Once we tuggle the widget from the IRA T Cloud, a signal is going to be sent from our make aboard over the Internet I D Cloud and whatever court is in here is going to be executed as well as the override fan control and the fan on double switch. So a bully and I should see. So once those values that changed, these quote back functions are going to be executed. So the first function that we want to right here is the regulate temperature. So we're going to do avoid regulate temperature. So if the temperature is greater than Marx, underscored temperature marks on the score attempt. If that's the keys, then we are going to turn our fund owns Will do A did still right our fund pin, and we're gonna right toe high. And of course, that's going toe Turn on our fun, Els We're gonna turn off our friend and the turn off our fun We do a digital right there are fun on that's going to be little. So in addition to turn any values on and off, we also want to set the fun on a 1,000,000,000 flags and fun One is going to be equal to truth. Onda here since we turned off our fun fun off is equal to truth And these are I should see the funnel on fun on here Sorry is equal the false So they found on property itself is what we are, what will be visible in the I T cloud interface. And of course, if we turn our fun on, we want him Make sure that the value of that property reflects the current state of our fan . So we're also gonna turn that flag true. And then if it's of course, you turn the fan off. We wanted to in that flag off, so it's gonna be false. So that's the regulate temperature convenience function. The other function we talked about was turn fun on or off, and this simply will check if that fun on flag is set to true on again. Remember, this is a value from our I ity cloud We want to turn our fun on so we do a digital right and to our fun taking it on health We turn off our funds who do a digital right to our fun and we turn it off. So those already only two conditions that we need to execute here and it turned fun on or function the last bit off, I should say, the last major function or convenience function that we want to create a update system so we can again have avoid upbeat system here. It doesn't take any arguments or parameters. So if override fun control, basically if that which it was set to true from the mean dashboard, then that means that we need to manually control are fun. So if that override fun control is set, we can call our tune fun fallen off function here, And that's going to be this guy, and it's going to check to see if the fine is on about. We have to inspect the current state of that fun on property. And if it set the own we gotta turn off and on. Otherwise, turn it off. So that's once that override flag is set, we need to inspect that variable. Otherwise, if it's not sent, we simply want to regulate the temperature. So our system is going toe up your operate like normal, and it's going to. Of course, if the current temperatures greeted any max temp is going to kick on. Our fun changed the state of our circuit to reflect that I should say, changes state of the property on the interface to reflect that. And if the temperature is less stunning max temperature meaning our system has cooled down enough, we're gonna turn off our fan and tune off the indicator as well. So those are the convenience functions. So the other cool changes that we need to make here for our callback functions. So if the maximum chip temperature was changed at any time in here, we want to call regulate temperature so immediately. If we let see, it was set to 25 degrees and we change it to 28 we immediately want to check. Hey, is this was the temperature. I was changed to a greater or the current temperature greater than it marks temperature. I was changed to and are sick. It would react accordingly. So that's going to be called here on Mac stem change. The other cool change that we need to make for the override. So once the override A is changed, I want to call update system Onda. Of course, what would happen here is if we tackle that Boolean flag to take manual control of our circuit up the IT system with just determine exactly what needs to be done. So if manual control is on true, then we check the state of that fun on toggle switch and then we we treat it accordingly and then finally, for on fund change here, we also do update system. So similarly, if we tackle that fun on bullion, we're only going to control our fun if and only if override is controlled or should see override is enabled otherwise, if it's not enable, we have to ignore it and just do regulate temperature. So hopefully you see how these, you know, by writing these three here, convenience functions were ableto referred to them in our callback. So once that those functions are written in our loop function and becomes very simple here . So the first thing is in a loop function. We want to read the temperature data. So in order to do that, we simply do a temperature. And that is the property from again our i o t. Which it screen or from the i o T Cloud we set that temperature value is equal to DHT. That read temperature on our library will take care of getting that reading from all the HD 22 sensor. And here we can do a serial. We want a print out to the serial monitor, the temperature and specifically what the value is on here. We can do a serial that print out that temperature value, and we also want to indicate that it iss Celsius circular cereal, that print print line, give us peace and put Celsius, and that's gonna print out the current temperature. So once that is done, really the only function we need to call in here as update system, so that's gonna take care of everything else. No other cool or logic is needed in here, and then we can put in a dally off of five seconds or so so the temperature reading would be taken every five seconds and just a comment here about updated system. Basically, we're going here to control the fund or regulate temperature based on user input setting. So you can see by writing that one up the IT system function. It takes care of everything here and are looked for us. We don't have to duel this logic and checking on in this way by writing our code in this way. It's very I should see. It's very neat. It's also there is separation of concerns because each of these functions handles something specifically. And of course, there's a lot of re use of those functions and that were referred to the seem logic and our callbacks. And it's just a clean, neat way to write our code and a reusable we that it's easy to understand, and also we have a maximum reuse, very efficient. We have writing our code, so that's it that completes the code changes that we need to make Andi in next lesson. We're going to test everything out. So, uh, pretty soon we're going to see if all the wiring of our circuit and all the court changes everything was able to come together and let's see our project in action 23. Testing it out: So now we're gonna test out our project and I'm gonna connect the aren't we know board to my computer. So once the board is connected, as you can see, it was detected. And the first let's go ahead and compile on upload our co two the board So we can click on the check mark here that's gonna compile and verifier code. That's that. This room to see if we had any errors, success, compile, elation or successful. And now let's proceed to upload Onda, save the cool toe aboard to click on the right arrow. Then we'll give this a few seconds to run. Okay, so it we got the success message. It was successfully uploaded to our board. Let's go ahead and click on the serial monitor here. Onda, as you can see there ago, so we see the connected status on. We also see the first humidity and temperature reading being displayed. Now you'll notice if we remember in our code we had a Delia five seconds, so really, every five seconds we're going to spit out, or I should see the split pea temperature and humidity values and one small tweak that we could make to make this show up a little better. Weaken do here after we do a serial that print Celsius weaken simply do, ah, cereal, that print flying and let's go ahead and upload that change and that will just simply meek each reading, come out on a new lying. So let's upload that we can also have then serial the print mine Celsius here. So now we see the humidity and the temperature being printed on separate lying. So that's kind of what we wanted just to be able to clearly see that. So once that's done, let's go ahead and open up the crowd console the goto I ot cloud. I'm just gonna open this any new window that we were able to sort of see it by side by side on. Once that loads up, we can click here on the widgets icon on here, our values. So here we can see the humidity. Right now, it's about 50.6% on the temperatures, about 24.8 Celsius. Now let's look at a change and let's see how, when the values change, how they are reflected on the I T cloud as well as any council. So it a similarly this change. What I'm going to do is I have a sword and Ryan has in a village that can get really hot. And I'm going to bring this order and iron close to the actual sensor. Onda Ben, We'll actually see the values change. So here ago, when I bring the sword and iron, and as you can see, I'm just gonna move it close to the sensor. Remember, the readings take place every five seconds on, and it should be pretty hot. So, as you can see, there goes. The humidity changed. The temperature was 24.8. I notice any consulate went up to 25. I'm just gonna bring it a little closer. 24.8 25.5. And remember, we said the temperature on the council, the change when? As adults off 0.5 degrees. So it's getting hard term. That's gonna move it pretty close here. And as you can see, it's going up. So the temperature change from 25.5 26. Humanities at 50.2 and it's continuing to go up. It's getting harder. 26.6, as you can see in our console. It's now 27 but again, Delta isn't big enough. When she does this speaking up them and jumps to 27.2, so various see it it's working on. It's taking those Delta changes into effect and only updating the Cloud Council when the Deltas are greater than 0.5 for temperature and 1% for humanity. So, of course, the humidity values dropping as temperatures increasing because the ear around the sensor is getting this. There's less water vapor as it's getting hotter. So that's why humanity is dropping. All right, so now let me move the Southern iron. I'm gonna put it back and let's just give it a second or so when we will see. Actually, temperatures start to drop again. So right now it's at 27.7, and, as you can see in the serial, monitored went to 27.6. But since it's not at what Delta 0.5 Hour Cloud Council is still going to say 27.7 and it's dropping some more 27.3 and we're getting pretty close once it gets to 27.2, we should see the cloud Consul should change, and there we go. All right, so because it was adult off 0.5, a change. So a circuit is working. Our cloud council is working. Were it was the view our properties on. And that's how you use a D. H d 22 center. That's how you take measurements and you configure it in the art we know rt cloud. 24. Project Overview - Detecting External Button Press Events: This is one of the coolest projects that we will be building in this course on. It is a fully fledged practical I ot application. We're going to tackle a temperature controlled, self regulating system that is controlled and monitored from the cloud. Essentially, our application will be able to set a desired temperature on our fun will automatically kick on and off toe. Cool the area surrounding our temperature sensor toe the desired temperature setting. I will also show how you can create a dashboard that not only allows you to set the desired temperature range, but also allows for Emmanuel Override enabling you to control the fund from a console. The dashboard will also contain real time This please that sure, the temperature of our sensor. We simply have to set the system on forget it itself regulates on its own. Around the we, we will learn how to control a fun electronically using a transistor as a switch. We will also learn how to create an I O T. Dashboard to fully control our fan and set a desire temperature range. The project will also show how we can implement a feedback group in the cloud that allows our sick it to self regulate the control temperature. All I will work culminates in this final project, and it's going to be a lot of fun. Everything we have learned will all come together. Let's get started. 25. Wiring the Circuit: No, it's time for us. The wire up our circuit. So first, let's create the ground, Really? Or maybe ground connection on our bread board, someone taking when I'll be connecting wires. And here, of course, the ground pin from our maker board. It's clearly highlighted here, and White will make that connection there. And we're gonna connect back to the ground really on our bread board because we're gonna have a couple of connections that are coming off of that. So let's first do that. Then let's wear a power the HD sensor and, of course, without DHT sensor. As you can see, there are three pins and it pin here. On the left is the positive pin or the visi seep. In the middle pin is a signal pin, and then deep in here on the right is ground or it's connected the ground. So I'm just gonna insert this sensor here in tow bread board and the first let's make the VCC connection. So that positive been here? I'm going to connect that here. As you can see, make sure it lines up in the same rule here, gonna make that connection here, and that we're going to connect to that to five folds on our meager board. So if we look here for the five old men, it is the pending here at the top. When I make sure that we like that in So that is in place. Next up the middle pin here on our DHT 22 sensor is Thesiger Nall pin and that is going to pin seven on our maker board. So just make that connection now and ensure that we get that middle pin lined up here and pin seven on Arduino board here is actually the second to last Been a Zaken see here in seven. So when I make sure that that lines up on it goes into the second to last socket here and it's been seven, and then, of course, finally depend here on the right had been on our sense of goes to ground. So I'm gonna make that connection Now I want to ensure that it lines up in a row with that pin Onda. Once we get that in weaken, just connect about two grown and again, this is all ground real going all the way across here at the top, and it will be grounded. So those any connections that we need for our sensor Next up, let us do the connections for our transistor. So here is our to end 39 or four transistor. And as you can see, what the transistor there is a flat surface here, Andi, When it's oriented with a flat surface facing you, of course I'm gonna turn it here. Here, the round sort of curved out there surface. And then here's a flat surface. Would be actual rating. Spring a little closer here with the actual writing on the transistor. Um, the left most pin here is going to be the emitter. The middle pin is going to be the base, and the right pen is going to be the collector. So I'm just going to insert this into the circuit and the make sure it's oriented that way with the flat side. As you can see, the curve, the site is on the outside, the flat side facing me or facing us agency. And that way we can know the orientation of dependence. So from our emitter, we have to make a ground connection. So the materials directly the ground, so I will make that connection now, So I just want to make sure they've been here and it left you line it up. We insert that where There to depend on the left. And we want to ensure that we grown that image or pin. So that is the ground for emitter. Next up the middle pin is the base spin and from the base, we actually have our one key res sister. So I'm gonna connect to that here to the base. That's when I ensure that we lying that up here in the middle. As you can see, I'm gonna connect back to another point here and bread board somewhere else on the bread board, I mean, and the other end of that base resistor goes to pin six on our maker board. So I will make that connection now. And here is that again we connect the other end about resistor along that same room, and we're going to go to pin six and then six on the maker board if return it here is actually the very last pin here on just below the pin seven. So we just want to make that connection here. That is the base for our transistor. I should see it's the end of the resistor that's connected to DB seven transistor and then from the collector, we go to the negative of our funds. So here is my CPU fund. Let me just quickly show it. And as you can see from their reading, it's a 12 volt DC fun, an iterated at 120.2 amps. So we're going to use as I mentioned to battery packs to get up to 12 volts. And if we look at the fun connections here, you'll see a series of wires. But what we're concerned with is theblaze choir and the red wire so they black would be the ground or negative wire, and the red wire is going to be our positive wire. So coming off of the collector here on our transistor, we're going to the negative or the black wire of our fun. So depending on whatever fun you have, just look out for the black and red wires, and that will give you an indication of the polarity. So I'm going to take a wire connected to the collector of or resistor. That's 1/3 pin. Make sure it is lined up. Connect that and and the other end of the wire goes into the black wire off our fun. So here, I mean that connection here. So the black wire is the outermost wire, and as you can see here on the left, that's where that connection went into out the most wire here on the left, the wire. Dustin. Right. Next it is the positive on that is actually going to go to the positive of our battery. But the phone connect our battery. Let me just show you here. These are two battery packs that we're using. On that they are for 1.5 bull batteries. And if you add up the 1.5, you'll get six folds per battery. And here is a six full butter proxy. Put them together in series and it's gonna be 12 volts. So let me show you. Actually, how are we going to do that? And if you look here in this particular body here, battery holder is pretty nifty. It has ah, sort of a female plug at the end on ditz. Once you put your batteries and your ableto come off of this female and meal again It's labeled Block I should see and a red wire. So if we're connecting batteries and Siri's remember, earthy negative of one battery has to go to the positive of the other. So I'm just going to make that connection Now, here, off the black wire, which is this end here Gonna push in. My connecting wire actually should go in a little more firmly. Right. So here is the end, and you should try to needing this up and actually put some tape so that this wire isn't exposed toe prevent shorts, but the black wire here it's connected to my connecting wire, and that has to go into the positive of the other battery pack. So here, that goes into the red wire. So if you look at the red wire, is this wiring inside? And I'm going to make that connection here to the inside. So that is on the insane. Let me just fix that. There you go. So that's the inside. And then, of course, the outer wire is going to be our negative wire. That's going to go the ground. So I will use another connecting wire here. Okay, so this goes to ground this one. Insure, push this in and on this side. Here we have it. Positive wear, which would go to the positive section for a second. So just a shoe that these two battery packs are connected in Siris. But shoes on multi meter. And that's strictly footage. So I've connected them here. Here, I have. Ah, generic multi meter, and I'm gonna turn it on on its own. Actually, these e Volz size. Put it on the 20 volts setting, which should be enough. Take the measurement. I was gonna put this here on and let us check the voltage of our battery. So I'm going to check this out here. Here is the negative. So I'm gonna put the terminal there and what the terminal to the other were. And if you look at our multi meter, it says 12.74 bolts. So we're right, right? About 12 bullets all over 12 volts. So, as you can see, we connected our battery packs in Siris. Andi, it looks like we're good. So once that is set up to move the multi meter here out of the me. And now if you go back toe a circuit remember, the positive of our fan has to be connected to the positive of our body repack. So let me just do that right now. Here is the positive of our body pack, and we go back to the fan connection. Remember, we had the negative connection and the bread is the positive. So I'm gonna make that connection now. So now a Nazi positive of our fund and the other end of our battery has to be grounded. So again, here is the ground, the connection on our circuit. I guess when I ensure that that's grounded and that is it. So here, just uneaten things up. We have our body re peck. It's connected to a circuit. We have our fun connected. We have our DHT 22 sensor. We have our transistor and everything is connected upto a maker board. So they very last thing, of course we have to do is use our USB cable and connected into our maker board and the other, and it is going to go into our computer. So I knew that was quite a lot of wiring there, but hopefully you're able to follow alone with me and with the circuit diagram, please double check all your connections double and triple check. And of course, make sure that your Arduino maker borders powered off. There's no power supply tit as you are things up and when you have everything ready, will proceed to make all the co changes that we need, and then we will upload those cool changes to our circuit to test out our project. 26. Configuration in the Arduino IoT Cloud: Okay, you welcome back, everybody. And now we're going to set up the thing for our temperature control project. And we also have to set up a couple of properties that are associated with our thing that will use the monitor and control our circuit. So head over to create that Arduino dot cc and your chrome web browser and gonna click on Arduino Piety Cloud. So from here, if you have a project that was already created, you have to delete it on. This is in the beat aversion I'm working in. So let's go ahead and delete it, since it only allows one thing at a time. So I'm gonna just delete this existent thing, and we're are going to create a new thing. So click on the new thing button. We're going to give our thing a name, so I'm going to call it i o t Dash Cloud Ash temp Dash control Bash thing again. You could name it anything that you want, but this is the name all use for our project. So of course it's the maker WiFi 10 10 board on. Just leave that selected by default and we click on create so As you have noticed, this interface looks a little different from some of the projects at the beginning of the course and match because, as I mentioned, the Coyote Cloud is still in. Beta on day are making updates. So this is the latest version of the interface on Glad, actually a change in us, so I can get to show you that the functionality is similar. It's just that things have been moved around a little bit. So from this Properties tab, we can click on Add property, and we need to add a couple of properties that we will be referring to include as well as interacting with from the dashboard. So the 1st 1 is max temperature, and this is a property that we will use to set or control the maximum temperature range for our system. So the name over this marks on the score temp, and we can select from the property type. It's afloat since we'll be measuring temperature, the range will be using here is minus 15 to 80 degrees, and that's simply the Celsius range for our DHD 22 center. We want this to be a read on right permission because We want to actually set this temperature from the screen or from the cloud itself. And that will be the max temperature that would be allowed for our circuit onda the rest of the other properties. We can simply leave them as the fault, and we can click on at property. So once that's added, we have to add another property. So I'm going to click on that property again. And the name of this one is override Underscore fan control. And we will be using this property when we want to take control of our fans so our system is going to be self regulating. But if for any reason we want to take control of our fun and turn it on and off, regardless of what the temperature is, we'll be able to do that in our project, so the type is going to be on off bullion on. The permission is going to be read and write, so boots are only settings that we'll need for this particular property, and we can click on add property. The next property we need to create is fun on, so go ahead and click on add property again and the name of this is fun underscore on. And this here for the property type is going to be a boolean value, and it's going to be read and write. So essentially, this is what we're going to use to manually control, are fun and actually tune it on and off when we enable the override. Or this property is going to be set based on the current state of our system and whether our fun is currently owner off. So had serves a dual purpose. So that's a fun on property on Go ahead and click on that property Onda Last but not least , we need to add a temperature property, so I'm going to click on that property. And in the name of this, of course, is going to be temperature. And this simply reflects the current temperature of our circuit. So the DHD sensor is going to take a temperature reading. We're going to figure out what that is in code, and we're going to set this on a screen off our dashboard. So it's actually just going to be read on me. We're not going to be changing it, Onda. The type is going to be a float on seeing that it's a temperature value or should see the temperatures Sensor has a range of minus 40 degrees on it was all the way up to 80 degrees on. Of course, this is in Celsius. So three other thing that we want to do is when the value changes. We wanted one update and let's do every half of a degree. So 0.5, we're gonna change that to 0.5, and that will be the temperature property that we need for our project. So go ahead and click on that property. Andi, this would complete the properties that we need that we actually are going to interact with in code and as well as on the Coyote Cloud dashboard when we work with our project. 27. Making Code changes: Welcome back, everybody. And now it's time for us to dive in to some code and make the cool changes that are necessary for project toe work and for everything to come together. So here we're at the Coyote Cloud page and we have created four properties on and these properties we're going to refer to them in the cud. Onder, just a quickly recap we have our fun on which would be responsible for or I should see this is where we would tune are found on and off the marks temperature setting. We also have the override fun control when we want to take control of our circuit and then we have a temperature setting, which is just a read only value. In fact, it's the only read only property which reflects or updates with the true value of the temperature of our I T system. So those are the properties, and I'm just gonna click on the dashboard here, and these are how they are going to show up. And when we actually write our code and we're testing out our sick, it will come back to the dashboard so you can see all of these in action. So no, let's go ahead and write some code. And to do that at the top there is a button, that school edit sketch so you can go ahead and click on that button. And that should banned us in the Arduino Web editor. So let's click on that button now. So I'm just gonna maximize this window here a little bit so we can see our cool a little easier. So again, our first step as we come in here should be to click on a secret tub. And here we're going to enter the SS I. D and the password for our wireless network. So let's proceed to do that now, in order for our maker board to connect to our WiFi network. So when I enter the SS, I d hear of my network and the password. And once you have entered those values for your wife or a network, we can click on the mean tab here for our project. So once we're back here, the first thing that we need to do is we need to include the DHD Library, third party library, so we're able to use some of the convenience functions in there for our temperature sensor . So if we click on the library's tab, that should load up the library manager for us, and I'm going to click on the custom tub. And here I'm going to search for just teach T so you can type in DHT and hit Enter. And here we see the DHD Sensor Library. We want to go ahead and click on the include button, so that should include the DHT library at the top of our program here for us. So once that's done, let's cool down of it. And we have to declare a few constants here in our program. So right under thing properties that each where we include our thing properties that each file let's set up some constants. So the 1st 1 is we're going to define our DHD pen, and that is going to be pin seven. If you remember that was connected from the temperature sensor, the hope up in tow, our Meeker board. Then we're going to define the DHD type on. That's going to be DHT 22. This is what we will be using to a foot of which vision of the library or I should see which specific censor the DHD 22 a. D h d 11 were using. We're using the DHD 22 from this library, so we have to define a variable there that we will use. Then Stan sheet the DHD object and then next we can define our DHT object, and it's going to be the HD. We're gonna call it DHT. You can name it anything you want. But since it's the DHT library, we're just gonna use Boquillas tht and it's going toe granita pass and the d h depend that we're using, which was seven above on the DHD type. So this would clear our DHT variable or I should say, are in san she ate r GHT object on. This is what we will be using to take our temperature readings. Couple of the variables you wanna set up is define our fun six. And the positive pin of our fine is connected to pin six on our maker board. And the last variable we wanted to find is a default marks temperature. So let's see, e temperature was not set or a maximum temperature was not set from our i o T cloud interface that which it had no value. We want to ensure that we just have a default temperature that our program will use on and that we wanted variable changes or a set. Then it's picked up. So we just want to account for a null value or nothing mean the and let's set our default max temperature to 30 degrees. So once those of variables are defined, that's cruel down here in our program. And we need to add some additional cool right after the printed a bargain for here to initialize our objects and so on and to get things ready for execution. So the first thing that we do is we do a DHT, not begin, and that's going to just initialize our teach the object and make it ready to take readings . And we're gonna set up a pill mood for our fun pin as output. So we're seeing that are fun. Pain is going to be used as an output and will be sending no one high signals of that. And that, actually is what will go to the peace of our transistor to turn our fun on and off. Initially, we also want to turn our fun off so we can do a digital freight to our fan, and we could write a little signal to it on. Essentially, this initially tunes off our fund on here. We check if mocks temp is equal to no meaning that property was not sent. We want to set max temp until it afford max temp, which is that value at the top of our program. So just switching over here quickly to think properties that each remember Max temp was that property that we have, where we specify the maximum temperature. It we have a reference to that variable here from all thing properties that each and here were initially checking. If that value is MT. Or there wasn't anything in there, we're going to set it to the default max temperature, which would be 30 degrees. So that's the end of the set up that we need to do in our set up function after initializing variables and our fan pin and certainly max temperature and now we get into the loop function where all the magic happens for our self regulating system. As I mentioned, though, to make things easier before we get into loop there are a couple of convenience functions that we're going to write, and I covered that in the previous lecture when we discussed some of those functions and logic that would be in there. But before we start writing that, I just wanted to highlight those callback functions that go created for us. So on Max Temp change again. Once we tuggle the widget from the IRA T Cloud, a signal is going to be sent from our make aboard over the Internet I D Cloud and whatever court is in here is going to be executed as well as the override fan control and the fan on double switch. So a bully and I should see. So once those values that changed, these quote back functions are going to be executed. So the first function that we want to right here is the regulate temperature. So we're going to do avoid regulate temperature. So if the temperature is greater than Marx, underscored temperature marks on the score attempt. If that's the keys, then we are going to turn our fund owns Will do A did still right our fund pin, and we're gonna right toe high. And of course, that's going toe Turn on our fun, Els We're gonna turn off our friend and the turn off our fun We do a digital right there are fun on that's going to be little. So in addition to turn any values on and off, we also want to set the fun on a 1,000,000,000 flags and fun One is going to be equal to truth. Onda here since we turned off our fun fun off is equal to truth And these are I should see the funnel on fun on here Sorry is equal the false So they found on property itself is what we are, what will be visible in the I T cloud interface. And of course, if we turn our fun on, we want him Make sure that the value of that property reflects the current state of our fan . So we're also gonna turn that flag true. And then if it's of course, you turn the fan off. We wanted to in that flag off, so it's gonna be false. So that's the regulate temperature convenience function. The other function we talked about was turn fun on or off, and this simply will check if that fun on flag is set to true on again. Remember, this is a value from our I ity cloud We want to turn our fun on so we do a digital right and to our fun taking it on health We turn off our funds who do a digital right to our fun and we turn it off. So those already only two conditions that we need to execute here and it turned fun on or function the last bit off, I should say, the last major function or convenience function that we want to create a update system so we can again have avoid upbeat system here. It doesn't take any arguments or parameters. So if override fun control, basically if that which it was set to true from the mean dashboard, then that means that we need to manually control are fun. So if that override fun control is set, we can call our tune fun fallen off function here, And that's going to be this guy, and it's going to check to see if the fine is on about. We have to inspect the current state of that fun on property. And if it set the own we gotta turn off and on. Otherwise, turn it off. So that's once that override flag is set, we need to inspect that variable. Otherwise, if it's not sent, we simply want to regulate the temperature. So our system is going toe up your operate like normal, and it's going to. Of course, if the current temperatures greeted any max temp is going to kick on. Our fun changed the state of our circuit to reflect that I should say, changes state of the property on the interface to reflect that. And if the temperature is less stunning max temperature meaning our system has cooled down enough, we're gonna turn off our fan and tune off the indicator as well. So those are the convenience functions. So the other cool changes that we need to make here for our callback functions. So if the maximum chip temperature was changed at any time in here, we want to call regulate temperature so immediately. If we let see, it was set to 25 degrees and we change it to 28 we immediately want to check. Hey, is this was the temperature. I was changed to a greater or the current temperature greater than it marks temperature. I was changed to and are sick. It would react accordingly. So that's going to be called here on Mac stem change. The other cool change that we need to make for the override. So once the override A is changed, I want to call update system Onda. Of course, what would happen here is if we tackle that Boolean flag to take manual control of our circuit up the IT system with just determine exactly what needs to be done. So if manual control is on true, then we check the state of that fun on toggle switch and then we we treat it accordingly and then finally, for on fund change here, we also do update system. So similarly, if we tackle that fun on bullion, we're only going to control our fun if and only if override is controlled or should see override is enabled otherwise, if it's not enable, we have to ignore it and just do regulate temperature. So hopefully you see how these, you know, by writing these three here, convenience functions were ableto referred to them in our callback. So once that those functions are written in our loop function and becomes very simple here . So the first thing is in a loop function. We want to read the temperature data. So in order to do that, we simply do a temperature. And that is the property from again our i o t. Which it screen or from the i o T Cloud we set that temperature value is equal to DHT. That read temperature on our library will take care of getting that reading from all the HD 22 sensor. And here we can do a serial. We want a print out to the serial monitor, the temperature and specifically what the value is on here. We can do a serial that print out that temperature value, and we also want to indicate that it iss Celsius circular cereal, that print print line, give us peace and put Celsius, and that's gonna print out the current temperature. So once that is done, really the only function we need to call in here as update system, so that's gonna take care of everything else. No other cool or logic is needed in here, and then we can put in a dally off of five seconds or so so the temperature reading would be taken every five seconds and just a comment here about updated system. Basically, we're going here to control the fund or regulate temperature based on user input setting. So you can see by writing that one up the IT system function. It takes care of everything here and are looked for us. We don't have to duel this logic and checking on in this way by writing our code in this way. It's very I should see. It's very neat. It's also there is separation of concerns because each of these functions handles something specifically. And of course, there's a lot of re use of those functions and that were referred to the seem logic and our callbacks. And it's just a clean, neat way to write our code and a reusable we that it's easy to understand, and also we have a maximum reuse, very efficient. We have writing our code, so that's it that completes the code changes that we need to make Andi in next lesson. We're going to test everything out. So, uh, pretty soon we're going to see if all the wiring of our circuit and all the court changes everything was able to come together and let's see our project in action 28. Testing it out: So now we're gonna test out our project and I'm gonna connect the aren't we know board to my computer. So once the board is connected, as you can see, it was detected. And the first let's go ahead and compile on upload our co two the board So we can click on the check mark here that's gonna compile and verifier code. That's that. This room to see if we had any errors, success, compile, elation or successful. And now let's proceed to upload Onda, save the cool toe aboard to click on the right arrow. Then we'll give this a few seconds to run. Okay, so it we got the success message. It was successfully uploaded to our board. Let's go ahead and click on the serial monitor here. Onda, as you can see there ago, so we see the connected status on. We also see the first humidity and temperature reading being displayed. Now you'll notice if we remember in our code we had a Delia five seconds, so really, every five seconds we're going to spit out, or I should see the split pea temperature and humidity values and one small tweak that we could make to make this show up a little better. Weaken do here after we do a serial that print Celsius weaken simply do, ah, cereal, that print flying and let's go ahead and upload that change and that will just simply meek each reading, come out on a new lying. So let's upload that we can also have then serial the print mine Celsius here. So now we see the humidity and the temperature being printed on separate lying. So that's kind of what we wanted just to be able to clearly see that. So once that's done, let's go ahead and open up the crowd console the goto I ot cloud. I'm just gonna open this any new window that we were able to sort of see it by side by side on. Once that loads up, we can click here on the widgets icon on here, our values. So here we can see the humidity. Right now, it's about 50.6% on the temperatures, about 24.8 Celsius. Now let's look at a change and let's see how, when the values change, how they are reflected on the I T cloud as well as any council. So it a similarly this change. What I'm going to do is I have a sword and Ryan has in a village that can get really hot. And I'm going to bring this order and iron close to the actual sensor. Onda Ben, We'll actually see the values change. So here ago, when I bring the sword and iron, and as you can see, I'm just gonna move it close to the sensor. Remember, the readings take place every five seconds on, and it should be pretty hot. So, as you can see, there goes. The humidity changed. The temperature was 24.8. I notice any consulate went up to 25. I'm just gonna bring it a little closer. 24.8 25.5. And remember, we said the temperature on the council, the change when? As adults off 0.5 degrees. So it's getting hard term. That's gonna move it pretty close here. And as you can see, it's going up. So the temperature change from 25.5 26. Humanities at 50.2 and it's continuing to go up. It's getting harder. 26.6, as you can see in our console. It's now 27 but again, Delta isn't big enough. When she does this speaking up them and jumps to 27.2, so various see it it's working on. It's taking those Delta changes into effect and only updating the Cloud Council when the Deltas are greater than 0.5 for temperature and 1% for humanity. So, of course, the humidity values dropping as temperatures increasing because the ear around the sensor is getting this. There's less water vapor as it's getting hotter. So that's why humanity is dropping. All right, so now let me move the Southern iron. I'm gonna put it back and let's just give it a second or so when we will see. Actually, temperatures start to drop again. So right now it's at 27.7, and, as you can see in the serial, monitored went to 27.6. But since it's not at what Delta 0.5 Hour Cloud Council is still going to say 27.7 and it's dropping some more 27.3 and we're getting pretty close once it gets to 27.2, we should see the cloud Consul should change, and there we go. All right, so because it was adult off 0.5, a change. So a circuit is working. Our cloud council is working. Were it was the view our properties on. And that's how you use a D. H d 22 center. That's how you take measurements and you configure it in the art we know rt cloud. 29. Using a Third Party Library to handle Debouncing: Now we're going to go ahead and introduce a change to our code to make it a little more robust in the way that we handle the bouncing. So let's go ahead on. We can click on the icon here and back to edit code, and this should load up our Web editor, Onda. What we're going to do is we're going to introduce a good party library called F T the bouncer. So if you remember down our code, we was simply toppling or button and we were introducing deadly. This probably isn't the most efficient way to handle the bouncing by introducing a delay of one second in our program. So we're gonna show it away that it could be done a little more efficiently and in order to do that, will also demonstrate how to use or include a food party library into your IittIe application. So from the left, let's go back up here to the top. Let's click on the library's tub, and we're going to search for a library. Andi, in here. Let's sit for Ft. The bouncer and you can click on the magnifying glass, and that brings up the FT to bounce a library and here we can actually include this library and top project. This is mean, very easy for us. So I'm just gonna go ahead and click on the include button, then what I noticed with the Web editor since it is to in beta that I tried to include a library and I actually did not see that library showing up here for me. So maybe it is that as it's still going through some changes, I'm I'm sure that that bug will be fixed. But for the time being, that was simply the process of how a library should be included by clicking on the include button and that should be included in your code. But we're gonna have to manually include our FT the Bones. So I worry. So right under here after the initial includes statements I'm going to do and include, And it is called F T The bones here that each and that is going to include RFD, the council, every for us. Next up, if we school a little bit down, we're going to have to create for the clear and FTD Bonser object. So here, right after are defined button pen weaken, do an f t the bouncer, and we're gonna call this object buttons. And if we scroll a little bit down after the pin load in our set of function, we're going toe initialize that buttons object. So we're going to do buttons that ad pin, and we're going to pass in the button pin and initialize that as low and next we're going to do buttons, got in it, and that's going to initialize our buttons object. Then, in our look function, we actually after the Arduino cloud, that updated statement. We simply have to run buttons that update, and this is going to determine if our button was pressed or not. So we can actually remove this code that we had previous me and remove that daily. And now we can implement a couple of callback functions, and these Kobach functions will actually tell us if our button was pressed or not. So the 1st 1 is void on pin activated and we're going to except in there you went eat on the score T pin number, and this callback function actually is called when our button is pressed. So here we would inside this function would put any appropriate logic that we want to execute so we can do a serial that print lying, printing on that pin number of variable. And here's where we actually tuggle our tackle variable. So Tuggle is equal to not Tuggle, and this was the scene logic that we had before. There is also in mother callback function that we have access to and that is on pin deactivated. It takes the same tape of input as the function above that pin number. You went heat on this court E and weaken do again, a serial in here, that print line, and we could print that pin number. So we're not actually doing anything here. Once a whiteness depressed so again un been activated will be fired when a button is pressed and when we release the button, that's when UNP in deactivated will be fired and we could have but some logic in here. But we're really concerned about this where we would tackle the value. This is where when a tackle the value of our property. So those are all the code changes that we need to make, and we can go ahead and click on the verify and Deceive Button here that's going to compile our code andan. Sure, we didn't make any errors, so it looked like Oh, yes, I mean a type of here. So it was serial dot print line. So let's try that again. That's why we should always try to compiler cooled before we uploaded. It would tell us if we mean any errors. Looks like we're good to go. So now we can go ahead and upload that cool toe outboard. So one status uploaded and compiled on sent upto aboard, we can proceed to test out our changes. 30. Testing our Debouncing Changes: Let's go ahead and test out our changes. So from our Web editor, that's go ahead and click on Go to Coyote Cloud. That's gonna load up our dirty clothes on. And I'm going to do this. Actually, since we want to see the serial monitor, I'm just going to let's go back to edit code. And when I click on monitor and I'm going to open up the Coyote Cloud and in New Window that we will actually be able to see the serial monitor and the ality cloud on will be able to see the messages that are sent there for our core packs. So once we're in the parity cloud, we can click on the whited stub on Here's Our Toggle Switch and now I'm gonna go ahead and press are button. So let's see how well our third party ft the bones of library works. Some go ahead on duh press the button and there it registered. That is true falls true fools. True, false. Now you notice every time I press there's one value that shows up. Five. That's that You went it, variable that a sentence. And when I released the button, that's why you see a second value of five also showing up, so it operates in the same way as before. But this is just illustrating how 1/3 party library can be pulled in and used in our reality applications and our I t projects on. And this is just a more efficient way of handling the bouncing as part of detecting when our button was pressed. So hopefully this was valuable to you. Onda. You're able to see the the benefit of using big party libraries and also were able to see how we can detect user interaction with our maker board in our projects. 31. Project Overview - Motion Sensor Alarm that calls your Cell Phone: This is one of the coolest projects that we will be building in this course on. It is a fully fledged practical I ot application. We're going to tackle a temperature controlled, self regulating system that is controlled and monitored from the cloud. Essentially, our application will be able to set a desired temperature on our fun will automatically kick on and off toe. Cool the area surrounding our temperature sensor toe the desired temperature setting. I will also show how you can create a dashboard that not only allows you to set the desired temperature range, but also allows for Emmanuel Override enabling you to control the fund from a console. The dashboard will also contain real time This please that sure, the temperature of our sensor. We simply have to set the system on forget it itself regulates on its own. Around the we, we will learn how to control a fun electronically using a transistor as a switch. We will also learn how to create an I O T. Dashboard to fully control our fan and set a desire temperature range. The project will also show how we can implement a feedback group in the cloud that allows our sick it to self regulate the control temperature. All I will work culminates in this final project, and it's going to be a lot of fun. Everything we have learned will all come together. Let's get started. 32. Wiring the Circuit: No, it's time for us. The wire up our circuit. So first, let's create the ground, Really? Or maybe ground connection on our bread board, someone taking when I'll be connecting wires. And here, of course, the ground pin from our maker board. It's clearly highlighted here, and White will make that connection there. And we're gonna connect back to the ground really on our bread board because we're gonna have a couple of connections that are coming off of that. So let's first do that. Then let's wear a power the HD sensor and, of course, without DHT sensor. As you can see, there are three pins and it pin here. On the left is the positive pin or the visi seep. In the middle pin is a signal pin, and then deep in here on the right is ground or it's connected the ground. So I'm just gonna insert this sensor here in tow bread board and the first let's make the VCC connection. So that positive been here? I'm going to connect that here. As you can see, make sure it lines up in the same rule here, gonna make that connection here, and that we're going to connect to that to five folds on our meager board. So if we look here for the five old men, it is the pending here at the top. When I make sure that we like that in So that is in place. Next up the middle pin here on our DHT 22 sensor is Thesiger Nall pin and that is going to pin seven on our maker board. So just make that connection now and ensure that we get that middle pin lined up here and pin seven on Arduino board here is actually the second to last Been a Zaken see here in seven. So when I make sure that that lines up on it goes into the second to last socket here and it's been seven, and then, of course, finally depend here on the right had been on our sense of goes to ground. So I'm gonna make that connection Now I want to ensure that it lines up in a row with that pin Onda. Once we get that in weaken, just connect about two grown and again, this is all ground real going all the way across here at the top, and it will be grounded. So those any connections that we need for our sensor Next up, let us do the connections for our transistor. So here is our to end 39 or four transistor. And as you can see, what the transistor there is a flat surface here, Andi, When it's oriented with a flat surface facing you, of course I'm gonna turn it here. Here, the round sort of curved out there surface. And then here's a flat surface. Would be actual rating. Spring a little closer here with the actual writing on the transistor. Um, the left most pin here is going to be the emitter. The middle pin is going to be the base, and the right pen is going to be the collector. So I'm just going to insert this into the circuit and the make sure it's oriented that way with the flat side. As you can see, the curve, the site is on the outside, the flat side facing me or facing us agency. And that way we can know the orientation of dependence. So from our emitter, we have to make a ground connection. So the materials directly the ground, so I will make that connection now, So I just want to make sure they've been here and it left you line it up. We insert that where There to depend on the left. And we want to ensure that we grown that image or pin. So that is the ground for emitter. Next up the middle pin is the base spin and from the base, we actually have our one key res sister. So I'm gonna connect to that here to the base. That's when I ensure that we lying that up here in the middle. As you can see, I'm gonna connect back to another point here and bread board somewhere else on the bread board, I mean, and the other end of that base resistor goes to pin six on our maker board. So I will make that connection now. And here is that again we connect the other end about resistor along that same room, and we're going to go to pin six and then six on the maker board if return it here is actually the very last pin here on just below the pin seven. So we just want to make that connection here. That is the base for our transistor. I should see it's the end of the resistor that's connected to DB seven transistor and then from the collector, we go to the negative of our funds. So here is my CPU fund. Let me just quickly show it. And as you can see from their reading, it's a 12 volt DC fun, an iterated at 120.2 amps. So we're going to use as I mentioned to battery packs to get up to 12 volts. And if we look at the fun connections here, you'll see a series of wires. But what we're concerned with is theblaze choir and the red wire so they black would be the ground or negative wire, and the red wire is going to be our positive wire. So coming off of the collector here on our transistor, we're going to the negative or the black wire of our fun. So depending on whatever fun you have, just look out for the black and red wires, and that will give you an indication of the polarity. So I'm going to take a wire connected to the collector of or resistor. That's 1/3 pin. Make sure it is lined up. Connect that and and the other end of the wire goes into the black wire off our fun. So here, I mean that connection here. So the black wire is the outermost wire, and as you can see here on the left, that's where that connection went into out the most wire here on the left, the wire. Dustin. Right. Next it is the positive on that is actually going to go to the positive of our battery. But the phone connect our battery. Let me just show you here. These are two battery packs that we're using. On that they are for 1.5 bull batteries. And if you add up the 1.5, you'll get six folds per battery. And here is a six full butter proxy. Put them together in series and it's gonna be 12 volts. So let me show you. Actually, how are we going to do that? And if you look here in this particular body here, battery holder is pretty nifty. It has ah, sort of a female plug at the end on ditz. Once you put your batteries and your ableto come off of this female and meal again It's labeled Block I should see and a red wire. So if we're connecting batteries and Siri's remember, earthy negative of one battery has to go to the positive of the other. So I'm just going to make that connection Now, here, off the black wire, which is this end here Gonna push in. My connecting wire actually should go in a little more firmly. Right. So here is the end, and you should try to needing this up and actually put some tape so that this wire isn't exposed toe prevent shorts, but the black wire here it's connected to my connecting wire, and that has to go into the positive of the other battery pack. So here, that goes into the red wire. So if you look at the red wire, is this wiring inside? And I'm going to make that connection here to the inside. So that is on the insane. Let me just fix that. There you go. So that's the inside. And then, of course, the outer wire is going to be our negative wire. That's going to go the ground. So I will use another connecting wire here. Okay, so this goes to ground this one. Insure, push this in and on this side. Here we have it. Positive wear, which would go to the positive section for a second. So just a shoe that these two battery packs are connected in Siris. But shoes on multi meter. And that's strictly footage. So I've connected them here. Here, I have. Ah, generic multi meter, and I'm gonna turn it on on its own. Actually, these e Volz size. Put it on the 20 volts setting, which should be enough. Take the measurement. I was gonna put this here on and let us check the voltage of our battery. So I'm going to check this out here. Here is the negative. So I'm gonna put the terminal there and what the terminal to the other were. And if you look at our multi meter, it says 12.74 bolts. So we're right, right? About 12 bullets all over 12 volts. So, as you can see, we connected our battery packs in Siris. Andi, it looks like we're good. So once that is set up to move the multi meter here out of the me. And now if you go back toe a circuit remember, the positive of our fan has to be connected to the positive of our body repack. So let me just do that right now. Here is the positive of our body pack, and we go back to the fan connection. Remember, we had the negative connection and the bread is the positive. So I'm gonna make that connection now. So now a Nazi positive of our fund and the other end of our battery has to be grounded. So again, here is the ground, the connection on our circuit. I guess when I ensure that that's grounded and that is it. So here, just uneaten things up. We have our body re peck. It's connected to a circuit. We have our fun connected. We have our DHT 22 sensor. We have our transistor and everything is connected upto a maker board. So they very last thing, of course we have to do is use our USB cable and connected into our maker board and the other, and it is going to go into our computer. So I knew that was quite a lot of wiring there, but hopefully you're able to follow alone with me and with the circuit diagram, please double check all your connections double and triple check. And of course, make sure that your Arduino maker borders powered off. There's no power supply tit as you are things up and when you have everything ready, will proceed to make all the co changes that we need, and then we will upload those cool changes to our circuit to test out our project. 33. Configuration in the Arduino IoT Cloud: Now I'm going to go through the process of creating our thing for our alarm circuit. And then we're also going to create a property to associate with other thing. So head over to create that Arduino dot cc in a browser. Onda log in with your Arduino account and the country there. We want to click on our we know Coyote Cloud. So once that loads up, if you have an existing thing, go ahead and delete it. So we'll click on Delete Button, and now we're going to create our new thing. So click on the new thing button for the name of our thing. Let's call it I o T Dash Cloud Stash PR dash alarm bash thing. So this is gonna be the name of our thing. And, of course, for the maker board. Let's leave the maker. Why, Farid Tent in selected Andi, That's quickly create. So once our thing is created, let's proceed to create a property for our thing. So click on the plus sign here, and the name of our property is simply going to be motion m o T i o n. And we will be using this to reflect if motion was detected from a P R sensor. So the property type let's go ahead and select a bullion. And for this on off Boolean value, simply when motion is detected, we will be doubling this or setting it to true. And once motion is not detected or nothing is happening in our surroundings, it will be set off. So for the permission, this is just going to be a read only property. We're not actually going toe right from it because we're going to let the Pierre sensor drive or control what valueless is. And we're gonna allow the user to set this from the cloud user interface and for update and for update. Let's just leave when the value changes and they should be selected by default. So once that's done, go ahead and click on the create button Onda. At this point, we have completed the configuration of our thing and the property that we will be using for our priority project 34. Making Code changes: Welcome back, everybody. And now it's time for us to dive in to some code and make the cool changes that are necessary for project toe work and for everything to come together. So here we're at the Coyote Cloud page and we have created four properties on and these properties we're going to refer to them in the cud. Onder, just a quickly recap we have our fun on which would be responsible for or I should see this is where we would tune are found on and off the marks temperature setting. We also have the override fun control when we want to take control of our circuit and then we have a temperature setting, which is just a read only value. In fact, it's the only read only property which reflects or updates with the true value of the temperature of our I T system. So those are the properties, and I'm just gonna click on the dashboard here, and these are how they are going to show up. And when we actually write our code and we're testing out our sick, it will come back to the dashboard so you can see all of these in action. So no, let's go ahead and write some code. And to do that at the top there is a button, that school edit sketch so you can go ahead and click on that button. And that should banned us in the Arduino Web editor. So let's click on that button now. So I'm just gonna maximize this window here a little bit so we can see our cool a little easier. So again, our first step as we come in here should be to click on a secret tub. And here we're going to enter the SS I. D and the password for our wireless network. So let's proceed to do that now, in order for our maker board to connect to our WiFi network. So when I enter the SS, I d hear of my network and the password. And once you have entered those values for your wife or a network, we can click on the mean tab here for our project. So once we're back here, the first thing that we need to do is we need to include the DHD Library, third party library, so we're able to use some of the convenience functions in there for our temperature sensor . So if we click on the library's tab, that should load up the library manager for us, and I'm going to click on the custom tub. And here I'm going to search for just teach T so you can type in DHT and hit Enter. And here we see the DHD Sensor Library. We want to go ahead and click on the include button, so that should include the DHT library at the top of our program here for us. So once that's done, let's cool down of it. And we have to declare a few constants here in our program. So right under thing properties that each where we include our thing properties that each file let's set up some constants. So the 1st 1 is we're going to define our DHD pen, and that is going to be pin seven. If you remember that was connected from the temperature sensor, the hope up in tow, our Meeker board. Then we're going to define the DHD type on. That's going to be DHT 22. This is what we will be using to a foot of which vision of the library or I should see which specific censor the DHD 22 a. D h d 11 were using. We're using the DHD 22 from this library, so we have to define a variable there that we will use. Then Stan sheet the DHD object and then next we can define our DHT object, and it's going to be the HD. We're gonna call it DHT. You can name it anything you want. But since it's the DHT library, we're just gonna use Boquillas tht and it's going toe granita pass and the d h depend that we're using, which was seven above on the DHD type. So this would clear our DHT variable or I should say, are in san she ate r GHT object on. This is what we will be using to take our temperature readings. Couple of the variables you wanna set up is define our fun six. And the positive pin of our fine is connected to pin six on our maker board. And the last variable we wanted to find is a default marks temperature. So let's see, e temperature was not set or a maximum temperature was not set from our i o T cloud interface that which it had no value. We want to ensure that we just have a default temperature that our program will use on and that we wanted variable changes or a set. Then it's picked up. So we just want to account for a null value or nothing mean the and let's set our default max temperature to 30 degrees. So once those of variables are defined, that's cruel down here in our program. And we need to add some additional cool right after the printed a bargain for here to initialize our objects and so on and to get things ready for execution. So the first thing that we do is we do a DHT, not begin, and that's going to just initialize our teach the object and make it ready to take readings . And we're gonna set up a pill mood for our fun pin as output. So we're seeing that are fun. Pain is going to be used as an output and will be sending no one high signals of that. And that, actually is what will go to the peace of our transistor to turn our fun on and off. Initially, we also want to turn our fun off so we can do a digital freight to our fan, and we could write a little signal to it on. Essentially, this initially tunes off our fund on here. We check if mocks temp is equal to no meaning that property was not sent. We want to set max temp until it afford max temp, which is that value at the top of our program. So just switching over here quickly to think properties that each remember Max temp was that property that we have, where we specify the maximum temperature. It we have a reference to that variable here from all thing properties that each and here were initially checking. If that value is MT. Or there wasn't anything in there, we're going to set it to the default max temperature, which would be 30 degrees. So that's the end of the set up that we need to do in our set up function after initializing variables and our fan pin and certainly max temperature and now we get into the loop function where all the magic happens for our self regulating system. As I mentioned, though, to make things easier before we get into loop there are a couple of convenience functions that we're going to write, and I covered that in the previous lecture when we discussed some of those functions and logic that would be in there. But before we start writing that, I just wanted to highlight those callback functions that go created for us. So on Max Temp change again. Once we tuggle the widget from the IRA T Cloud, a signal is going to be sent from our make aboard over the Internet I D Cloud and whatever court is in here is going to be executed as well as the override fan control and the fan on double switch. So a bully and I should see. So once those values that changed, these quote back functions are going to be executed. So the first function that we want to right here is the regulate temperature. So we're going to do avoid regulate temperature. So if the temperature is greater than Marx, underscored temperature marks on the score attempt. If that's the keys, then we are going to turn our fund owns Will do A did still right our fund pin, and we're gonna right toe high. And of course, that's going toe Turn on our fun, Els We're gonna turn off our friend and the turn off our fun We do a digital right there are fun on that's going to be little. So in addition to turn any values on and off, we also want to set the fun on a 1,000,000,000 flags and fun One is going to be equal to truth. Onda here since we turned off our fun fun off is equal to truth And these are I should see the funnel on fun on here Sorry is equal the false So they found on property itself is what we are, what will be visible in the I T cloud interface. And of course, if we turn our fun on, we want him Make sure that the value of that property reflects the current state of our fan . So we're also gonna turn that flag true. And then if it's of course, you turn the fan off. We wanted to in that flag off, so it's gonna be false. So that's the regulate temperature convenience function. The other function we talked about was turn fun on or off, and this simply will check if that fun on flag is set to true on again. Remember, this is a value from our I ity cloud We want to turn our fun on so we do a digital right and to our fun taking it on health We turn off our funds who do a digital right to our fun and we turn it off. So those already only two conditions that we need to execute here and it turned fun on or function the last bit off, I should say, the last major function or convenience function that we want to create a update system so we can again have avoid upbeat system here. It doesn't take any arguments or parameters. So if override fun control, basically if that which it was set to true from the mean dashboard, then that means that we need to manually control are fun. So if that override fun control is set, we can call our tune fun fallen off function here, And that's going to be this guy, and it's going to check to see if the fine is on about. We have to inspect the current state of that fun on property. And if it set the own we gotta turn off and on. Otherwise, turn it off. So that's once that override flag is set, we need to inspect that variable. Otherwise, if it's not sent, we simply want to regulate the temperature. So our system is going toe up your operate like normal, and it's going to. Of course, if the current temperatures greeted any max temp is going to kick on. Our fun changed the state of our circuit to reflect that I should say, changes state of the property on the interface to reflect that. And if the temperature is less stunning max temperature meaning our system has cooled down enough, we're gonna turn off our fan and tune off the indicator as well. So those are the convenience functions. So the other cool changes that we need to make here for our callback functions. So if the maximum chip temperature was changed at any time in here, we want to call regulate temperature so immediately. If we let see, it was set to 25 degrees and we change it to 28 we immediately want to check. Hey, is this was the temperature. I was changed to a greater or the current temperature greater than it marks temperature. I was changed to and are sick. It would react accordingly. So that's going to be called here on Mac stem change. The other cool change that we need to make for the override. So once the override A is changed, I want to call update system Onda. Of course, what would happen here is if we tackle that Boolean flag to take manual control of our circuit up the IT system with just determine exactly what needs to be done. So if manual control is on true, then we check the state of that fun on toggle switch and then we we treat it accordingly and then finally, for on fund change here, we also do update system. So similarly, if we tackle that fun on bullion, we're only going to control our fun if and only if override is controlled or should see override is enabled otherwise, if it's not enable, we have to ignore it and just do regulate temperature. So hopefully you see how these, you know, by writing these three here, convenience functions were ableto referred to them in our callback. So once that those functions are written in our loop function and becomes very simple here . So the first thing is in a loop function. We want to read the temperature data. So in order to do that, we simply do a temperature. And that is the property from again our i o t. Which it screen or from the i o T Cloud we set that temperature value is equal to DHT. That read temperature on our library will take care of getting that reading from all the HD 22 sensor. And here we can do a serial. We want a print out to the serial monitor, the temperature and specifically what the value is on here. We can do a serial that print out that temperature value, and we also want to indicate that it iss Celsius circular cereal, that print print line, give us peace and put Celsius, and that's gonna print out the current temperature. So once that is done, really the only function we need to call in here as update system, so that's gonna take care of everything else. No other cool or logic is needed in here, and then we can put in a dally off of five seconds or so so the temperature reading would be taken every five seconds and just a comment here about updated system. Basically, we're going here to control the fund or regulate temperature based on user input setting. So you can see by writing that one up the IT system function. It takes care of everything here and are looked for us. We don't have to duel this logic and checking on in this way by writing our code in this way. It's very I should see. It's very neat. It's also there is separation of concerns because each of these functions handles something specifically. And of course, there's a lot of re use of those functions and that were referred to the seem logic and our callbacks. And it's just a clean, neat way to write our code and a reusable we that it's easy to understand, and also we have a maximum reuse, very efficient. We have writing our code, so that's it that completes the code changes that we need to make Andi in next lesson. We're going to test everything out. So, uh, pretty soon we're going to see if all the wiring of our circuit and all the court changes everything was able to come together and let's see our project in action 35. Testing out the Alarm: notes. Time to test out a project. So, of course, you first have to connect your maker board the U. S B cable to the board and then to your computer. And you want to ensure that that the Arduino maker WiFi 10 tennis selected here as your board and the first thing we canoe is a verify our code. So look on the check mark toe, verify and save. And this is going to do an initial compile ation of our code. And if everything is OK, we should get a success message showing up. So if you had known con violation errors, then you would get that green success message. Next up, Let's go ahead and click on the right are photo upload the cool toe, our maker board. This will just take a couple seconds. So once that's done again, you will receive a success message and let's proceed to test out our circuit. So first I'm just gonna go ahead and click on monitor, and this is going to bring up the serial monitor here. And as we're testing out our circuit, we want those messages to show up. We'll be logging out to the serial monitor and we can open up our charity cloud and a new window. So let's go ahead and do that. That way we wouldn't have this side by side as we test things out and go ahead and click on the widget stone. And of course, this is going to bring up our motion property. So to test this out, I'm just going Teoh, move my hand in front of our motion sensor and let's simulate some motion happening and see what happens. So you notice my hand went in on motion detected was true, and then it went back to fools. This is expected arm still moving my hand. That's why it's triggering someone to move my hand away and it should go back to full, says, You see, and motion ended. That was the speed. No, I'm gonna go ahead and move my hand back and as you see a detective motion again and move my hand away and motion has ended. So it's going off because they're moving in the background here. But as you notice as you're moving around the sensor as it detects any kind of motion movement, it fires off the sensor and that flag goes from false the truth as well as in our serial monitor. We're seeing the logging off when the property is set. When motion is detected on after a slight delay, it goes back from Haida lore. That signal pin goes back from high to low, and motion has ended. So again, let me Trevor it one last time just gonna move my hand nearly sensor and they had sets it off. And I'm gonna move my hand away and that she should go back from true defaults, so they am actually moving a bit in the background. So there you have it. That's the first part of our PR alarm thing, and we are going to make a modification to this project to make it a little more interesting. And we're going to configure a Web hook which allows a lot of amazing new possibilities with your piety projects. So that's going to be coming up in the next few lectures 36. Overview of If This Then That (IFTTT): Have you heard about this cool service called If this, then that or I f t t t pronounced ift for short. Well, if you have, please feel free to jump ahead to the next lecture where we'll see it in action in our project, for those of you that have not heard about if before, prepared to learn about something really awesome So what is ift? It is essentially on automation civil that enables you to connect various services so that when something happens with one service, a trigger goes off on an action takes place automatically on the other. So what does this mean? Let's break it down with a simple example. Let's see. You love to upload photos to Instagram. You can create a flu in ift, which basically says whenever I upload a photo to instagram, automatically back it up in a folder in my dropbox account, you can even find you in this logic to see only photos with a specific hashtag, an instagram will be uploaded to Dropbox. You can do this all without writing a single line of code. Just a few clicks are needed tow hook these services and triggers together in the technology landscape. Today you are connected to your APs and devices, but how many of these interact with each other? Integrating them is sometimes hard if it is the free bridge that makes each app, service or device talk to each other and chunk different tasks for better productivity. When you set up a flu in IFT, it is calling APP. Let there are thousands of Apple. It's already written out there for you to use and even ones for companies like Google, Facebook and Microsoft from many services they offer, bringing it closer to home. When we look at the Internet of things, if it allows you to connect events from I ot devices, sensors and modules that downstream services and epi eyes so that actions can be automatically triggered as an example, you can easily set up switching on or controlling an Iowa T device using Alexa with minimal configuration. You can also create basic I ot integrations like pressing a button to send a tweet, turning on a Philips hue light when you're Rieti devices, sending a message controlling color on the on off state of lights in your home beast on the time of the on weather conditions specifically for a i ot projects. If has the concept of Web hook integrations, essentially, you can configure a Web hook trigger to receive a Web request and perform in action. Actions may be sending an email calling your foon logging a message to Evernote or any other service that exists in the F platform. You can also set up custom actions were actually going to set up a custom apple it for our I T project. In the next video, let's could be Look at the breakdown of the ecosystem NFTE. You'll hear the concept of a service. A service is essentially a two application or facility that works with left. Some of the most popular services include Facebook, Twitter, instagram, YouTube, Soundcloud, Dropbox, Evernote and Pocket. You can also search services for weather, smart home controls, clocks, electron ICS and many more. The other concept you will hear about NFTE is an applet. Applets are essentially a combination of services that use a trigger and in action. When something happens on one service, it triggers an action on another couplets air. Basically, the formulas you set up for the sighting, which triggers will prompt which actions before getting started. You need to create a free if the count head over the i f t d t dot com, and click on the Sign Up link. You can create your own account using an email in my password, or you can sign up with your Google or Facebook account. Let's do that now. 37. Enabling an Applet on IFTTT: Okay, so here I am at the IFT website. I have t t t dot com and if you don't have an account at the top right here, you can click on the sign up button Onda, as I mentioned there, few east that you can get started with ift Onda Sign up for an account so you can continue with Google or you can use your Facebook account. Or you can simply create your own Emil and password to sign up. So if you haven't signed up already or you do not have a nifty account, go ahead and do that now and I'll show you how to enable an existence app let from the many choices that are available. So I'm gonna go ahead and sign in Onda. Once logged in, you have the ability to search for existent apurate. So we will set up on existing outlet for now. But in the next video, we'll actually be going through the process of creating a custom applet that could hook into our art. We know I ot cloud projects, so once I'm signed, then because I have some app lets already installed, I get some recommended up. Let's that might be available. That would interest me. So as you can see here, we have said SMS text to my email. We have some stuff pertaining to Google and Instagram and Twitter and so on someone to click on the search box on the outfit that I want to look for something pertaining to NASA images. So let's see. We want to receive NASA images for the days and cool out US peace sort of photos and images . So I'm gonna search for a NASA images on Let's see what we got here so you'll notice they're up. Let's that already exist that we can simply set up on enable for our account as well as there are services that you can search on. So if there's a particular company like Facebook or Twitter or any type of integration that you want to perform, you can check to see if the particular company has existing services that are out there that you can integrate with. So I'm just going to switch back over to the APP. Let's stop and let's look at the 1st 1 here that shows up for me. Get beautiful images from NASA every day, so that sounds pretty cool. Someone a quick on that one. And typically, when you look at the app, let it tells you here is the name of the apple it and it gives a short description. This outfit will send you a stunning image from NASA every day of the week. This up, it was actually created by Facebook. And as you can see, there's the messenger local. So I'm going to enable this. So to do that, we have to click on this turn on button basically, when you set up a nut, but depending on which services involved since this was created by Facebook, it using Facebook Messenger you normally would have to probably log in tow a service so that the apple it can work seamlessly with the service and the triggers and actions can be performed. So here, as you can see, it, is asking me to log in to connect my Facebook messenger account. So I'm gonna click on OK, on here. You'll see it's asking me to sign it with fees book to get started, so I'm just going to continue as myself. So there was a little more configuration that needs to occur here. So I clicked on get started. And as he saw, IFT sent me a message that in order, the used the Facebook messenger app lets who need to confirm it's actually use. So they sent me an email. I'm just gonna go ahead and click on my email account and check out that email. Bad day sent me under basically here. I get e message to confirm the connection. Someone just chemically corn confirm connection. So I did it once. I got an error, but hey was able to click on it again. And it no said that are successfully connected Facebook Messenger toe ift. And here is the get beautiful images from NASA every day. So when you click on that guy and I'm going to go back here and I'm going to turn on so this is being turned on right now. So, as I said initially, there was some set up that had to be done and it should be turned on. So know my up. It was set up. And that means that every day and messenger, I will get an image from NASA. So a couple of these have passed, and I just wanted to show you guys out here on messenger as I enabled the applet to get beautiful images from NASA every day. I actually got a couple of images, so if you'll notice here, as you can see, this 1st 1 came in, it says, preparing for the Expedition 59 p station crew landing. So that was one image there. Andi. I also got another image, which says the Expedition 59 speech station crew land safely in Kazakhstan. So ah, that illustrates the ift integration that I set up. It is working, and I have been receiving images daily from NASA, so just wanted to show you guys this. So that, in a nutshell, is the process of how you go about setting up an applet from IFT and these air already existing up. Its there are tons of them out there. As I mentioned, you can click on search and let's see you want to search for feast book as an example Here , you'll see there are tons of different outlets that folks have created out there, or that Facebook themselves actually have created so you can automatically share new posts . The Facebook page. You can automatically upload Instagrams Facebook page albumin soon, so there is a gamut of stuff that's out here for existing couplets. And, of course, from a services perspective, you can search for all the different services or companies that might have integrations with if here and basically you can have a lot of fun with this and create integrations between different services. So if you can't find what you're looking for from an applet perspective, you can also create your own custom applet. And actually, that is what we will be doing in the next video. I'll show how we can create a custom apple it to integrate with our Arduino loyalty cloud projects, so that's coming up next. 38. Creating an IoT Webhook to IFTTT: Now we're going to go through the process of creating a Web hook for our I ot project. So the PR sensor alarm project We're going to create a Web hook, and that Web book is going to be an integration to one. If this, then that apple it on. Essentially, what we're going to do is when motion is detected, we're going to call our cell phone, and basically that is a pretty realistic application in that if you let's say you have a motion sensor at the front of your home or the back of your home when it's activated during the day or during the night, if motion is detected at a particular doorway or window, a call would automatically be me to your cell phone, so we'll show how we can make this happen. This is a really cool application, Andi. It can be built into a security I ot project. So let's head of what to the create that aren't we know dot cc website and here we want to put back on the Arduino anti cloud. And of course, we had created a thing for our i o T Cloud Pierre alarm project. So It's called Coyote Cloud PR alarm thing when I click on it. And here's where we can see the properties that are associate ID with our thing. And if you'll notice below here there is a little link that says Web book. So if you click on that, it expands out on. Basically, here is where weaken an able a Web hook to a particular service. So what this means is that whenever our bullion value changes or motion is detected, were actually able to make an http request out to some service. And the cool thing about this is there are several different dough means that are available to us. So, as you can see, we can make Web hook requests out to the maker that i f t t t dot com domain Google ap eyes dot com Domain script that Google that come and also hooks that z pierre dot com So these are some of the dough means that are supported by the Arduino authority cloud out of the box. And from here we're able to meet http requests out to any girl that is hosted on those dough means. So let's go ahead. Onda, click on the meager dot i f t t t dot com link. Just gonna open it here in a new tab, and here you should land on the Web hook speech in i f T DT. So if you had not created an i f. D. DD account in the previous lesson, go ahead and create an account. Now sign up with a using even a password. Or you can sign in with Google or Facebook on at this speech, which would be i f t t t dot com slash Meaker on the school Web Hooks This will be the Web Hooks integration page, so the first thing that we should do is click on the Connect Witten. And essentially what you're doing is you are enabling Web hooks on your account. So click on, connect on. Once that's done, Web hooks would be enabled on def. You click on this documentation, but in here on the top, right, it basically spells out what you need to do. So basically, to trigger a Web Hooks event, you have to make a post or get Web request to this. U R l and event here would be actually the name that we would configure for our event, and we'll actually do that in the next step. So it's gonna be this girl on. Do you are assigned a specific, unique key, and this will be unique to you. So any I ot application that you want to create a Web hook for and integrate with if this then that you can make an http request to this girl. And in addition to that, you're also allowed to pass an additional parameters as part of the P load of that request . So if you're sending in Jason, you can send in three values up to three values Valley one volley to value three. Or you could upend this to the end off your URL as query string parameters. So let's just keep this open, make a note of this and actually, we're going to come back to this to copy this URL when we're configuring our Web hook in the Arduino authority cloud. So next up here we are the mean i f t t t dot com boom beach, and you can click on my up let's And now here are some operates that I created, but you mean have only one. If you had followed along in a previous lesson or you may have no up, let's hear. We're going to create now our custom up Let that will integrate with our Web book. So click on New Applet. And this, of course, is the screen that we get when we first starting off a nap. Let and we have to specify this. So we're adding to this and if this and this is going to be the trigger toe our Web book. So I clicked on the plus something for this on for services. I'm just gonna search in here for Web books, and as you see, I started typing in Web and we have Web books. You're going to select the Web Look service, and we have to specify what is the trigger on our Web book service. So the option that's available to us is to receive a Web request. So go ahead and click on that Onda. We have to give our Web request on event name, so let's call it motion underscore detected. And as you can see, you can't have species in the event name. It has to be on underscore character to separate different words like be mentioned here below. So we're gonna use motion underscore detected since in our case, our PR alarm thing circuit is going to detect motion. This could be again. Anything that you want to name. It just has to be something that will be able to extract out of the request or something that's unique to this Web hook request. But we're going to use motion on the score, detective, then click on Create Trigger. And now we specify that. So we specify this this part of the interaction and if that is the action we want to take. So for the action service, I'm going to start typing and call. And as I mentioned, what we're going to be doing is when Motion is detected were actually going to make a call to our cell phone. Andi, since I know a lot of folks all over the world are gonna be taking this class instead of using the phone call us only option, we're gonna use a voice over I p call Andi in order to receive that phone call. What you need to do is in store Lee. If this then that app for your mobile device. So at this point in time, let's before we can figure this, let's pause a video and I would encourage you to go out to the APP store. If you have an android device Google Plea and the just such I f t t t and the if this then that up will come up. It's a free up Onda correspondingly, If you have an IOS device, you can head out to the IOS App store Onda search for the if this then that up Andi, Once you install the up, you can log in with your user name and password and then we will proceed from there. So take a moment, pause the video, go ahead and stole. The app will only take a minute or so. And when you get it in store than lock in, let's resume the video and continue on. All right. Great. So you got the app installed. Let's continue with the configuration of our action service. So we're gonna select here Voice over I p calls. So select the second option on. Of course, the action is going to be cool. My device select core might of ice. Andi here is where we specify some ingredients for our action. So when your mobile device rings and you pick up your going to Cecere the message Hello on event cold on event name is what we had specified. It will be motion detected occurred on your Meeker Web hooks service. So in addition to this, we can also are additional text. So I'm going to click on an ingredient. And if you remember, we're able to pass in a few optional permit er's Let's pass in a value one on that would be the area off. Let's see where motion detected. So let's say we set this up at our front door. Our backdoor. Here's where we can determine. Or we should specify when we make or Web hook requests where the motion happened and that we when we get to call in our food and can tell us exactly which sensor was triggered. So this will welcome together. When we actually configure the Web hook on, we test it out. So what I can do here is I can customize this message that would be sent us part of the phone call so I can see motion was detected at on Dhere and when a retrieve the value of value one that was passed in on my http request and we're going to pass in front door or back door and we'll test that out and see how that works. So once I've made that small change, let's go ahead and click on Create action, Onda. We just have toe quickly review and finish and click on the finish button. So no apple, it is created. And what we need to do is let's go back over to our web hooks tub and actually the time where we got this girl that we had to call. So I'm gonna copy this. You are all here. The https maker dot i f t t t dot com and so one with her a key. And I want to copy this URL on. Let's head back to the art. We know I o t Cloud. So in here, this is where we specify the web hook. You are else We're gonna piece this in here on. Of course, the event that we have here is motion underscore detected. So we're going to replace that please holder with motion underscore detected with key on at the end of our girl. Let's talk on a query string parameter value one equal to and we can see a front door. Now, in order to put a space, we have to put in the percentage saying 22 you are all in code, our string. So we put front percentage 20 door on. That's going to be the value of value, one that we pass in. So once that is done, we can click on Add Web Hook and now our web hook is created. So what we can do now is let's proceed to test it out. So again, make sure that you have the up and store the i f T T t app installed on your mobile device and, of course, opening up and log in. And in the next video, we're gonna test everything out and see how it works. 39. Testing our Custom IoT IFTTT Applet: So now it's time to test out our Web hook integration and test out our project. We did not make any cool changes from what we had originally set up as faras the called for our thing and the project and so on. The only thing we did, of course, was to create that Web hook. Andi. That integration would if this then that so our code remain the same. It's just the creation of that Web book on Now that Web hook is going to be triggered when I were circuit the text motion and it's going to make a call to our cell phone and we're going to hear that message that we set up so really cool, really exciting, and I'm just gonna go ahead and click on Add it code here, and this is going to land us. Of course, any weapon injure. And at this point in time, let us apply power toe our Arduino boards. I'm just gonna plug in the USB cable for the circuit, and once that's but been, our board should set up. That's give it a minute. It's actually going toe. Connect our WiFi network. As you see there. It was detected on our web editor, and I'm just going to click on the serial monitor here. So now let's go ahead and test this out. That me? I'm going to move my hand in front of the PR sensor. Of course, the led should light up when motion was detected. Will also see it on the serial monitor. That motion was detected on. Then my cell phone should ring and be You pick it up and this into the message that was recorded. So let's check it out. Here I go. I'm gonna move my hand there. The sensor went off. Motion was detected on. Here is my phone. That's except the core. Put it on speaker. Event call. Motion detected occurred on the maker Web service motion was detected at front board. There we go. So we heard it. We heard the core. Let me just leave the call here and, of course, call again because motion was detected again when it's just gonna go ahead and the plane and there we haven't. So it worked. We're able to see. As motion was detected, our Web hook was fired and that actually made a voice over I P call on its making another one because I just moved It made a voice over I p call to our if this, then that up on, we were able to hear that message that we set up on done by configuring front door, back door. We can put in custom query string parameters, and that's in that way. We can specify where our sensor is, which motion was detected and we could add. Customization is to our message, so really cool. Hope you enjoyed this hope. You can see the applications with regards to integrating Web hooks to your priority projects and in particular, the Arduino Maker board. And there are lots of possibilities. We just did this simple one. To make a call, you could send an EMU. You can hook up a camera to take an image. The possibilities are endless. So once you understand the basics of that Web hook integration, the sky's the limit. I'm really interested in seeing what cool, fun, exciting projects you guys come up with. Hope you like this 40. Project Overview - Measuring Temperature and Humidity: This is one of the coolest projects that we will be building in this course on. It is a fully fledged practical I ot application. We're going to tackle a temperature controlled, self regulating system that is controlled and monitored from the cloud. Essentially, our application will be able to set a desired temperature on our fun will automatically kick on and off toe. Cool the area surrounding our temperature sensor toe the desired temperature setting. I will also show how you can create a dashboard that not only allows you to set the desired temperature range, but also allows for Emmanuel Override enabling you to control the fund from a console. The dashboard will also contain real time This please that sure, the temperature of our sensor. We simply have to set the system on forget it itself regulates on its own. Around the we, we will learn how to control a fun electronically using a transistor as a switch. We will also learn how to create an I O T. Dashboard to fully control our fan and set a desire temperature range. The project will also show how we can implement a feedback group in the cloud that allows our sick it to self regulate the control temperature. All I will work culminates in this final project, and it's going to be a lot of fun. Everything we have learned will all come together. Let's get started. 41. Wiring the Circuit: No, it's time for us. The wire up our circuit. So first, let's create the ground, Really? Or maybe ground connection on our bread board, someone taking when I'll be connecting wires. And here, of course, the ground pin from our maker board. It's clearly highlighted here, and White will make that connection there. And we're gonna connect back to the ground really on our bread board because we're gonna have a couple of connections that are coming off of that. So let's first do that. Then let's wear a power the HD sensor and, of course, without DHT sensor. As you can see, there are three pins and it pin here. On the left is the positive pin or the visi seep. In the middle pin is a signal pin, and then deep in here on the right is ground or it's connected the ground. So I'm just gonna insert this sensor here in tow bread board and the first let's make the VCC connection. So that positive been here? I'm going to connect that here. As you can see, make sure it lines up in the same rule here, gonna make that connection here, and that we're going to connect to that to five folds on our meager board. So if we look here for the five old men, it is the pending here at the top. When I make sure that we like that in So that is in place. Next up the middle pin here on our DHT 22 sensor is Thesiger Nall pin and that is going to pin seven on our maker board. So just make that connection now and ensure that we get that middle pin lined up here and pin seven on Arduino board here is actually the second to last Been a Zaken see here in seven. So when I make sure that that lines up on it goes into the second to last socket here and it's been seven, and then, of course, finally depend here on the right had been on our sense of goes to ground. So I'm gonna make that connection Now I want to ensure that it lines up in a row with that pin Onda. Once we get that in weaken, just connect about two grown and again, this is all ground real going all the way across here at the top, and it will be grounded. So those any connections that we need for our sensor Next up, let us do the connections for our transistor. So here is our to end 39 or four transistor. And as you can see, what the transistor there is a flat surface here, Andi, When it's oriented with a flat surface facing you, of course I'm gonna turn it here. Here, the round sort of curved out there surface. And then here's a flat surface. Would be actual rating. Spring a little closer here with the actual writing on the transistor. Um, the left most pin here is going to be the emitter. The middle pin is going to be the base, and the right pen is going to be the collector. So I'm just going to insert this into the circuit and the make sure it's oriented that way with the flat side. As you can see, the curve, the site is on the outside, the flat side facing me or facing us agency. And that way we can know the orientation of dependence. So from our emitter, we have to make a ground connection. So the materials directly the ground, so I will make that connection now, So I just want to make sure they've been here and it left you line it up. We insert that where There to depend on the left. And we want to ensure that we grown that image or pin. So that is the ground for emitter. Next up the middle pin is the base spin and from the base, we actually have our one key res sister. So I'm gonna connect to that here to the base. That's when I ensure that we lying that up here in the middle. As you can see, I'm gonna connect back to another point here and bread board somewhere else on the bread board, I mean, and the other end of that base resistor goes to pin six on our maker board. So I will make that connection now. And here is that again we connect the other end about resistor along that same room, and we're going to go to pin six and then six on the maker board if return it here is actually the very last pin here on just below the pin seven. So we just want to make that connection here. That is the base for our transistor. I should see it's the end of the resistor that's connected to DB seven transistor and then from the collector, we go to the negative of our funds. So here is my CPU fund. Let me just quickly show it. And as you can see from their reading, it's a 12 volt DC fun, an iterated at 120.2 amps. So we're going to use as I mentioned to battery packs to get up to 12 volts. And if we look at the fun connections here, you'll see a series of wires. But what we're concerned with is theblaze choir and the red wire so they black would be the ground or negative wire, and the red wire is going to be our positive wire. So coming off of the collector here on our transistor, we're going to the negative or the black wire of our fun. So depending on whatever fun you have, just look out for the black and red wires, and that will give you an indication of the polarity. So I'm going to take a wire connected to the collector of or resistor. That's 1/3 pin. Make sure it is lined up. Connect that and and the other end of the wire goes into the black wire off our fun. So here, I mean that connection here. So the black wire is the outermost wire, and as you can see here on the left, that's where that connection went into out the most wire here on the left, the wire. Dustin. Right. Next it is the positive on that is actually going to go to the positive of our battery. But the phone connect our battery. Let me just show you here. These are two battery packs that we're using. On that they are for 1.5 bull batteries. And if you add up the 1.5, you'll get six folds per battery. And here is a six full butter proxy. Put them together in series and it's gonna be 12 volts. So let me show you. Actually, how are we going to do that? And if you look here in this particular body here, battery holder is pretty nifty. It has ah, sort of a female plug at the end on ditz. Once you put your batteries and your ableto come off of this female and meal again It's labeled Block I should see and a red wire. So if we're connecting batteries and Siri's remember, earthy negative of one battery has to go to the positive of the other. So I'm just going to make that connection Now, here, off the black wire, which is this end here Gonna push in. My connecting wire actually should go in a little more firmly. Right. So here is the end, and you should try to needing this up and actually put some tape so that this wire isn't exposed toe prevent shorts, but the black wire here it's connected to my connecting wire, and that has to go into the positive of the other battery pack. So here, that goes into the red wire. So if you look at the red wire, is this wiring inside? And I'm going to make that connection here to the inside. So that is on the insane. Let me just fix that. There you go. So that's the inside. And then, of course, the outer wire is going to be our negative wire. That's going to go the ground. So I will use another connecting wire here. Okay, so this goes to ground this one. Insure, push this in and on this side. Here we have it. Positive wear, which would go to the positive section for a second. So just a shoe that these two battery packs are connected in Siris. But shoes on multi meter. And that's strictly footage. So I've connected them here. Here, I have. Ah, generic multi meter, and I'm gonna turn it on on its own. Actually, these e Volz size. Put it on the 20 volts setting, which should be enough. Take the measurement. I was gonna put this here on and let us check the voltage of our battery. So I'm going to check this out here. Here is the negative. So I'm gonna put the terminal there and what the terminal to the other were. And if you look at our multi meter, it says 12.74 bolts. So we're right, right? About 12 bullets all over 12 volts. So, as you can see, we connected our battery packs in Siris. Andi, it looks like we're good. So once that is set up to move the multi meter here out of the me. And now if you go back toe a circuit remember, the positive of our fan has to be connected to the positive of our body repack. So let me just do that right now. Here is the positive of our body pack, and we go back to the fan connection. Remember, we had the negative connection and the bread is the positive. So I'm gonna make that connection now. So now a Nazi positive of our fund and the other end of our battery has to be grounded. So again, here is the ground, the connection on our circuit. I guess when I ensure that that's grounded and that is it. So here, just uneaten things up. We have our body re peck. It's connected to a circuit. We have our fun connected. We have our DHT 22 sensor. We have our transistor and everything is connected upto a maker board. So they very last thing, of course we have to do is use our USB cable and connected into our maker board and the other, and it is going to go into our computer. So I knew that was quite a lot of wiring there, but hopefully you're able to follow alone with me and with the circuit diagram, please double check all your connections double and triple check. And of course, make sure that your Arduino maker borders powered off. There's no power supply tit as you are things up and when you have everything ready, will proceed to make all the co changes that we need, and then we will upload those cool changes to our circuit to test out our project. 42. Configuration in the IoT Cloud: Okay, you welcome back, everybody. And now we're going to set up the thing for our temperature control project. And we also have to set up a couple of properties that are associated with our thing that will use the monitor and control our circuit. So head over to create that Arduino dot cc and your chrome web browser and gonna click on Arduino Piety Cloud. So from here, if you have a project that was already created, you have to delete it on. This is in the beat aversion I'm working in. So let's go ahead and delete it, since it only allows one thing at a time. So I'm gonna just delete this existent thing, and we're are going to create a new thing. So click on the new thing button. We're going to give our thing a name, so I'm going to call it i o t Dash Cloud Ash temp Dash control Bash thing again. You could name it anything that you want, but this is the name all use for our project. So of course it's the maker WiFi 10 10 board on. Just leave that selected by default and we click on create so As you have noticed, this interface looks a little different from some of the projects at the beginning of the course and match because, as I mentioned, the Coyote Cloud is still in. Beta on day are making updates. So this is the latest version of the interface on Glad, actually a change in us, so I can get to show you that the functionality is similar. It's just that things have been moved around a little bit. So from this Properties tab, we can click on Add property, and we need to add a couple of properties that we will be referring to include as well as interacting with from the dashboard. So the 1st 1 is max temperature, and this is a property that we will use to set or control the maximum temperature range for our system. So the name over this marks on the score temp, and we can select from the property type. It's afloat since we'll be measuring temperature, the range will be using here is minus 15 to 80 degrees, and that's simply the Celsius range for our DHD 22 center. We want this to be a read on right permission because We want to actually set this temperature from the screen or from the cloud itself. And that will be the max temperature that would be allowed for our circuit onda the rest of the other properties. We can simply leave them as the fault, and we can click on at property. So once that's added, we have to add another property. So I'm going to click on that property again. And the name of this one is override Underscore fan control. And we will be using this property when we want to take control of our fans so our system is going to be self regulating. But if for any reason we want to take control of our fun and turn it on and off, regardless of what the temperature is, we'll be able to do that in our project, so the type is going to be on off bullion on. The permission is going to be read and write, so boots are only settings that we'll need for this particular property, and we can click on add property. The next property we need to create is fun on, so go ahead and click on add property again and the name of this is fun underscore on. And this here for the property type is going to be a boolean value, and it's going to be read and write. So essentially, this is what we're going to use to manually control, are fun and actually tune it on and off when we enable the override. Or this property is going to be set based on the current state of our system and whether our fun is currently owner off. So had serves a dual purpose. So that's a fun on property on Go ahead and click on that property Onda Last but not least , we need to add a temperature property, so I'm going to click on that property. And in the name of this, of course, is going to be temperature. And this simply reflects the current temperature of our circuit. So the DHD sensor is going to take a temperature reading. We're going to figure out what that is in code, and we're going to set this on a screen off our dashboard. So it's actually just going to be read on me. We're not going to be changing it, Onda. The type is going to be a float on seeing that it's a temperature value or should see the temperatures Sensor has a range of minus 40 degrees on it was all the way up to 80 degrees on. Of course, this is in Celsius. So three other thing that we want to do is when the value changes. We wanted one update and let's do every half of a degree. So 0.5, we're gonna change that to 0.5, and that will be the temperature property that we need for our project. So go ahead and click on that property. Andi, this would complete the properties that we need that we actually are going to interact with in code and as well as on the Coyote Cloud dashboard when we work with our project. 43. Making Code Changes: Welcome back, everybody. And now it's time for us to dive in to some code and make the cool changes that are necessary for project toe work and for everything to come together. So here we're at the Coyote Cloud page and we have created four properties on and these properties we're going to refer to them in the cud. Onder, just a quickly recap we have our fun on which would be responsible for or I should see this is where we would tune are found on and off the marks temperature setting. We also have the override fun control when we want to take control of our circuit and then we have a temperature setting, which is just a read only value. In fact, it's the only read only property which reflects or updates with the true value of the temperature of our I T system. So those are the properties, and I'm just gonna click on the dashboard here, and these are how they are going to show up. And when we actually write our code and we're testing out our sick, it will come back to the dashboard so you can see all of these in action. So no, let's go ahead and write some code. And to do that at the top there is a button, that school edit sketch so you can go ahead and click on that button. And that should banned us in the Arduino Web editor. So let's click on that button now. So I'm just gonna maximize this window here a little bit so we can see our cool a little easier. So again, our first step as we come in here should be to click on a secret tub. And here we're going to enter the SS I. D and the password for our wireless network. So let's proceed to do that now, in order for our maker board to connect to our WiFi network. So when I enter the SS, I d hear of my network and the password. And once you have entered those values for your wife or a network, we can click on the mean tab here for our project. So once we're back here, the first thing that we need to do is we need to include the DHD Library, third party library, so we're able to use some of the convenience functions in there for our temperature sensor . So if we click on the library's tab, that should load up the library manager for us, and I'm going to click on the custom tub. And here I'm going to search for just teach T so you can type in DHT and hit Enter. And here we see the DHD Sensor Library. We want to go ahead and click on the include button, so that should include the DHT library at the top of our program here for us. So once that's done, let's cool down of it. And we have to declare a few constants here in our program. So right under thing properties that each where we include our thing properties that each file let's set up some constants. So the 1st 1 is we're going to define our DHD pen, and that is going to be pin seven. If you remember that was connected from the temperature sensor, the hope up in tow, our Meeker board. Then we're going to define the DHD type on. That's going to be DHT 22. This is what we will be using to a foot of which vision of the library or I should see which specific censor the DHD 22 a. D h d 11 were using. We're using the DHD 22 from this library, so we have to define a variable there that we will use. Then Stan sheet the DHD object and then next we can define our DHT object, and it's going to be the HD. We're gonna call it DHT. You can name it anything you want. But since it's the DHT library, we're just gonna use Boquillas tht and it's going toe granita pass and the d h depend that we're using, which was seven above on the DHD type. So this would clear our DHT variable or I should say, are in san she ate r GHT object on. This is what we will be using to take our temperature readings. Couple of the variables you wanna set up is define our fun six. And the positive pin of our fine is connected to pin six on our maker board. And the last variable we wanted to find is a default marks temperature. So let's see, e temperature was not set or a maximum temperature was not set from our i o T cloud interface that which it had no value. We want to ensure that we just have a default temperature that our program will use on and that we wanted variable changes or a set. Then it's picked up. So we just want to account for a null value or nothing mean the and let's set our default max temperature to 30 degrees. So once those of variables are defined, that's cruel down here in our program. And we need to add some additional cool right after the printed a bargain for here to initialize our objects and so on and to get things ready for execution. So the first thing that we do is we do a DHT, not begin, and that's going to just initialize our teach the object and make it ready to take readings . And we're gonna set up a pill mood for our fun pin as output. So we're seeing that are fun. Pain is going to be used as an output and will be sending no one high signals of that. And that, actually is what will go to the peace of our transistor to turn our fun on and off. Initially, we also want to turn our fun off so we can do a digital freight to our fan, and we could write a little signal to it on. Essentially, this initially tunes off our fund on here. We check if mocks temp is equal to no meaning that property was not sent. We want to set max temp until it afford max temp, which is that value at the top of our program. So just switching over here quickly to think properties that each remember Max temp was that property that we have, where we specify the maximum temperature. It we have a reference to that variable here from all thing properties that each and here were initially checking. If that value is MT. Or there wasn't anything in there, we're going to set it to the default max temperature, which would be 30 degrees. So that's the end of the set up that we need to do in our set up function after initializing variables and our fan pin and certainly max temperature and now we get into the loop function where all the magic happens for our self regulating system. As I mentioned, though, to make things easier before we get into loop there are a couple of convenience functions that we're going to write, and I covered that in the previous lecture when we discussed some of those functions and logic that would be in there. But before we start writing that, I just wanted to highlight those callback functions that go created for us. So on Max Temp change again. Once we tuggle the widget from the IRA T Cloud, a signal is going to be sent from our make aboard over the Internet I D Cloud and whatever court is in here is going to be executed as well as the override fan control and the fan on double switch. So a bully and I should see. So once those values that changed, these quote back functions are going to be executed. So the first function that we want to right here is the regulate temperature. So we're going to do avoid regulate temperature. So if the temperature is greater than Marx, underscored temperature marks on the score attempt. If that's the keys, then we are going to turn our fund owns Will do A did still right our fund pin, and we're gonna right toe high. And of course, that's going toe Turn on our fun, Els We're gonna turn off our friend and the turn off our fun We do a digital right there are fun on that's going to be little. So in addition to turn any values on and off, we also want to set the fun on a 1,000,000,000 flags and fun One is going to be equal to truth. Onda here since we turned off our fun fun off is equal to truth And these are I should see the funnel on fun on here Sorry is equal the false So they found on property itself is what we are, what will be visible in the I T cloud interface. And of course, if we turn our fun on, we want him Make sure that the value of that property reflects the current state of our fan . So we're also gonna turn that flag true. And then if it's of course, you turn the fan off. We wanted to in that flag off, so it's gonna be false. So that's the regulate temperature convenience function. The other function we talked about was turn fun on or off, and this simply will check if that fun on flag is set to true on again. Remember, this is a value from our I ity cloud We want to turn our fun on so we do a digital right and to our fun taking it on health We turn off our funds who do a digital right to our fun and we turn it off. So those already only two conditions that we need to execute here and it turned fun on or function the last bit off, I should say, the last major function or convenience function that we want to create a update system so we can again have avoid upbeat system here. It doesn't take any arguments or parameters. So if override fun control, basically if that which it was set to true from the mean dashboard, then that means that we need to manually control are fun. So if that override fun control is set, we can call our tune fun fallen off function here, And that's going to be this guy, and it's going to check to see if the fine is on about. We have to inspect the current state of that fun on property. And if it set the own we gotta turn off and on. Otherwise, turn it off. So that's once that override flag is set, we need to inspect that variable. Otherwise, if it's not sent, we simply want to regulate the temperature. So our system is going toe up your operate like normal, and it's going to. Of course, if the current temperatures greeted any max temp is going to kick on. Our fun changed the state of our circuit to reflect that I should say, changes state of the property on the interface to reflect that. And if the temperature is less stunning max temperature meaning our system has cooled down enough, we're gonna turn off our fan and tune off the indicator as well. So those are the convenience functions. So the other cool changes that we need to make here for our callback functions. So if the maximum chip temperature was changed at any time in here, we want to call regulate temperature so immediately. If we let see, it was set to 25 degrees and we change it to 28 we immediately want to check. Hey, is this was the temperature. I was changed to a greater or the current temperature greater than it marks temperature. I was changed to and are sick. It would react accordingly. So that's going to be called here on Mac stem change. The other cool change that we need to make for the override. So once the override A is changed, I want to call update system Onda. Of course, what would happen here is if we tackle that Boolean flag to take manual control of our circuit up the IT system with just determine exactly what needs to be done. So if manual control is on true, then we check the state of that fun on toggle switch and then we we treat it accordingly and then finally, for on fund change here, we also do update system. So similarly, if we tackle that fun on bullion, we're only going to control our fun if and only if override is controlled or should see override is enabled otherwise, if it's not enable, we have to ignore it and just do regulate temperature. So hopefully you see how these, you know, by writing these three here, convenience functions were ableto referred to them in our callback. So once that those functions are written in our loop function and becomes very simple here . So the first thing is in a loop function. We want to read the temperature data. So in order to do that, we simply do a temperature. And that is the property from again our i o t. Which it screen or from the i o T Cloud we set that temperature value is equal to DHT. That read temperature on our library will take care of getting that reading from all the HD 22 sensor. And here we can do a serial. We want a print out to the serial monitor, the temperature and specifically what the value is on here. We can do a serial that print out that temperature value, and we also want to indicate that it iss Celsius circular cereal, that print print line, give us peace and put Celsius, and that's gonna print out the current temperature. So once that is done, really the only function we need to call in here as update system, so that's gonna take care of everything else. No other cool or logic is needed in here, and then we can put in a dally off of five seconds or so so the temperature reading would be taken every five seconds and just a comment here about updated system. Basically, we're going here to control the fund or regulate temperature based on user input setting. So you can see by writing that one up the IT system function. It takes care of everything here and are looked for us. We don't have to duel this logic and checking on in this way by writing our code in this way. It's very I should see. It's very neat. It's also there is separation of concerns because each of these functions handles something specifically. And of course, there's a lot of re use of those functions and that were referred to the seem logic and our callbacks. And it's just a clean, neat way to write our code and a reusable we that it's easy to understand, and also we have a maximum reuse, very efficient. We have writing our code, so that's it that completes the code changes that we need to make Andi in next lesson. We're going to test everything out. So, uh, pretty soon we're going to see if all the wiring of our circuit and all the court changes everything was able to come together and let's see our project in action 44. Testing it Out: So now we're gonna test out our project and I'm gonna connect the aren't we know board to my computer. So once the board is connected, as you can see, it was detected. And the first let's go ahead and compile on upload our co two the board So we can click on the check mark here that's gonna compile and verifier code. That's that. This room to see if we had any errors, success, compile, elation or successful. And now let's proceed to upload Onda, save the cool toe aboard to click on the right arrow. Then we'll give this a few seconds to run. Okay, so it we got the success message. It was successfully uploaded to our board. Let's go ahead and click on the serial monitor here. Onda, as you can see there ago, so we see the connected status on. We also see the first humidity and temperature reading being displayed. Now you'll notice if we remember in our code we had a Delia five seconds, so really, every five seconds we're going to spit out, or I should see the split pea temperature and humidity values and one small tweak that we could make to make this show up a little better. Weaken do here after we do a serial that print Celsius weaken simply do, ah, cereal, that print flying and let's go ahead and upload that change and that will just simply meek each reading, come out on a new lying. So let's upload that we can also have then serial the print mine Celsius here. So now we see the humidity and the temperature being printed on separate lying. So that's kind of what we wanted just to be able to clearly see that. So once that's done, let's go ahead and open up the crowd console the goto I ot cloud. I'm just gonna open this any new window that we were able to sort of see it by side by side on. Once that loads up, we can click here on the widgets icon on here, our values. So here we can see the humidity. Right now, it's about 50.6% on the temperatures, about 24.8 Celsius. Now let's look at a change and let's see how, when the values change, how they are reflected on the I T cloud as well as any council. So it a similarly this change. What I'm going to do is I have a sword and Ryan has in a village that can get really hot. And I'm going to bring this order and iron close to the actual sensor. Onda Ben, We'll actually see the values change. So here ago, when I bring the sword and iron, and as you can see, I'm just gonna move it close to the sensor. Remember, the readings take place every five seconds on, and it should be pretty hot. So, as you can see, there goes. The humidity changed. The temperature was 24.8. I notice any consulate went up to 25. I'm just gonna bring it a little closer. 24.8 25.5. And remember, we said the temperature on the council, the change when? As adults off 0.5 degrees. So it's getting hard term. That's gonna move it pretty close here. And as you can see, it's going up. So the temperature change from 25.5 26. Humanities at 50.2 and it's continuing to go up. It's getting harder. 26.6, as you can see in our console. It's now 27 but again, Delta isn't big enough. When she does this speaking up them and jumps to 27.2, so various see it it's working on. It's taking those Delta changes into effect and only updating the Cloud Council when the Deltas are greater than 0.5 for temperature and 1% for humanity. So, of course, the humidity values dropping as temperatures increasing because the ear around the sensor is getting this. There's less water vapor as it's getting hotter. So that's why humanity is dropping. All right, so now let me move the Southern iron. I'm gonna put it back and let's just give it a second or so when we will see. Actually, temperatures start to drop again. So right now it's at 27.7, and, as you can see in the serial, monitored went to 27.6. But since it's not at what Delta 0.5 Hour Cloud Council is still going to say 27.7 and it's dropping some more 27.3 and we're getting pretty close once it gets to 27.2, we should see the cloud Consul should change, and there we go. All right, so because it was adult off 0.5, a change. So a circuit is working. Our cloud council is working. Were it was the view our properties on. And that's how you use a D. H d 22 center. That's how you take measurements and you configure it in the art we know rt cloud. 45. Project Overview - Temperature-Controlled Self Regulation IoT: This is one of the coolest projects that we will be building in this course on. It is a fully fledged practical I ot application. We're going to tackle a temperature controlled, self regulating system that is controlled and monitored from the cloud. Essentially, our application will be able to set a desired temperature on our fun will automatically kick on and off toe. Cool the area surrounding our temperature sensor toe the desired temperature setting. I will also show how you can create a dashboard that not only allows you to set the desired temperature range, but also allows for Emmanuel Override enabling you to control the fund from a console. The dashboard will also contain real time This please that sure, the temperature of our sensor. We simply have to set the system on forget it itself regulates on its own. Around the we, we will learn how to control a fun electronically using a transistor as a switch. We will also learn how to create an I O T. Dashboard to fully control our fan and set a desire temperature range. The project will also show how we can implement a feedback group in the cloud that allows our sick it to self regulate the control temperature. All I will work culminates in this final project, and it's going to be a lot of fun. Everything we have learned will all come together. Let's get started. 46. Using a Transistor as a Switch to Control our Fan: before we start looking at the components that we're going to need for a circuit as well as thesis circuit diagram, I wanted to go over a concept around how we will be controlling our fun Elektronik Lee, and we'll actually be using a transistor as a switch to be ableto programmatically turn our fun on and off. So I'm just gonna go through that process to describe how that piece of the circuit is gonna be set up so that you understand the Elektronik principles that are involved with the design of the circuit. So first we have, of course, I will make her board and we will be connecting to pin seven on our meager board that's actually gonna be connected to a one key resistor, and that's going to go into the peace of our transistor. So a transistor, This is a collector. This is going to be the emitter. And of course, this here is goingto be connected to ground and that we are going to connect the collective or transistor is going to be connected to our funds. I'm just gonna put the motor here, and this, of course, here is the negative terminal of the motor and the positive terminal of the motor on the top here is going to be connected to our D c voltage. So we actually gonna be using 12 volts and we're using to battery packs in connecting them in Siris. So here, I'm just gonna Do you know what? This here is going to be one ratchet back and I know Onda, and of course, that's going to be connected back to ground. So essentially batters are circuit. So again, this is our transistor. This is the beast of our transistor. Here, this is the collector. And here is the emitter that's connected the ground. And again, we're using an NPM transistor in this circuit. And actually, the transistor we're going to use is a two n 15 9 or four transistor. That should be sufficient. Obese resistor here is going to be a one killer whom resistor on. Of course, this here is Ah, it is connected to pin seven on our maker board and that is going to be actually controlling our transistor. So and we just make a notation here at the top again. These are this is our 12 wolves here, and it's it's D C voltage. So here is a positive negative positive. And then here's in negative. Let's stop through what happens when the circuit turns on. So initially, when no current is flowing from our maker board from been seven, this transistor here will be turned off. So when it's off, no current can flow from our d c voltage into our fund down to ground. So our fund will be essentially off. However, when we send ah, high signal here, return this pen on for high 3.3. Wolves is going to come out from our pin seven atomic aboard, and that's going to flew into the beast transistor here of our sick it. So once that flows into here is gonna to our transistor on. And, of course, when that happens, when he transistors to an on current is going to start from the positive here of our d c voltage and it's going to start flowing down here into our motor. All right, come out here of all motor is going to flow down through the collector and two grown. And of course, it's gonna come back up here, back up to the negative. So essentially, what's going to happen as current is going to be flowing through this circuit in this direction because our transistors to unknown And of course, as current is flowing, it's gonna turn our motor on and it's gonna turn our final. So that is how we're able to get current flowing through a fund. Once we apply a high voltage here to the spin, it's gonna turn on a transistor and allow current to flow through our motor to grow So off course, once a low voltage comes, here's And once we turned this from high to low, this transistor is gonna shut off. There's no it's not going to be turned on and no current will be with the flu and our fan will shut off. So that is a little bit of background, essentially own how we are using a transistor on here. This is our transistor in our circuit. How we're gonna use it as a switch to turn on our motor. So hopefully as we go through setting up our circuit and reviewing the overall sickened diagram, this will make a little more sense. So I just wanted to give you guys this background on how we're going to be using he transistor as a switch in our circuit 47. Parts Needed for the Project: Okay, so let's take a look at the parts that we're going to need for our project. So, first, of course, we're going to need on Arduino maker WiFi 10 10 and here I have it connected to bread board because we need a bread board to me. Call or connections, Ben. Also, we have a d h d 22 temperature humidity sensor. We also have, ah to end pretty 904 transistor connecting wires. I also have here of CPU fun, and this fun here is redid a 12 volt, a one key resistor. We're going to need this for the beasts of our transistor. Andi, I have here a two pack of for 1.5 both batteries and this one of these would be equal to six folds. So we're going to connect two of them together. And that's how we're going to get 12 goals for fun. If you have ah, power supply as well, you can connect back to your fan, but we're going to be using since we want to make a Project mobile, we're gonna use the's battery packs and we'll connect them in Siris so that we'll get around 12 volts and we'll verify that voltage with a vote meter. So those are all the parts that we're going to need. And of course, finally, a USB cable on this is going to connect here into our Meeker board, and the other end is gonna connect to our computer, so that's everything we'll need for our project. 48. Reviewing the Circuit Diagram: Let's take a moment to review our circuit diagram before we start wiring up our circuit. This is probably the most complex circuit for the course, so there's quite a few connections here. It's not that bad, but I just wanted to go through it so that she will have an understanding of how things are wired together. So first, let's start that they left here on the Meeker board. We're connecting the ground, the pin from our maker board to the grown riel. And the reason we're doing that is we have to make a couple of connections off of that same ground. So we first established that connection to the ground riel Ben for our DHT 20 to censor, the VCC pin is connected to five volts. The output pin or the signal or data pin is connected to pin seven here on the maker board . If there'd been, there is no connection or it's not connected to anything, and the fourth Ben is actually connected to ground. So here we connect that back to the ground, real. So that's all the worrying for the DHT 22 sensor. And now let's take a look at our transistor So this is the MP in transistor. On on this DAG round the left been is the emitter. The middle pin is the base and the right pendency collector. So the emitter is connected directly to ground here on a circuit Onda for the center print for the bees from pin six. Here on a maker board, we connect to the won t resistor and the other end of that resistor goes to the beast of our transistor. The dip in, which is a collector of the transistor, is actually connected to the negative pin off our fun and let's see negative fin of the motor on our fund. And of course, here is our fun. And the positive pin of the fun is connected to the positive pin of hors d C po supply. So this is our possibly we're actually using two banks of batteries, and each battery bank has 41.5 bull batteries. So that's six holds. And when we connect them in Siris, we're going to get 12 volts. So they found that we're using the CPU found that has 12 volts. So I should say it's powered. Has a reading of 12 volts So that's where we're using to battery packs and really connect them and Siri's and I'll show you how we do that. The last connection, of course, is from the battery pack. So this positive fan pin is connected to the positive of the battery pack, and the negative of the battery pack goes to ground. So those are only connections for the circuit. It's a little more than we've done before, but not too bad. It's monitor herbal circuit and let's see how we wire the circuit up. 49. Wiring the Circuit: No, it's time for us. The wire up our circuit. So first, let's create the ground, Really? Or maybe ground connection on our bread board, someone taking when I'll be connecting wires. And here, of course, the ground pin from our maker board. It's clearly highlighted here, and White will make that connection there. And we're gonna connect back to the ground really on our bread board because we're gonna have a couple of connections that are coming off of that. So let's first do that. Then let's wear a power the HD sensor and, of course, without DHT sensor. As you can see, there are three pins and it pin here. On the left is the positive pin or the visi seep. In the middle pin is a signal pin, and then deep in here on the right is ground or it's connected the ground. So I'm just gonna insert this sensor here in tow bread board and the first let's make the VCC connection. So that positive been here? I'm going to connect that here. As you can see, make sure it lines up in the same rule here, gonna make that connection here, and that we're going to connect to that to five folds on our meager board. So if we look here for the five old men, it is the pending here at the top. When I make sure that we like that in So that is in place. Next up the middle pin here on our DHT 22 sensor is Thesiger Nall pin and that is going to pin seven on our maker board. So just make that connection now and ensure that we get that middle pin lined up here and pin seven on Arduino board here is actually the second to last Been a Zaken see here in seven. So when I make sure that that lines up on it goes into the second to last socket here and it's been seven, and then, of course, finally depend here on the right had been on our sense of goes to ground. So I'm gonna make that connection Now I want to ensure that it lines up in a row with that pin Onda. Once we get that in weaken, just connect about two grown and again, this is all ground real going all the way across here at the top, and it will be grounded. So those any connections that we need for our sensor Next up, let us do the connections for our transistor. So here is our to end 39 or four transistor. And as you can see, what the transistor there is a flat surface here, Andi, When it's oriented with a flat surface facing you, of course I'm gonna turn it here. Here, the round sort of curved out there surface. And then here's a flat surface. Would be actual rating. Spring a little closer here with the actual writing on the transistor. Um, the left most pin here is going to be the emitter. The middle pin is going to be the base, and the right pen is going to be the collector. So I'm just going to insert this into the circuit and the make sure it's oriented that way with the flat side. As you can see, the curve, the site is on the outside, the flat side facing me or facing us agency. And that way we can know the orientation of dependence. So from our emitter, we have to make a ground connection. So the materials directly the ground, so I will make that connection now, So I just want to make sure they've been here and it left you line it up. We insert that where There to depend on the left. And we want to ensure that we grown that image or pin. So that is the ground for emitter. Next up the middle pin is the base spin and from the base, we actually have our one key res sister. So I'm gonna connect to that here to the base. That's when I ensure that we lying that up here in the middle. As you can see, I'm gonna connect back to another point here and bread board somewhere else on the bread board, I mean, and the other end of that base resistor goes to pin six on our maker board. So I will make that connection now. And here is that again we connect the other end about resistor along that same room, and we're going to go to pin six and then six on the maker board if return it here is actually the very last pin here on just below the pin seven. So we just want to make that connection here. That is the base for our transistor. I should see it's the end of the resistor that's connected to DB seven transistor and then from the collector, we go to the negative of our funds. So here is my CPU fund. Let me just quickly show it. And as you can see from their reading, it's a 12 volt DC fun, an iterated at 120.2 amps. So we're going to use as I mentioned to battery packs to get up to 12 volts. And if we look at the fun connections here, you'll see a series of wires. But what we're concerned with is theblaze choir and the red wire so they black would be the ground or negative wire, and the red wire is going to be our positive wire. So coming off of the collector here on our transistor, we're going to the negative or the black wire of our fun. So depending on whatever fun you have, just look out for the black and red wires, and that will give you an indication of the polarity. So I'm going to take a wire connected to the collector of or resistor. That's 1/3 pin. Make sure it is lined up. Connect that and and the other end of the wire goes into the black wire off our fun. So here, I mean that connection here. So the black wire is the outermost wire, and as you can see here on the left, that's where that connection went into out the most wire here on the left, the wire. Dustin. Right. Next it is the positive on that is actually going to go to the positive of our battery. But the phone connect our battery. Let me just show you here. These are two battery packs that we're using. On that they are for 1.5 bull batteries. And if you add up the 1.5, you'll get six folds per battery. And here is a six full butter proxy. Put them together in series and it's gonna be 12 volts. So let me show you. Actually, how are we going to do that? And if you look here in this particular body here, battery holder is pretty nifty. It has ah, sort of a female plug at the end on ditz. Once you put your batteries and your ableto come off of this female and meal again It's labeled Block I should see and a red wire. So if we're connecting batteries and Siri's remember, earthy negative of one battery has to go to the positive of the other. So I'm just going to make that connection Now, here, off the black wire, which is this end here Gonna push in. My connecting wire actually should go in a little more firmly. Right. So here is the end, and you should try to needing this up and actually put some tape so that this wire isn't exposed toe prevent shorts, but the black wire here it's connected to my connecting wire, and that has to go into the positive of the other battery pack. So here, that goes into the red wire. So if you look at the red wire, is this wiring inside? And I'm going to make that connection here to the inside. So that is on the insane. Let me just fix that. There you go. So that's the inside. And then, of course, the outer wire is going to be our negative wire. That's going to go the ground. So I will use another connecting wire here. Okay, so this goes to ground this one. Insure, push this in and on this side. Here we have it. Positive wear, which would go to the positive section for a second. So just a shoe that these two battery packs are connected in Siris. But shoes on multi meter. And that's strictly footage. So I've connected them here. Here, I have. Ah, generic multi meter, and I'm gonna turn it on on its own. Actually, these e Volz size. Put it on the 20 volts setting, which should be enough. Take the measurement. I was gonna put this here on and let us check the voltage of our battery. So I'm going to check this out here. Here is the negative. So I'm gonna put the terminal there and what the terminal to the other were. And if you look at our multi meter, it says 12.74 bolts. So we're right, right? About 12 bullets all over 12 volts. So, as you can see, we connected our battery packs in Siris. Andi, it looks like we're good. So once that is set up to move the multi meter here out of the me. And now if you go back toe a circuit remember, the positive of our fan has to be connected to the positive of our body repack. So let me just do that right now. Here is the positive of our body pack, and we go back to the fan connection. Remember, we had the negative connection and the bread is the positive. So I'm gonna make that connection now. So now a Nazi positive of our fund and the other end of our battery has to be grounded. So again, here is the ground, the connection on our circuit. I guess when I ensure that that's grounded and that is it. So here, just uneaten things up. We have our body re peck. It's connected to a circuit. We have our fun connected. We have our DHT 22 sensor. We have our transistor and everything is connected upto a maker board. So they very last thing, of course we have to do is use our USB cable and connected into our maker board and the other, and it is going to go into our computer. So I knew that was quite a lot of wiring there, but hopefully you're able to follow alone with me and with the circuit diagram, please double check all your connections double and triple check. And of course, make sure that your Arduino maker borders powered off. There's no power supply tit as you are things up and when you have everything ready, will proceed to make all the co changes that we need, and then we will upload those cool changes to our circuit to test out our project. 50. Configuration in the IoT Cloud: Okay, you welcome back, everybody. And now we're going to set up the thing for our temperature control project. And we also have to set up a couple of properties that are associated with our thing that will use the monitor and control our circuit. So head over to create that Arduino dot cc and your chrome web browser and gonna click on Arduino Piety Cloud. So from here, if you have a project that was already created, you have to delete it on. This is in the beat aversion I'm working in. So let's go ahead and delete it, since it only allows one thing at a time. So I'm gonna just delete this existent thing, and we're are going to create a new thing. So click on the new thing button. We're going to give our thing a name, so I'm going to call it i o t Dash Cloud Ash temp Dash control Bash thing again. You could name it anything that you want, but this is the name all use for our project. So of course it's the maker WiFi 10 10 board on. Just leave that selected by default and we click on create so As you have noticed, this interface looks a little different from some of the projects at the beginning of the course and match because, as I mentioned, the Coyote Cloud is still in. Beta on day are making updates. So this is the latest version of the interface on Glad, actually a change in us, so I can get to show you that the functionality is similar. It's just that things have been moved around a little bit. So from this Properties tab, we can click on Add property, and we need to add a couple of properties that we will be referring to include as well as interacting with from the dashboard. So the 1st 1 is max temperature, and this is a property that we will use to set or control the maximum temperature range for our system. So the name over this marks on the score temp, and we can select from the property type. It's afloat since we'll be measuring temperature, the range will be using here is minus 15 to 80 degrees, and that's simply the Celsius range for our DHD 22 center. We want this to be a read on right permission because We want to actually set this temperature from the screen or from the cloud itself. And that will be the max temperature that would be allowed for our circuit onda the rest of the other properties. We can simply leave them as the fault, and we can click on at property. So once that's added, we have to add another property. So I'm going to click on that property again. And the name of this one is override Underscore fan control. And we will be using this property when we want to take control of our fans so our system is going to be self regulating. But if for any reason we want to take control of our fun and turn it on and off, regardless of what the temperature is, we'll be able to do that in our project, so the type is going to be on off bullion on. The permission is going to be read and write, so boots are only settings that we'll need for this particular property, and we can click on add property. The next property we need to create is fun on, so go ahead and click on add property again and the name of this is fun underscore on. And this here for the property type is going to be a boolean value, and it's going to be read and write. So essentially, this is what we're going to use to manually control, are fun and actually tune it on and off when we enable the override. Or this property is going to be set based on the current state of our system and whether our fun is currently owner off. So had serves a dual purpose. So that's a fun on property on Go ahead and click on that property Onda Last but not least , we need to add a temperature property, so I'm going to click on that property. And in the name of this, of course, is going to be temperature. And this simply reflects the current temperature of our circuit. So the DHD sensor is going to take a temperature reading. We're going to figure out what that is in code, and we're going to set this on a screen off our dashboard. So it's actually just going to be read on me. We're not going to be changing it, Onda. The type is going to be a float on seeing that it's a temperature value or should see the temperatures Sensor has a range of minus 40 degrees on it was all the way up to 80 degrees on. Of course, this is in Celsius. So three other thing that we want to do is when the value changes. We wanted one update and let's do every half of a degree. So 0.5, we're gonna change that to 0.5, and that will be the temperature property that we need for our project. So go ahead and click on that property. Andi, this would complete the properties that we need that we actually are going to interact with in code and as well as on the Coyote Cloud dashboard when we work with our project. 51. Reviewing the Dashboard that will be created for the project: before we get started, making the cool changes will need for a project, since this is probably when it be more complex projects quoting wise that we're working on , I just wanted to take some time to go through the logic and the algorithms that will be using as part of the code. That way you'll have an understanding when we do write the code, how it's structured and some of the assumptions that are made. So the purpose of this lesson is just to give an overview of how it going to tackle the problem and how we're going to logically interact with the widgets and how, when changes are made on the widgets, those changes interact with the actual code that's running on our Arduino maker board. So first, let's talk about the actual dashboard that we will be creating for our project. So essentially we're goingto have three properties. So the first property that we're going tohave is the maximum temperature, so this property would allow us to set the value of the maximum temperature of our system, and it's going to be a floating point number. But essentially, if see, we set this to 30 degrees or 25 degrees. That would be the marks temp of our system. Andi, if the system would go above that temperature, the fan is going to kick on toe, actually cool down the system. And once the system goes below the max temperature, the fun automatically shuts off. So that's the first property that will have on our widget screen. The next would be override fun control on what this essentially is is it's going to be a true or false sort of tuggle switch. And here we're gonna have either being true or false a Boolean value, and this would allow us. Let's see, for instance, we want to manually take control of our fun and turn it on and off. We simply can tackle this one to true and were able to set to no fun on and off. And this overrides anything from a temperature perspective. So it doesn't matter at this point what the temperature of our system is. We are able to take control of our fun and control it at any time. So the food property that goes hand in hand, actually with you over it, fun control is fun on, So this is what will actually control the fund. So again, this is going to be here. A toggle switch or Boolean, true or false and this value one set with the Tumen what the fund is. So let's look at how this is going to operate practically. Let's see, we set the temperature, the maximum temperature of our system to be 26 degrees if overwrite. Fun control and it's the fourth state is going to be set the fall. So let's see that this is struggled. What this means is that our system is going to measure the temperature off the surrounding environment on, Of course, the DHT 22 center is going to do this. Once the temperature goes above 26 degrees, are fine, kicks on and cools down the system and wants to temperature falls below 26 degrees defined shuts off. So that is sort of normal operation of the circuit. And in that case, the override fund control. Once we check or once the system checks for it is at false, so that means that normal operation is occurring. However, if we would tuggle this and we would have put this value here to true So let's say from ah , widget dashboard, we set this the true. What this means is now the code or our logic is going to check the value of this fun on property. So fun on is true. That means that we have taken control, were see that were overriding the fund control. And once this is true off, fun will kick on. So this allows us at any point in time if we want to manually take control of our system, which has struggled this override the truth and we can set our fun on the true and are fun kicks on. Otherwise, if we tackle this guy and we move him from true toe Falls were able at any point in time, the shut off our fund so manually take control and shut off our fun regardless of the temperature. If it's below 26/26 weekend, turn our fun on and off at any time. So from a properties perspective, that's essentially how our properties are going to be configured in the I o t cloud and they're going toe work. These three properties, we're going to use these to control our entire system. There was one of a property that I forgot to mention that we actually will be needing for our project. And of course it's going to be the four property, actually, and it's going to be temperature so the temperature is going toe. Reflect the meters temperature. Why should see the most current temperature of our sensor, and that's going to be, ah, floating point field. And it's going to be as opposed to these being read and write this temperature. Few is going to be read only and really, it's just going to be used toe reflect the current state of our system and the current reading off from our DHD sensor. So this would be the fourth property that we need to create. So I just I forgot to mention that, and I wanted Teoh ensure that we were aware of these four properties 52. Reviewing the Algorithm that we will use for our Project Code: not over reviewed what the dashboard is going to look like and what the widgets and properties we're going to set up in the are, you know, 80 club. Let's dive into the logic around our coat, and some of the algorithms will be using for our code. So we're going toe, have three mean functions in our code, and let's talk through what they are and basically, how they're going to work. So the first function is called regulate temperature, and this function typically is called for normal operation of our circuit. So it does a few things. So basically, when this function is called, here's the logic that we we execute or what this the the code that dysfunction would would until so if the temperature is greater than our marks temperature. So the current temperature is greater than the max temperature that we set, we're going to turn on our fund, so basically gonna turn you found on otherwise else. If the temperature is less than a marks temperature, we're going to turn off the fund and in its normal sort of state of operation or sick, it regulate temperature is the function that's going to be called from our Luke function, and this is just going to control typically the system and ensure that our temperature is automatically within the desired range that we set up. The other function that we're going tohave will see that we're creating. Our court is called Turn fund on and off, and this function or Mike its name implies it's simply going to check the value of our fun on a 1,000,000,000 values. So just if we look back here, if our finest turned if this is set to true or false, it's just going to inspect the value of the fund on property. Onda. Basically, if final in here, that fund on property, if that's true, that's going to turn on the fund else it's going to turn off the phone. So this convenience function is really only concerned about turning the fun on and off, only inspecting that fun on bullion value. The third function that we're goingto have a school update system and inside of this function on this bit of operation, this is where we check to see if the override enabled flag is set. So just heading back over here If the override fund control as true or false. We're going to take action inside this particular function. So here, if the override is enable meaning, if it's set the truth basically in here, we want to call our turn fun on or off function. So again, once the override is enable, then what that means is we actually have to coming back to hear. Once override is true, then the value of the fund on bullion switch matter. So if it's true, we want to turn on our fun or if it's fools who want to turn off our fund it, regardless of what the temperature is. So that's the purpose of this check here, so otherwise, if the override enables is false, that means we just want to go ahead and call regulate temperature function. So that means that we want our system to operate as normal on. Basically, check again here to see if the current temperature is greater. Any marks temperature. It clicks on the fund to cool down our circuit. Onda. Once the temperature falls below the max temperature, it turns are fun off. So these are the three mean functions that we will see in our code that we will implement and the other thing that we will also see as some of the callback functions pertaining to our properties. So the first property that we have is the marks temperature. If you remember, these are the three properties here We have max temperature overwrite, fun control and fun on on. On each of these, they're going to be read, write, and there's going to be a callback function that's going to be executed once we change any of these values from the Arduino iron clothes. So the 1st 1 is the temperature change. So on some change, we're actually going to call the regulate temperature function. So once we that say, we set a new max temperature, that's it was initially 26 we set it at 30 degrees. As soon as we make that change is gonna call this regulate temperature function and Ben were in our system is going to take into account that new temperature change. So that's the first property. The 2nd 1 is, of course, the fun on or I should say, let's do the override change. So on over a change. So on that over a change, we simply core update system So again that over a change we head back over here. If we set this the true or falls any value once this value changes from the Arduino I ity cloud to come back here, we're going to call update system and upbeat system basically will Then check if the override was enabled. Turn the fan on and off, basically, look or inspected the value of that fun on variable and control are fun accordingly or else just regulate the temperature. So that's what that over I change. Quote back knows on also the last one is the own fund on change, which is our last property and just showing you again what that was. So that's this last guy here. Once this has changed a true or false. Anytime we talk all this value, we're gonna call the call back and we're gonna call this exact same update system. So these form the properties, the callback functions of our properties. So just quickly recap he's Here are all the properties and we were able to react to the changes of the properties on our our I mean priority cloud dashboard and these callback functions will be executed and these here are the three mean functions that will be written in our core, and they will be formed part of the media logic processing of our circuit. So that sort of gives an overview of what to expect or some of the way that we will structure our code for project and in the next lesson, well, actually dive in and writing code. But hopefully this provide some background and you'll have an understanding of the logic that we're going to implement when we write our code, I'll see you in the next lesson. 53. Making Code Changes: Welcome back, everybody. And now it's time for us to dive in to some code and make the cool changes that are necessary for project toe work and for everything to come together. So here we're at the Coyote Cloud page and we have created four properties on and these properties we're going to refer to them in the cud. Onder, just a quickly recap we have our fun on which would be responsible for or I should see this is where we would tune are found on and off the marks temperature setting. We also have the override fun control when we want to take control of our circuit and then we have a temperature setting, which is just a read only value. In fact, it's the only read only property which reflects or updates with the true value of the temperature of our I T system. So those are the properties, and I'm just gonna click on the dashboard here, and these are how they are going to show up. And when we actually write our code and we're testing out our sick, it will come back to the dashboard so you can see all of these in action. So no, let's go ahead and write some code. And to do that at the top there is a button, that school edit sketch so you can go ahead and click on that button. And that should banned us in the Arduino Web editor. So let's click on that button now. So I'm just gonna maximize this window here a little bit so we can see our cool a little easier. So again, our first step as we come in here should be to click on a secret tub. And here we're going to enter the SS I. D and the password for our wireless network. So let's proceed to do that now, in order for our maker board to connect to our WiFi network. So when I enter the SS, I d hear of my network and the password. And once you have entered those values for your wife or a network, we can click on the mean tab here for our project. So once we're back here, the first thing that we need to do is we need to include the DHD Library, third party library, so we're able to use some of the convenience functions in there for our temperature sensor . So if we click on the library's tab, that should load up the library manager for us, and I'm going to click on the custom tub. And here I'm going to search for just teach T so you can type in DHT and hit Enter. And here we see the DHD Sensor Library. We want to go ahead and click on the include button, so that should include the DHT library at the top of our program here for us. So once that's done, let's cool down of it. And we have to declare a few constants here in our program. So right under thing properties that each where we include our thing properties that each file let's set up some constants. So the 1st 1 is we're going to define our DHD pen, and that is going to be pin seven. If you remember that was connected from the temperature sensor, the hope up in tow, our Meeker board. Then we're going to define the DHD type on. That's going to be DHT 22. This is what we will be using to a foot of which vision of the library or I should see which specific censor the DHD 22 a. D h d 11 were using. We're using the DHD 22 from this library, so we have to define a variable there that we will use. Then Stan sheet the DHD object and then next we can define our DHT object, and it's going to be the HD. We're gonna call it DHT. You can name it anything you want. But since it's the DHT library, we're just gonna use Boquillas tht and it's going toe granita pass and the d h depend that we're using, which was seven above on the DHD type. So this would clear our DHT variable or I should say, are in san she ate r GHT object on. This is what we will be using to take our temperature readings. Couple of the variables you wanna set up is define our fun six. And the positive pin of our fine is connected to pin six on our maker board. And the last variable we wanted to find is a default marks temperature. So let's see, e temperature was not set or a maximum temperature was not set from our i o T cloud interface that which it had no value. We want to ensure that we just have a default temperature that our program will use on and that we wanted variable changes or a set. Then it's picked up. So we just want to account for a null value or nothing mean the and let's set our default max temperature to 30 degrees. So once those of variables are defined, that's cruel down here in our program. And we need to add some additional cool right after the printed a bargain for here to initialize our objects and so on and to get things ready for execution. So the first thing that we do is we do a DHT, not begin, and that's going to just initialize our teach the object and make it ready to take readings . And we're gonna set up a pill mood for our fun pin as output. So we're seeing that are fun. Pain is going to be used as an output and will be sending no one high signals of that. And that, actually is what will go to the peace of our transistor to turn our fun on and off. Initially, we also want to turn our fun off so we can do a digital freight to our fan, and we could write a little signal to it on. Essentially, this initially tunes off our fund on here. We check if mocks temp is equal to no meaning that property was not sent. We want to set max temp until it afford max temp, which is that value at the top of our program. So just switching over here quickly to think properties that each remember Max temp was that property that we have, where we specify the maximum temperature. It we have a reference to that variable here from all thing properties that each and here were initially checking. If that value is MT. Or there wasn't anything in there, we're going to set it to the default max temperature, which would be 30 degrees. So that's the end of the set up that we need to do in our set up function after initializing variables and our fan pin and certainly max temperature and now we get into the loop function where all the magic happens for our self regulating system. As I mentioned, though, to make things easier before we get into loop there are a couple of convenience functions that we're going to write, and I covered that in the previous lecture when we discussed some of those functions and logic that would be in there. But before we start writing that, I just wanted to highlight those callback functions that go created for us. So on Max Temp change again. Once we tuggle the widget from the IRA T Cloud, a signal is going to be sent from our make aboard over the Internet I D Cloud and whatever court is in here is going to be executed as well as the override fan control and the fan on double switch. So a bully and I should see. So once those values that changed, these quote back functions are going to be executed. So the first function that we want to right here is the regulate temperature. So we're going to do avoid regulate temperature. So if the temperature is greater than Marx, underscored temperature marks on the score attempt. If that's the keys, then we are going to turn our fund owns Will do A did still right our fund pin, and we're gonna right toe high. And of course, that's going toe Turn on our fun, Els We're gonna turn off our friend and the turn off our fun We do a digital right there are fun on that's going to be little. So in addition to turn any values on and off, we also want to set the fun on a 1,000,000,000 flags and fun One is going to be equal to truth. Onda here since we turned off our fun fun off is equal to truth And these are I should see the funnel on fun on here Sorry is equal the false So they found on property itself is what we are, what will be visible in the I T cloud interface. And of course, if we turn our fun on, we want him Make sure that the value of that property reflects the current state of our fan . So we're also gonna turn that flag true. And then if it's of course, you turn the fan off. We wanted to in that flag off, so it's gonna be false. So that's the regulate temperature convenience function. The other function we talked about was turn fun on or off, and this simply will check if that fun on flag is set to true on again. Remember, this is a value from our I ity cloud We want to turn our fun on so we do a digital right and to our fun taking it on health We turn off our funds who do a digital right to our fun and we turn it off. So those already only two conditions that we need to execute here and it turned fun on or function the last bit off, I should say, the last major function or convenience function that we want to create a update system so we can again have avoid upbeat system here. It doesn't take any arguments or parameters. So if override fun control, basically if that which it was set to true from the mean dashboard, then that means that we need to manually control are fun. So if that override fun control is set, we can call our tune fun fallen off function here, And that's going to be this guy, and it's going to check to see if the fine is on about. We have to inspect the current state of that fun on property. And if it set the own we gotta turn off and on. Otherwise, turn it off. So that's once that override flag is set, we need to inspect that variable. Otherwise, if it's not sent, we simply want to regulate the temperature. So our system is going toe up your operate like normal, and it's going to. Of course, if the current temperatures greeted any max temp is going to kick on. Our fun changed the state of our circuit to reflect that I should say, changes state of the property on the interface to reflect that. And if the temperature is less stunning max temperature meaning our system has cooled down enough, we're gonna turn off our fan and tune off the indicator as well. So those are the convenience functions. So the other cool changes that we need to make here for our callback functions. So if the maximum chip temperature was changed at any time in here, we want to call regulate temperature so immediately. If we let see, it was set to 25 degrees and we change it to 28 we immediately want to check. Hey, is this was the temperature. I was changed to a greater or the current temperature greater than it marks temperature. I was changed to and are sick. It would react accordingly. So that's going to be called here on Mac stem change. The other cool change that we need to make for the override. So once the override A is changed, I want to call update system Onda. Of course, what would happen here is if we tackle that Boolean flag to take manual control of our circuit up the IT system with just determine exactly what needs to be done. So if manual control is on true, then we check the state of that fun on toggle switch and then we we treat it accordingly and then finally, for on fund change here, we also do update system. So similarly, if we tackle that fun on bullion, we're only going to control our fun if and only if override is controlled or should see override is enabled otherwise, if it's not enable, we have to ignore it and just do regulate temperature. So hopefully you see how these, you know, by writing these three here, convenience functions were ableto referred to them in our callback. So once that those functions are written in our loop function and becomes very simple here . So the first thing is in a loop function. We want to read the temperature data. So in order to do that, we simply do a temperature. And that is the property from again our i o t. Which it screen or from the i o T Cloud we set that temperature value is equal to DHT. That read temperature on our library will take care of getting that reading from all the HD 22 sensor. And here we can do a serial. We want a print out to the serial monitor, the temperature and specifically what the value is on here. We can do a serial that print out that temperature value, and we also want to indicate that it iss Celsius circular cereal, that print print line, give us peace and put Celsius, and that's gonna print out the current temperature. So once that is done, really the only function we need to call in here as update system, so that's gonna take care of everything else. No other cool or logic is needed in here, and then we can put in a dally off of five seconds or so so the temperature reading would be taken every five seconds and just a comment here about updated system. Basically, we're going here to control the fund or regulate temperature based on user input setting. So you can see by writing that one up the IT system function. It takes care of everything here and are looked for us. We don't have to duel this logic and checking on in this way by writing our code in this way. It's very I should see. It's very neat. It's also there is separation of concerns because each of these functions handles something specifically. And of course, there's a lot of re use of those functions and that were referred to the seem logic and our callbacks. And it's just a clean, neat way to write our code and a reusable we that it's easy to understand, and also we have a maximum reuse, very efficient. We have writing our code, so that's it that completes the code changes that we need to make Andi in next lesson. We're going to test everything out. So, uh, pretty soon we're going to see if all the wiring of our circuit and all the court changes everything was able to come together and let's see our project in action 54. Testing it out: Welcome back to the course, everyone. And now it's gonna get really exciting. We're going to test out our temperature, self regulating I ot application. And just before we get going, there are a few things we need to double check. So here I might be I ot Cloud Council, where we set up the properties for our coyote cloud attempt control thing. And we just want to ensure if we look at the temperature property and click on the edit icon, we want to ensure, of course, that it is set up us float. The men value goes from minus 15 to 80 degrees, and that's the range of our DHT 22 center. And also this particular property is read only. So verify that those settings are in place, and also we want our value to update with a delta of 0.1. So that will give us more. Find green control on exactly when the temperature values are updated and those changes will be reflected on the console. So we just want to ensure that this delta is 0.1. So once you have that in place, ensure that everything is saved and the other properties as well. They have to be read on right because we will be interacting with them. So once those have been verified, let's go ahead and let's add it to sketch. And when we get to the Web editor, go ahead and connect your USB cable, as you can see or Mick aboard was detected, and the first thing that we should do is of course, we can click, verify and save. So go ahead and click this button. This is just gonna verify are cored and save it to the online sketchbook. So it does a pre check to ensure that we don't have any compile Asian errors and so on. So we'll give this a few seconds to run. Gay Looks like it was a success and it was saved to our online sketchbook. Next up, we're going to click on the right arrow to upload and save our code. So this is gonna uploaded Kutan Maker Board. Go ahead and click on this and let's give this a few seconds to run. Okay, So success. So it has been uploaded. Onda, we are all ready to go. Let's go ahead and open up the serial monitor here. And if you click on a serial monitor tab, we should be able to see our board. And there we see that it's connected to a network and here, as offers reading. So the current temperature is 24.5 degrees Celsius. So from here, I'm going to open up the charity cloud and let's just open this in a new window. That way we can see these two side by side, and I'm going to go ahead and click on dashboard. So let's click on dashboard and here we're going to see a visual representation of our widgets on our system. So currently, what's the state of our system? The temperature is set at 24.2 degrees currently, so that's the current temperature coming from our fun, and this temperature here will update every five seconds or so and with the value and also here are fun is currently own, so if you'll notice, you'll see that our fun is spinning and the marks temperature setting that we have here is currently set at 24.17 degrees. So as you'll see the fund just shut off because the temperature reached or it fell below DNI max temperature setting. But let's do this. We can tweak this value unless assimilate or fund turning on, so it's a kind of 24.17 I'm going to reduce this a little bit to reduce the marks temperature of our system, and here we go. So the current temperature or I should say the marks temperature we set to was 21.84 and that is Will Balu. Of course, our 24.1 current temperature so are fun is going to turn on and it's going to kick on, and it's going to try to cool down our system until it reaches this 21.84 or about and then our final shut off. Now, of course, that's quite a big temperature difference. So let's go ahead and let's treat this over with when I get it close to 24 as we can. So right now it's a 24.171 and of course, the current temperature is reading a 24 and that is a little less so. The final shutting off. Let's go ahead and simulate taking control of our system and manually turning on our fan. So I'm going to hit the override switch and put this the own and then I'm going to click on and this should turn on our fan. So now we're an override status, and it's gonna take a couple seconds here and there we go. Our front kicks on. So that signal made its way from the charity cloud down door circuit, and now we're manually controlling our fan. So regardless of what the temperature settings are, we are have set that are far on his own. So there it is. Our fun is running regardless of whatever the state of the system is now that simulated in our front off. So again, the override is tuned on. So if I turn this off, we're going to give it a couple seconds here and our fun will shut off. So there goes, it shuts itself off, and it's slowing down, and now it's completely off. So, as you can see, we can take control of our priority system at any time and were able to control the state of the fun just by overriding or enabling this override switch and then making tuna fan on So let's try it again. Turn off and on. There it goes. It switches on and no one went toe. Switch it off again, and there it switches off. So that demonstrates how we're able to control our friend. Let's take off the override. And now we're back in tow. Temperature regulating mood and our current temperature, as you can see, is 24.2 degrees Celsius. And our setting here for Max temp is 27. So what I'm going to do is I'm going to use a soldering iron, bring it close to my temperature sensor is gonna be a very hot and I'm going to increase the system toe past 27 degrees on. You'll notice once that happens, the fine is going to kick on the cool down our system. So let's check this out here and put in a Southern. I'm pretty close to the sensor, and if you take a look at the readings on the left here, you'll see that it's increasing. So it's going to 24.4, 24.7, and it's actually rising pretty quickly. You're here also seeing that reflected on the coyote dashboard temperatures increasing 25 25.4. Pretty soon we're going to hit or we're getting close to 27 over a 25.9 and our finest gonna kick on because it's going to exceed our maximum temperature. This is gonna test if our system is self regulating. So here we go. We're getting up. There were passed 27.2 and very shortly are fantastic on, and they're dead. So it was able to kick on because it exceeded the temperature of our system. And I'm going to move the center and I are in a week, and this is going toe cool for a little bit. And when the temperature drops below 27 right now it's a 27.8 point nine. As you can see, it's starting to drop 27.5 and our fine shut off because it dropped Balu. Now it's a 26 dropped below the 27 point to eat maximum temperature setting. So again, let's just check this out again. It's a 26.3 right now. I'm gonna heat it back up, bring the salt and iron close to the sensor. The temperature starts to rise again. It's a 26.2 and it's gonna start to rise pretty quickly. 26.4. Once it passes 27.2 wheat or around there are funds gonna kick on. So any second now it's a 27.1 on. Here we go there kicks on to cool down our system Civil. As you can see, our system works. And of course, if you notice on the dashboard as well defund own struggles which automatically changes from after own indicating the current status of our fun, it's on. And just now, in a second, when it falls with low 27.2 right now is a 27.5. Our fund will shut off on our fun own indicator on our dashboard is going to go from on to off so they're fun shuts off and the indicator goes off so they have it. This is our reality project built in the Arduino. Aren t cloud were able to regulate temperature, set a maximum temperature and have our fun kick on and off when fresh holes or when the temperature exceeds the maximum temperature setting and were able to monitor all of this in real time from a dashboard that was really easy to set up in the Arduino ality crowd. Hope you like this project and hope it opens your eyes to the possibilities of the types of coyote ups that you can build with the Arduino charity crowd.