Exploring the Arduino Nano ESP32 | MicroPython & IoT Cloud

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we're taking a look at the Arduino Nano esp32 we'll see how to set up our IDE test the board with Wi-Fi and turn it into a human interface device we'll also program the new Nano with micropython and we'll use it to build a project on the Arduino iot Cloud there's a new family member today so welcome to the workshop [Music] well hello and welcome to the workshop and those of you who are observant will notice that I am once again wearing my Arduino shirt now I want to quickly dispel any rumors that I only wear the Arduino shirt I wear several different shirts and I have indeed washed this shirt since the last time you saw it but the reason I'm wearing it today is the same as the reason you saw me wearing it the last time Arduino has once again released a new microcontroller board this time another member of the growing Arduino Nano family now this year Arduino has already made a few releases they started the year off with the Arduino Giga and then after that we had two Arduino Unos the Minima and the Wi-Fi and now we have the Arduino Nano esp32 now from its name I think you can tell what the main feature of this board is it's the first Arduino Nano to use an esp32 2 is its main processor although it's not the first Nano board to have an esp32 a couple of the boards have used an esp32 as a Communications co-processor now with this board Arduino is really pushing the fact that it can be used on the Arduino iot cloud and we'll be taking a look at that in this video another thing they're pushing is the fact that this board can be programmed in micro python another thing that we will look at today so let's go and take a look at the brand new Arduino Nano esp32 the Arduino Nano esp32 provides the power of an esp32 in the familiar Arduino Nano package 3.3 volt logic device and is the first Arduino Nano to use a USBC connector this board is Arduino iot Cloud compatible like all Arduino boards it can be programmed in C plus plus but it could also be programmed using micropython the Arduino Nano esp32 is capable of emulating a human interface device such as a keyboard or a mouse this is the seventh member of the popular Arduino Nano family the original Arduino Nano board is still available it's based around an atmega 328 microcontroller the same one used in the Arduino Uno R3 it has a mini USB connector and uses 5 volt logic an upgraded version of the original Nano is the Nano every this is the least expensive Arduino Nano and it uses an atmeg of 4809 microcontroller it's also a 5 volt logic device and uses a micro USB connector the Nano 33 ble has Bluetooth connectivity and uses an nrf52840 microcontroller it also has a micro USB connector and this is a 3.3 volt logic board the Nano 33 ble sense is an advanced version of the Nano 33 ble and it includes a number of additional sensors on board the Nano 33 iot may be familiar to the audience of the drumbot workshop as we've used this board before it has Wi-Fi and Bluetooth capability and it's based around the Sam D21 microcontroller it has a micro USB connector and this is a 3.3 volt logic board another board that we've used here in the workshop is the Nano rp2040 connect board this board is based around the Raspberry Pi rp2040 microcontroller it's also a 3.3 volt logic board that uses a micro USB connector this board is the same familiar pin out as all of the boards in the Arduino Nano series note that when I'm labeling the data connectors I'm giving two labels to them the normal Arduino data output pin such as d0 D1 and the esp32 gpio pin you'll need to know this information for two reasons the first reason is that you can use these boards with the esp32 board manager instead of the Arduino provided one and if you're doing that you'll need to use the esp32 gpio numbers also if you are programming in micropython those are the numbers that you will use to address the ports the i o pins can Source 40 milliamps and sync 28 milliamps all of the gpio pins can be used as interrupts they all support pulse width modulation but due to some timer restrictions you can only use four pwm signals simultaneously the board has the same eight analog and puts as all the other Arduino Nano boards this is a 12-bit analog to digital converter but it will default to 10 bits for compatibility with older software if you don't require analog inputs you can use these eight inputs as digital i o pins the Nano esp32 has a uart whose transmittent receiver on the bottom two pins the Nano esp32 has a single I squared C bus and it's located on pins A4 and A5 by default however you can programmatically change these to use other pins if you wish the board Sports and SPI bus with connections for controller and peripheral out controller out peripheral in and the clock connection as for chip select you can use any of the digital i o pins for that there are a couple of ways that you can power the Arduino Nano esp32 the first way is to use the VN pin although it's recommended to use 6 to 18 volts here it'll actually accept voltage as low as 4.5 or as high as 21 volts the bus in is the connection provided to the USBC connector and it will draw 5 volts from USBC there's a 3.3 volt output for powering external peripherals the 3.3 volts is provided by an internal Buck converter on the board there's also the connection labeled v-bus which is an output if you power the board using the USBC connector this output provides 5 volts however if you're using V in to power the board the v-bus is disabled in addition there are two ground connections which are easily identified with a white marking on the board b0 and B1 are the boot pins if these pins are grounded you can load the bootloader by pressing the reset button there's also an external reset input and of course the reset button at the top you can also enter the bootloader mode with the reset button without using b0 and B1 simply press the reset button and press it once again when you see the RGB light flashing there are three LEDs in the Arduino Nano esp32 the power LED whose purpose is pretty obvious the LED built-in which is connected to pin D13 this is the Same Led we use for our blink sketch there's also an RGB LED whose segments can either be addressed using their i o port or by using the Constance LED red LED green and led blue the Arduino Nano esp32 is based around a u-blocks Nora w10610b module this module contains an esp32 S3 microcontroller this is the 32-bit dual core microcontroller and can run at a clock speed of up to 240 megahertz it has 384 kilobytes of ROM and 500 kilobytes of static Ram it can also use 16 kilobytes of static Ram when placed into low power mode it provides 2.4 gigahertz Wi-Fi and Bluetooth 5. the Nano esp32 also has an additional 16 megabyte external flash chip you can program the Nano esp32 using either C plus plus or micro python and so now let's get started with the Arduino Nano esp32 and so here we have it the new Arduino Nano esp32 board or I should say boards because I've got two of them over here when you purchase this you have the option of getting it with the pins soldered in as this one or you can get the pins separately and that offers a lot of Versatility as you'll notice the board uses a cast related pin design on it and that allows you to surface mount the board if you wanted to and also having the pin separate allows you to solder in only the pins that you need to solder them the other way around or to even use different connectors on the board so it's pretty versatile so now that we've seen the board let's start working with it now of course one of the first things that we're going to need to do before we can start working with our new Arduino Nano esp32 board is to install a boards manager for it so open your Arduino IDE and go into the boards manager and just type in esp32 in the filter and you'll notice I come back with two different results the esp32 by espressive which I've already installed and a new one from Arduino with the Arduino esp32 boards and it includes the Arduino Nano esp32 so let's just install that and we've successfully installed the board manager and we're ready to use our new Arduino Nano esp32 board now in order to test out the board I decided to forego the usable blink sketch we've already seen the board blink anyway because it came running it from the factory instead I went into some of the sample sketches that come when you load the board and there are a lot of them if you've used the esp32 before you'll recognize a lot of those sketches because these are samples that are based on the esp32 now I should warn you that not every sample will run immediately on the Arduino Nano esp32 board simply because I noticed that a few of the sketches use PIN numbers that are not applicable to this but they can probably be modified one that you don't need to modify however is the Wi-Fi scan and I thought I'd run that as my first test of the board it's a very simple sketch you can load it off of the sample sketches it includes the Wi-Fi Library sets up the serial monitor puts the Wi-Fi in the station mode and this doesn't disconnect in case it was already on an access point and then in the loop it just prints out to the serial Monitor and does a scan Network and then it prints out the results of the scan in detail and waits about five seconds and does it again so it's a pretty simple sketch and it's a great one to test out our board so I've already loaded it up to my esp32 I'll just turn on my serial Monitor and we can see that it is indeed scanning and it's working very well if you're wondering about the repeats here by the way on dbws net that's my own network it's a mesh Network and it has three repeaters on it there's also an outdoor one over here the laser gets also mine so a lot of this is my own stuff plus some stuff that's in the neighborhood over here so the scan seems to work pretty good obviously the esp32 is working and now we can move on to a few more interesting things now one of the features of the new Arduino Nano esp32 board is that it can be used to emulate a human interface device place and that's not as scary as it sounds it's not some sort of a biological implant a human interface device is simply referring to devices that can connect to a computer so that humans can control it I.E a keyboard or a mouse or a trackpad well you can emulate that with the new Arduino Nano esp32 and create all sorts of custom projects such as custom keyboards or custom sequences that you can automatically run on a computer so let's go and take a look at the new Nano has a human interface device the human interface device function allows your microcontroller to emulate either a keyboard or a mouse in order to simplify this Arduino has provided two libraries a keyboard library and a mouse library and you can see the different functions that the libraries have here note that when you're programming for an HID device you should be using switches to activate your keyboard or Mouse movements and not do them continuously if you do that you could program yourself into a trap where if you try to reprogram your device it will be controlling your IDE and making keyboard in Mouse movements while you're trying to program and you don't want that for our experiment we will of course use the Arduino Nano esp32 and we're going to be using five momentary contact normally open push button switches we'll connect i o pin D12 to one side of one of the push buttons this will be the up button that will cause the mouse to move upward d11 will be connected to one side of a push button that will be our down button making the mouse make downward movements we'll connect d10 to another push button and this will be for the left movement of the mouse D9 will be connected to a push button that we will use for the right movement and we'll connect pin d8 to a push button that will do the left click of the mouse now in this experiment we are not adding a push button for the right click but you could add one to another i o Port if you wish we will also connect the ground to the other side of all of our push buttons and this completes the wiring now let's go and take a look at some code we can use for our human interface device now in order to make our Mouse work we're going to use one of the sketches that was included when you installed the boards manager for the Arduino Nano esp32 and this is the button Mouse control sketch now as you recall I mentioned earlier that the esp32 sketch is included with the Arduino Nano esp32 are generic esp32 sketches and some of them need modification and this is one of them and here's what the modification is for you can see in the description that we have five push buttons and these are the pins they're attached to well those are not the pins we are using D12 is correct the rest of them are wrong we don't have D14 and D15 available directly but we can use those to control our RGB LED but we don't have access to most of them one of them D14 is actually also the boot pin and you shouldn't try using that as an input pin we could have used d0 but I decided not to and so that's the change need to make the sketch otherwise the sketch is pretty simple we start off to sketch first of all by determining whether the USB port isn't on the go mode it needs to be into on the go mode before we can use this sketch so if it isn't we just abandon the sketch but assuming that it is we include the two libraries that's the USB library and the usb hid Mouse library after that we create an object named Mouse and then we go and set up the push buttons and here's where I had to make my modifications you'll have to make those same mods over here so modify them and they're just sequential 12 11 10 9 and 8. after that we have the range the amount that we're going to move on the screen every time we push one of those buttons to go up down left or right and a delay in the response that just makes it a lot easier to use in the setup is quite simple we initialize all of them as inputs and we use the internal pull-up resistors and that avoided us having to use five external resistors on the push button switches then we start both The Mouse and the USB in the loop we go and we read those buttons we read the state of the buttons with the digital read and we calculate the distance based upon the button States so if any of the buttons were pressed we're going to get results over here and so if we get a non-zero result we will go and we'll do a mouse move and this is how we move the mouse and you can see we just provide the x coordinate and the y-coordinate and the range okay now if the mouse button has been pressed this uh is for the mouse click and this is for the left click so if you want to make another button in there to do a right click you would essentially copy this bit of code except use Mouse right instead of mouse left after that we just put in a small delay and this is just the end of the if statement to make sure that we are in usb OTG mode and so the sketch is actually pretty simple to use we'll load it up and we'll see if we've actually created a mouse now in order to demonstrate this I've opened up ubuntu's Mouse testing screens and I've made my cursor as large as possible so hopefully you can see it and I've got the circuit here in the board of course and so let's just take a look at what some of the controls do here's the one that can move the cursor to the right and I think you can see that happening move it back to the left we can go down we can go up let's move over to the left a bit and go down to here where we can test the click I can even do a double click that's great move it up it does seem to work indeed and it works pretty well and so as you can see it's very easy to emulate a mouse or another human interface device using the Arduino Nano esp32 now I should mention there is also a keyboard demonstration program that uses basically the same wiring and you will of course have to change the inputs that we're using like we did for the other code but you could try that sample out as well and check it out for emulating a keyboard and this can be great for building a custom device that you can use to create macros or to control a computer directly one of the features of the new Arduino Nano esp32 is that in addition to C plus plus it can also be programmed using micropython micro python is a more human readable language than C plus plus and it can allow for Rapid application development now in order to use micropython on the board you need to install micropython first and we'll be using a different editor than the Arduino IDE 2.0 that we've been using for our other experiments so let's go ahead and install micropython onto the Arduino Nano esp32 the micropython project was the brainchild of Damien George a physicist from the University of Cambridge in the UK Damien's concept was to create a scriptable language that could run on microcontrollers and with that he created micro python micro python is a subset of Python 3 and has been optimized for use on microcontrollers and includes libraries for addressing the microcontroller's hardware it was initially funded in a successful Kickstarter campaign in 2013 allowing Damien George to quit his job and work full-time on micropython the first microcontroller that used micro python was the pi board a board designed specifically for the kickstarter campaign in 2013. the pie board is still considered to be the standard microcontroller for micropython but it's now been ported to many different microcontrollers the key difference between micropython and C plus plus is that C plus plus is a compiled language whereas micropython is an interpreted language in a compiled language you write your code on a computer and then run it through a compiler that is also on the computer the compiler produces binary code that is usable by your microcontroller and it sends the binary code to the microcontroller when the MCU wants to run the code it reads the binary code directly in an interpreted system though the code is written and the text is sent directly to the microcontroller onboard the microcontroller is an interpreter The Interpreter turns the text into the binary code and then feeds it to the microcontroller whenever the microcontroller wants to run the code it needs to run it through The Interpreter first the advantages of C plus plus or faster execution because it doesn't need to use The Interpreter it also requires Less storage space on the microcontroller as the binary code is much more compact than the text file C plus plus can also provide more security for code that requires passwords Etc because those passwords would be embedded within the binary code and would be very difficult to retrieve micropython on the other hand is more human readable and much easier to edit micropython code is portable so the code written for one microcontroller could be very easily ported to another one with similar features one big advantage of micropython is that the development time is much faster as you can immediately test the effect of different statements and you can use Rebel the command line in order to test them out before writing code with C plus plus you would have to compile everything before testing it there are many different editors you can use for micro python but we'll be using the Arduino lab for micropython this is a text editor with python syntax highlighting it includes file system management and a command line called read a Val print Loop or Apple it has code execution controls to run and pause code and it will also work with non-arduino boards the steps that we're going to be taking today are as follows first we're going to download the Arduino lab for micropython then we'll download the Arduino micropython installer in the third step we'll use that installer to flash the micropython firmware to the Arduino Nano esp32 board in our fourth step we'll connect our code Editor to the board and then in our fifth step we'll write a small program to verify the correct operation so let's get to it now in order to work with micropython with our Nano esp32 we're going to need to do two downloads the first thing we're going to download is the bootloader program this is a program that we're going to run on our computer to load the micropython bootloader onto our Arduino Nano esp32 and it's this page on GitHub that you go to in order to get the bootloader now they have them for Linux for Windows and for Mac OS on Linux and windows it's a Dev and exe file respectively you can just download for Mac OS it's a zip file you'll need to unzip it and there'll be a DMG file in that you'll just drag that into your applications directory you can just run the windows exe to do the install and the dev file if you're using Ubuntu just right click on it and use the software installer to install it and with all three operating systems you'll get prompted to accept the file from a external source and you can trust Arduino so you can say yes you accept it now you're also going to need to download the Arduino lab for micro python this is the micropython editor and as you can see it's pretty well in its infancy 0.8.0 at the time of filming and they have it for both Linux Windows and Mac just download whatever you need for your computer and this is a self-contained file for all three operating systems so you can just click on it and run it so go and grab those files and the next step is to load the micropython onto our Arduino Nano esp32 now to get the micropython onto our Arduino Nano esp32 board we're going to need to put the board into bootloader mode and there's a couple of ways you can do that you can just use the reset switch and do a double click on it and watch the status button and click it again but I find that to be a little bit awkward and it's a lot easier to do just with a jumper let me show you how you do that now you'll see that there's a ground pin over here you can always see the ground pins because it's got a white mark on the board beside a ground right next to it is a B1 pin that's our boot one and when I put the jumper there you'll notice that the LED turns green and if you look at our schematic you'll see why it turns green that's tpio zero and I just sent it to ground and gpio0 is also the green segment on our RGB LED so it seems the LED is actually active low now if you've programmed an esp32 before for example an esp32 cam you might recognize the procedure of grounding gpio0 at any rate once I have it grounded once I want to do is just press the reset key and I can release it and then take my jumper out and I don't know if you can see that too well but the LED is now sort of a purple color and that indicates that we are in bootloader mode now on our computer I've got the micro python installer and as you can see it's detected a board if it doesn't see it you can just hit reload over here but it's already detected that I've got an Arduino Nano esp32 it's a very easy thing to do what I really just need to do is hit this green button and say install micro python but let's look at a few of the options we have over here first there's a button here that we can use we can click off this to use a nightly build and that'll get us the latest greatest build of micro python however I should warn you that they're not always the most stable build so unless you have a reason for doing that don't click into that you can also drag in or open a file over here to upload something other than the micro python bootloader and that might be handy I wouldn't be too surprised if someone ports perhaps zetafruit themselves will Port circuit python over to the Nano esp32 and this would be a way of installing it but we just want to install micropython so we're just going to click on this and it's flashing micropython has gone up to the Internet to get the latest greatest version and there we go we've successfully added micropython to the Arduino Nano esp32 now after you finish flashing micropython up to your Arduino Nano esp32 you're going to need to reset the board and the easiest way to do that is just to pull the micro USB connector out and then put it back in once you've reconnected open up the Arduino labs for micro python editor that you downloaded and you'll see a very basic editor that already loads a very small script into it now the editor has a few controls in the top if you've used the Thani editor from micropython you might recognize some of this editor because it's styled a little bit like it right now what we need to do is to connect to a board and you can see we have a connect button and we have a status down here of disconnected so let's hit connect and we see that we've got something on this port over here now this is the only Port that we have an option for so it's seen a board there now keep in mind that I'm on Linux if you're on Windows or if you're on a Mac you'll have a port but it'll be labeled a bit different than this one so I'm just going to select that and as you can see from the bottom we have a terminal and the terminal is actually the micropython this is actually the board over here so we have connected to it you can toggle the terminal on and off just by clicking the button over here the files over here will show you the files that are on the board itself right now it is a boot.py on the board and this will also show you your local computer over here so you can move files around and you can save them and as I said we've got a scripted side here and it's a very basic script we're just going to import the Sleep live sleep function from the time library and then we're going to do a basic for loop from 0 to 10. we're just going to print a period we're going to sleep for 0.1 which means one tenth of a second and do it over and over again and so what we can do is we can open the terminal and if we want to we can run this and if you'll notice in the terminal it ran now as I said we can do basically instant editing with micropython and it's rapid application development is one of the big features of micropython so let's just change that to something else and we'll write hello in there and then we'll run that and you'll notice I didn't have to save anything or do anything I can just play with the code and see the results in instantly and this is what's called Rebel and it's actually one of the main features of micro python now we're not going to go too deeply into micro python today but as you can see we've loaded it now onto our Arduino Nano esp32 board well since we didn't run the mandatory blink program with the Arduino Nano esp32 I decided we would do it in micropython so that's essentially what we have over here from the machine library and the Machine library has all of the different functions that the microcontroller would have so you often import from machine we're going to import pin that defines the i o pins and we'll import time again we'll call a variable my LED and we're going to Define it as pin zero and that pin is going to be an output now if you look on our gpio listing pin zero once again is that green segment of the RGB LED so that's what we're defining is my LED and this is where we're basically blinking it we're going to turn the value to a zero we're going to go to sleep for one second we're going to turn the value to a one we're going to go to sleep for a second and we do this while it's true so basically we just continue to do it so this is the equivalent of a loop in one of our Sketchers so what we can do is we can basically run this right now I can open the terminal if you wish but there's not much to see in the terminal we really want to look at the board and we'll run this right now and as you can see our green LED is flashing now we can if we want change it to a different i o pin now the green is on gpio zero the red is on gpio 46 and remember we're using the esp32 gpio numbers when we're programming with micropython so I just changed that to a 46 and I'll hit run and now I've got a red one flashing and if I want to I can also choose 48 because that's the same as D13 the one that we generally use for the blank sketch and I'll change it to that and as you can see our D13 is flashing you'll also notice the red one is still on and that just happens to be the state that it was in when we changed the program and so there you have it we can develop with micro python using the Arduino Nano esp32 and now we have run the mandatory blink sketch so after you've used your Arduino Nano esp32 with micro python for a while you may want to go back and use C plus plus and you can easily do that just by reinstalling the Arduino bootloader and I'm going to show you how to do that right now now once again we need to put the board into bootloader mode so I'm going to take the ground connection and connect it to B1 and I get my green LED I'm going to press reset and release remove the connection and it's purple so I am in bootloader mode I'm going to go into the Arduino IDE now you could use IDE version 1.8 or version 2 but when I go into here I notice I'm connected to not an esp32 Nano but a different board so I want to change that and that's not uncommon because it's running micropython the Arduino IDE really doesn't know what it is and so I'm going to go and look for a nano esp32 and there it is and so I'm going to select that instead and tell it I'm a nano esp32 now I want to go into tools and under Tools I want to go and look at programmer and I want to make sure it is ESP tool that's been selected you're going to want to check that because by default it may not be selected and then after that I'm going to go into sketch and do upload using programmer and I'm done and I'm going to disconnect and reconnect and if you'll notice I've got a flashing LED and the astute if you will have noticed that it was the blink sketch that I had in my Arduino IDE and so that's what it did it Reloaded The bootloader and it also loaded the sketch I had open which in my case happened to be blink so you can very easily switch between C plus plus and micro python on the Arduino Nano esp32 the Arduino iot cloud is a product that we've worked with before here in the dronebot workshop I actually did an introductory video to the cloud a couple of years ago and I will be doing a new video on the Arduino iot Cloud very soon to show you all of the new features and the new boards that you can use with the cloud now in 2023 and the newest board that you can use with the Arduino iot cloud is our new friend the Arduino Nano esp32 so let's take our Nano esp32 and connect it to the Arduino iot Cloud the Arduino iot Cloud provides cloud services for a variety of microcontrollers both from Arduino and from other manufacturers you can control these microcontrollers using a dashboard that you can run on a desktop or mobile device you can also interact with these microcontrollers using an Amazon home control device the basic concept of the Arduino iot Cloud revolves around the thing a thing is a device that is built with a microcontroller and has a network connection to the iot cloud it runs a sketch and can manipulate Cloud variables which are variables that are visible throughout the cloud you can control your thing with your dashboard or with your Amazon home device the Arduino iot Cloud provides over-the-air OTA uploads this allows you to upload new sketches to your devices without a direct connection to them the iot cloud provides a scheduler you can schedule jobs to go on and off for a specific amount of time web hooks allow you to integrate your project with another service such as if this then that with support for Amazon home control devices you can add voice control to your projects and variable synchronization allows variables to be synchronized across devices connected to the cloud simplifying programming to work with the Arduino iot Cloud you'll require an Arduino account and an iot Cloud plan there's a free tier that you can use to perform the experiments we're doing today you'll also need to install the Arduino create agent on your computer this is a small program that allows interaction with USB connected devices after that we're going to build a thing and we'll build a dashboard to control our thing so let's begin by heading up to the Arduino iot cloud now to check out our Nano esp32 with the Arduino iot Cloud we're going to create a pretty simple temperature and humidity sensor device and we'll be using an Adafruit a8t20 temperature and humidity sensor it's an i squared C device and the hookup is pretty simple it goes as follows we will connect the v in pin on the aht20 to the 3.3 volt output of the Arduino Nano esp32 we'll connect the ground of the ht20 to one of the grounds on the Arduino Nano we'll connect the scl PIN to pin A5 on the Arduino Nano esp32 and the SDA will be connected to pin A4 and this completes the wiring now let's get our temperature and humidity sensor working on the Arduino iot cloud now the first thing you're going to need to do to work with the Arduino iot cloud is to install the Arduino create agent onto your computer the Arduino create agent is a small piece of software that runs in the background of your computer and it provides an interface to the USB port so that the web-based Arduino iot Cloud products can access it it runs all the time in the background but you can configure it if you wish to only run when you need it it's very simple to install because Arduino has a step-by-step installation page and I'm on the first page of it right now and I'll hit the start button and it tells me I'm going to need to download the agent install it and congratulations and if I hit the download button I'll get prompted to download the agent now I'm not going to actually do it myself because I already have the Arduino create agent but it's a very simple procedure it works for all three operating systems as you see it says the agent correctly installed because it's already gone to my machine and seen that the agent is there so once you have this installed we can start working with the Arduino iot cloud all right so now I've connected my Arduino Nano esp32 up to my computer and I've opened up the Arduino iot Cloud page now I'm going to assume we've already created the cloud account it can follow along as I said a free account will work for this just fine now on the top of the page you'll see a number of items things dashboards devices Integrations and templates we're going to concern ourselves with the first three items of things the dashboards and devices and right now I'm on the devices page now it's listing a number of devices that I already have connected to the Arduino iot Cloud if you're just starting of course you won't have any devices here but I'm going to click the add button in order to add my Arduino Nano esp32 board so remember I've got the board connected to the computer I'm going to select an Arduino board and it's going to go out and look for it my computer has the Arduino create agent so it should be able to connect to it and it found an Arduino Nano esp32 so I'll say configure the first thing it needs is a name it's going to suggest one but I bought my own name for it and I'll give it that name and now it's going to come up with some information that's very important especially this secret key over here you can't recover this key this is the only time you're going to see it so you either need to copy it or do what I do here which is download the PDF document and I'm going to download the secret key and save it as a PDF and I'll have this information because this key is going to be required when I configure my Arduino iot Cloud thing okay so I'm going to say that I've saved the key I'm going to continue and it says congratulations I'm all set and now my Nano esp32 is in my list of devices that I can use with the Arduino iot cloud the next step after adding our device to the iot cloud is to create a new thing and I'm on the Things tab right now and I'm going to hit the create button and this is the screen we're going to be using for creating our things you can see that at the top over here it has a place that we can give our thing a title so let's give our project the title I'm going to call it iot thermometer you can call it anything you like now we need to associate a device and of course we're going to associate the Nano esp32 that we just created so we'll click on here we'll get a list of our devices now if you've just started you'll only have the one device but here's the Nano esp32 and I'm also going to need to enter some Network credentials and over here we need our Wi-Fi name that's here SSID and the secret key you will call is that one of the things that was generated when we created our device and so we'll just paste that into there and we'll save that and the last thing we need to do is to create Some Cloud variables and we're going to need two variables because on our project we're going to get both the temperature and the humidity so what's that our first variable and I'm going to use this one for temperature and I'm giving it a name now you can call it anything you want I call it cell temp sell for Celsius and for the variable type we are going to make this a floating Point number and here's floating Point number now for variable permissions you have two choices read and write or read only in this case we only need read only because we're only going to be reading this we'll never write back to the device with the temperature so it's read only now for the update policy you actually have two choices as well and either of them is good on change means that this will be updated whenever the variable changes and we're going to leave it like that but periodically you could choose to do that and update it every second or every two seconds and regulate the amount of data but I'm going to leave it like this and I'm going to add my variable I'm going to add a second one for humidity Rel humid for relative humidity same type of variable and the same options over here okay and you'll notice that we have two other tabs over here sketch and metadata we're not going to concern with metadata but sketch you'll see has a little tube beside it and what that means is that the sketch that this is generating Force has had two modifications and those two modifications would have been the two variables over here and we can see the sketch over here and so this is the sketch that is being created for us and it has all of the things we need for the iot cloud plus it's also defined the two floats that we've just defined to Cloud variables and it's ready for us to add our own code now we can work on it over here in this editor or we can click here to open the full editor which will bring you up the Arduino web editor which is a nicer way to edit things so we're going to do that and we're going to add our own code to this as well so I've opened up the web editor which is an easier way to work with the sketches that you're creating with the Arduino iot Cloud I should mention there's also a third way of doing this if you have IDE 2.0 you can go into your Sketchbook location and you'll see all of your iot Cloud sketches you need to pull the sketches down you can work on them and then you need to push them back up to the cloud it's not Dynamic so you have a number of different ways of working with the sketches now you'll see there's actually four files over here there's the main file and that's the one we're going to be concerning ourselves with there's a readme file and this is just a template for a readme file that you can create yourself to give details about the project to give the parts that you're going to need etc etc so you can edit that if you wish for the projects you make now things properties is one that you shouldn't edit at all it's created by the iot cloud it says here do not edit it and it has a number of parameters over here and including the two different Cloud variables that we've created and the fourth one is a secret file and I'm not going to show it to you because it's a secret file it has your web identification your network identification excuse me so your SSID and password and it also has that secret key inside it so leave that file alone and we'll go back to the main file now a lot of this was generated by the iot cloud itself this whole beginning bit was and it tells you the two variables the two Cloud variables that we're going to be using in here and it also included this itself thing properties and that's just this file over here that I showed you now this is code that I've added since we're using the ath20 sensor I've added the Adafruit library for that and I've defined the sensor and I've called it a8t and I've also defined two variables these are local variables to hold both the temperature and the humidity and there also floats now in set up a lot of this again was originally set up by the iot cloud so all of this first section over here for the serial monitor this has been set up by iot Cloud as was this and as was this and now we finally got to this section which I just basically copied out of the sample code that came with the library and it just starts the library it starts the object and prints out to the serial monitor that we found in the ht20 now we go into the loop and the only thing that was in the loop that they had given us when they generated the code is this and this has to stay at the top of your Loop otherwise this is the code that I've added and again most of this code came just from the sample uh code that came with the sensor so we create two sensor objects over here for humidity and temperature and we do a get event on each one so we can get fresh data into them then we print the results out to the serial Monitor and we're just using the serial monitor for testing in case this doesn't work for us and then we update our local variables and so these are the two variables that I defined read temp and read hum and we'll just update them with the current temperature and humidity values and then we pass those variables to our two Cloud variables and so every time we do that the cloud variables will get refreshed we delay for half a second then do everything all over again so it's actually a pretty simple sketch a lot of it again was written for us by the iot cloud now I've already gone through and uploaded the sketch to my uh Nano esp32 you can see it's connected over here now I will warn you when you do a confirmation and an upload the confirming part where it confirms the sketch it really takes a little while it's a lot a lot slower than the desktop based compiler so you just have to be patient and so it's been uploaded we can actually look at the serial monitor right now and we can see that I'm getting temperature and humidity data out of my sensor another thing we can check is that it has actually connected up to the Wi-Fi and it is broadcasting out to the cloud we can go back into the cloud over here and go and look at our Cloud variables and if you look at the variables you'll see that they have values and they're continually updating and those are the temperature and humidity values right now so we know that this seems to be working and our next step is going to be to build a dashboard so we can view this data Now to create a dashboard for our project we've gone to you guessed it the dashboards Tab and we're going to hit the create button and we come up with a new Untitled completely blank dashboard let's give it a title let's call it we'll call it that and now we can add some elements to our dashboard and we click over here and we can add widgets and things to the dashboard let's add some widgets to it now we're going to be displaying both temperature and humidity let's start with the temperature now there's a couple of things we can use we can use a value widget here to display the value a gauge over here is actually I think what we'll probably use and so we'll click on that and here's the configuration screen for our gauge now first we need to link the gauge to something this is only sample data over here it's not real data so we'll click the link variable and we'll go to our project and iot thermometers our project and this is going to be the temperature and so our Cloud variable is cell temp so we're going to link that variable to it and we'll link it and it's already getting the data from the variable now we can also change the range of that if we wanted to it goes from zero to a hundred and a hundred is a bit high it's not going up to the boiling point of water indoors I'm going to put that at about 40. and you can make whatever choice you like here and I'll say done to that and so now we have a gauge over here we can go back and edit the title a bit Etc we can do that in a moment but this let's add another widget over here and I saw one down over here below gauge that I think would do well for humidity so humidity is measured as a percentage we'll link that variable to the humidity and it can have an icon and I saw a nice icon here when I was looking in here before there you go a water drop icon and up over here let's change the name to humidity and we'll say done for that and there's the humidity now we can arrange these a bit if we like by drafting them out like this and we can say done and there's our temperature and humidity we can take a look at what it would look like on the mobile app by clicking over here and that's what it would look like we can go to the desktop we can also do a few other things I want to add a few things to this so let's just move this around say done to that we'll add some more stuff to it and what I want to add is a chart and we're going to link this to the same temperature variable that we did before because you can link more than one wood it's the same variable we'll call that temperature and we'll say done and let's just move this around a little bit something like this move you under here say done I'm going to add another widget you can probably guess where I'm going with this right now add a second chart and this time we'll link this to the humidity and we can say done and there we go we've got a pretty nice looking control panel right now we can get the temperature and the humidity we can also see historical data for temperature and humidity obviously we haven't been running long enough to get a lot of historical data but eventually that will populate itself and so you can see how quick it is that we can build an iot project with the Arduino iot cloud and a device like the Arduino Nano esp32 now of course there are things we could do in order to improve upon this project and actually a lot of you would probably rather see the temperature in fahrenheit than Celsius and we can add code for that we could also add a switch on here to switch between Fahrenheit and Celsius and if we do clicking the switch will create an event and it'll change the value of cloud variables we'll be using read write variables for that and we can use that to flip Celsius and Fahrenheit we could also put some code in over here here to limit this down to perhaps one decimal point so it doesn't keep dancing around there's a lot of ways we can improve it but I think you can see that for Rapid application development the Arduino iot cloud and a device like the Arduino Nano esp32 are a pretty winning combination now for the final demonstration of our project I want to show you that I've disconnected the Arduino Nano esp32 so there's no longer a USBC cable here and I've connected it to a nine volt battery onto the v in pin and I'm running it with that and you can see that I'm still getting my temperature and humidity data and so that proves out that we could run this as a remote device pretty well anywhere another thing I wanted to show you if we move over to the Arduino web editor you can see over here the connection to my Nano esp32 has now changed it is now over the air instead of connected directly to a USB port and that means that I could update this code if I wanted to and send it up to the Nano esp32 without having to connect it back up to the USBC connector and so that's a pretty cool feature as well so as you can see once again the Arduino Nano esp32 and the Arduino iot Cloud make building iot it looks really quite simple now the Arduino Nano esp32 is certainly an interesting addition to the Arduino Nano family although there were a few things I have to confess that surprised me when I got the board and started reading the literature about it what surprised me is that there are some features of the esp32 that Arduino hasn't documented in their literature although they could very likely still be there and be used they simply haven't put them in the documentation some of those features for example are the fact that the esp32 has two digital to analog converters yet there's no mention of those in the Arduino documentation the esp32 can also do I squared s that is mentioned in one of the spec sheets but there is no other mention of it anywhere that I've been able to find yet and the esp32 can use several of its inputs as touch inputs and again I don't see any information about that in the Arduino documentation however to be fair this product has this been released and sure the documentation will continue to be up updated this is an inexpensive board and it's a great introduction to iot and to micro Python and as I mentioned earlier I'm going to be doing more Arduino iot Cloud projects and I'm definitely going to be using this board for a few of them now if you want some more information about the Arduino Nano esp32 you can find it in the article that accompanies this video on the dronebotworkshop.com website and you'll find the link to that article right below the video while you're on the website if you haven't yet please sign up for my newsletter not a sales letter just something I send out every now and then to let you know what's going on here in the workshop if you want to discuss this board the dronebot workshop forums is a great place to do it you'll find a lot of like-minded individuals who can help you out with your electronic projects or who just like to talk about electronics and of course it's free to sign up for the Forum and while you're in the signing up mood if you haven't done it yet please subscribe to the YouTube channel it's very easy to do all you have to do is hit that red subscribe button and also click on that Bell notification and assuming you've enabled notifications in your web browser you'll get notified every time that I make a new video so until we meet the next time please take good care of yourself please stay safe out there and I will see you soon here in the dronebot workshop goodbye for now bye [Music]
Info
Channel: DroneBot Workshop
Views: 141,333
Rating: undefined out of 5
Keywords: arduino nano esp32, arduino nano, esp32-s3, micropython arduino nano, arduino iot cloud, arduino tutorial, dronebot workshop arduino, iot, arduino
Id: R51tf66es9w
Channel Id: undefined
Length: 57min 42sec (3462 seconds)
Published: Sun Aug 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.