Arduino GIGA WiFi - First Look

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we're taking a first look at the new Arduino Giga we'll learn about the unique features of this microcontroller including its 16-bit a to d converters USB a connector and real-time clock will also build a waveform generator using the giga's 12-bit digital to analog converters it's the most powerful Arduino yet so welcome to the workshop foreign [Music] [Applause] well hello and welcome to the workshop and today we're going to be working with a brand new microcontroller board the Arduino Giga now the Arduino Giga is a large board that has the same form factor as the Arduino Mega 2560 and the Arduino do and it also has compatible pinouts but that is where the resemblance ends this is a board that doesn't have its Heritage in the Arduino AVR line of microcontrollers instead this board hails from the Arduino Pro Line and it uses the same processor that the Arduino partentia uses Arduino is calling this the most powerful Arduino board ever created and it certainly is a monster it has more i o ports than the Arduino Mega a total of 76 of them it has 16-bit analogs to digital converters 12-bit digital to analog converters it has an integrated real time clock and one of my favorite features is it has a USB a connector that you can connect external USB storage devices to you can connect keyboards or mice to it and you can use them within your Arduino programs it has a very powerful microcontroller probably the most powerful one we've ever seen in the workshop here it runs circles around things like the rp2040 or the esp32 it of course has Wi-Fi and Bluetooth as well now this board has so many features that even though this video is an hour long it would be impossible for me to cover all of them and there's no reason to really cover a lot of the standard features we all know how to Blink LEDs Drive Motors and read sensors so instead today what I'm going to do is I'm going to focus on some of the more unique aspects of the Arduino Giga and we're going to start off by learning a bit more about this amazing microcontroller the Giga is based around an stm32h7 processor and it includes both Wi-Fi and Bluetooth this large microcontroller board has a whopping 76 digital i o pins and 12 of those pins are capable of pulse width modulation it also has 14 analog inputs and it has a 16-bit analog to digital converter in addition there are two analog outputs in the form of two 12-bit dacs the onboard memory includes Ram Flash and sdram the Giga has an integrated real-time clock there are USBC USB 2.0 and a 3.5 millimeter audio connector on the board there are also connectors for a display and a camera this microcontroller has a number of different applications one obvious one is robotics where all of the i o ports and the power of the dual core processor will really come to advantage since it has the same form factor as the Arduino Mega it's a natural for 3D printing this board could be used to update and improve 3D printers to allow Wi-Fi and Bluetooth connectivity since the Giga can be used on the Arduino iot Cloud it's a natural board for iot projects it's 16-bit digital to analog converters would allow it to be used for audio processing and analyzing applications and of course this is pretty well the ultimate board for makers and hobbyists the Giga has the same form factor as the Arduino Mega and it has the same pin outs as well for this reason you can use accessories designed for both the mega and the Uno when prototyping with the Giga if you want to use some of your Arduino Shields they'll be very careful because the Giga is a 3.3 volt board and is not 5 volt tolerant now let's take a look at some of the connectors on the Giga board there's a USBC connector a USB 2.0 connector a 3.5 millimeter audio connector that is both for input and output there's a micro UFL connector for an antenna there is the same collection of i o ports that was available on the Arduino Mega and just like the mega there are a group of analog to digital converter inputs as well there are a number of power and reset pins and we'll take a closer look at a few of them in a few moments there are connections for uarts three connections for I squared C two DAC outputs and a can bus connection or at least the logic signals for a can bus connection you'll still need a transceiver to connect to a can bus there's another connector which has additional i o ports and can also be used for a DSi display a second connector can be used for more i o ports or for an rducam compatible camera the Giga has the same SPI connection that the Arduino Mega had it also has a JTAG connector so you can perform debugging operations and there are two switches on the Giga a reset button and another one labeled boot zero which we'll discuss in a few moments the Giga is based around the same processor used in a lot of high-end Arduino products the stm32h7 this is a dual core processor the first core is a 32-bit arm cortex M7 that has a dual Precision floating Point Unit and runs at a whopping 480 megahertz the second core is a 32-bit arm cortex M4 and it also has a floating Point Unit and operates at 240 megahertz both of the cores can run independently and it is even possible to run a micropython program on One Core while you run an Arduino C plus plus program on the other core this has amazing applications for example in robotics where you could use a C plus plus code to handle the sensors in the motor driving while you use the other core with a micro Python program to do the navigation logic Wi-Fi and Bluetooth capabilities are provided by a murata 1dx module the Giga has Wi-Fi capabilities up to 65 megabits per second it also supports Bluetooth low energy version 5. you should note however that with the current version of the Arduino IDE you'll only be able to use version 4. there are several sources of memory on the Giga board the stm3287 chip itself has two megabytes of internal Flash and one megabyte of ram there is also an additional chip with 16 megabytes of Flash and another one with eight megabytes of sdram the Giga has several Communications options there are four uarts three I squared C connections two SPI or serial peripheral interface connections and a can bus connection the Giga also has an ate cc608a chip for security and encryption purposes now let's take a closer look at a few of the connectors on the Arduino giga the USBC connector can be used to provide Power for the Giga it requires 5 volts in this configuration it can also be used to communicate with the computer so that we can program the device and use the serial monitor the Giga can also be used as a USB peripheral and that includes sharing out some of its memory that will appear as a thumb drive to a computer attached to it the Giga can also be used to emulate a mouse keyboard or other hid or human interface device such as a game controller the USB 2.0 connector is a type a connector and is used for connecting external devices such as thumb drives or ssds there are three pins on the side of the Giga labeled off ground and vrtc the off pin can be used as a power switch if this pin is set to ground the Giga will turn itself off the vrtc pin can be used to supply power to the real-time clock in the Giga this can be used to keep the real-time clock active even when there is no other power applied to the board in addition to taking power from the USBC connector you can also use the v in PID and the Giga has an internal Buck converter that will regulate its voltage you can apply from 6 to 24 volts DC to the VN pin there are two buttons on the Giga the first one is labeled boot zero this button can be used to perform a firmware update on the board you can also use this button in your own code and read its status there's a typical onboard LED common to all Arduino boards and it also can be used as a status indicator for the embed OS there's a reset button which of course resets the board and has also used in the reload process for the firmware the Giga has the 3.5 millimeter tip ring sleeve Jack this provides outputs for both DAC 0 and dac1 it also is connected directly to analog input A7 so you could use a microphone these connections are also available Elsewhere on the board there's also a connection for an antenna for Wi-Fi and ble and an antenna is included when you purchase the giga further down the board we'll see a camera interface this is a 20 pin interface compatible with RDU cam cameras if you're not using a camera you can also use these extra i o pins for your application and on the other side of the board there's an interface for a display that uses the display serial interface standard or DSi this is a 24-pin connector that again can also be used as additional i o ports and so now that we've seen all the connections on the Giga let's take one out and start working with it and here it is my new Arduino Giga and this is exactly how I received it in the Box mounted on a plastic frame which is kind of a nice thing to have for prototyping and of course you can take it off the frame when you want to use the Giga in its actual application now as you can see it's a very nicely made board here are all the connectors on the side the USBC the other USB Jack that can be used for like an SSD or a memory stick or something and this is an audio connector don't confuse that with the power connector on the older Arduino Mega and as you can see pretty well the same layout as the Arduino Mega as well now I've got a few other things here in the workbench with me including the remainder of the packaging the Box the stickers that come with it and the little antenna that they have and the antenna just hooks over here there's a little UFL connection over there for it and of course you could use another antenna if you had compatible connector now I've also got an Arduino Mega or at least a mega clone over here and we can put the two of these together and sort of see you can see indeed they are the same form factor and uh you know the same pin outs on these connectors anyway obviously the mega is missing a few of the connectors that they have on the Giga over here again though just be careful if you're going to put cards onto this such as the shields that you have for the Mega because this is a 3.3 volt device now the other thing I have over here are a couple of prototyping teals that were made for the Mega and these will actually fit onto the Giga as well so if you're just doing some prototyping and you want to do some simple subtle spreadboarding with it you can still make use of all the stuff that you had for the Arduino Mega and for that matter for the Arduino Uno if you're only interested in the pins down this level over here so there you go the brand new are we know Giga now let's start working with it okay I've just booted up my brand new Arduino Giga and as you can see the built-in LED is cycling through red green and blue and this is actually normal for a brand new Giga it just means it's a healthy board now this uh LED can also be used as a status indicator for the state of the embed OS and that's the operating system that holds the Arduino code and if it is flashing rapidly four times followed by flashing slowly four times and repeating that cycle that means that there's a problem with the embed OS and there are instructions on the Arduino website for fixing that but now that it seems that I have a healthy board let's go and write some code for it and watch it work now as I said at the beginning of the video this is a brand new microcontroller from Arduino and a lot of the software for this microcontroller is still in a development phase there are examples that Arduino provides in their excellent documentation however some of the code samples are taken from the portentia and don't quite work correctly with the Arduino Giga now I'm going to go through a number of code samples with you today a few of them I had to correct and you can get the corrected version on the article that accompanies this video in the dronebotworkshop.com website you can download them all over there but more importantly I want you to realize that this is in its infancy and this stuff is going to improve so don't judge the board on that I even had some difficulty setting the board up using Linux although it's set up correctly with Windows and so let me show you how I set up the board and how I resolve that Linux issue or run some example sketches and then we can start working with our new Arduino no giga now before we start using our Giga with the Arduino IDE we're going to need to install the board using the boards manager now I'm showing you IDE version 2 but you could also be using IDE version 1.8 it will work with either one but you do need to have a recent copy of the boards manager because the Giga board has only been added to the boards manager recently so just open up your boards manager and all you do is you simply type in giga and there it is the only entry the Arduino embed OS gigaborts by Arduino and with this hit install for that and that's all there is to it our board has now been installed in our boards manager now I'm sure a lot of you are looking at the screen right now and thinking is he really going to demonstrate this using the blink sketch when this microcontroller is so powerful but that's not why I have blink up right now what I want to illustrate is that under Linux I've got a bit of a problem using the Arduino Giga R1 and I want to show you what the problem is and then I'll show you how to repair the problems so I'm going to upload blink I've got my Giga connected and it compiles as you expect it would it goes to upload and here's our problem and first of all if you look at the board itself you can see that the led the onboard LED is actually just kind of pulsing green that's not the blink that I asked for it never uploaded anything and it's complaining about a dfu suffix signature dfu is the device firmware update and by the way that pulsing green means that this is in firmware update mode but it just hasn't completed it it wasn't able to do it because of this error message now I thought this might be a problem with this machine or with the 2.0 version of the Arduino IDE so I tried it with the same machine with the 1.8 version of the IDE I got the same problem I tried on a few other Linux machines all of them Ubuntu Linux mind you but the last two versions of Ubuntu and I still had the same problem and then I moved over to some windows machines and I'm able to upload it in Windows I can upload it in Windows 10 and in Windows 11 and in both of them I get a warning about this but it goes and proceeds and so I thought well I could do the demo in Windows but I really do want to fix this in Linux and so I've done a little bit of research and I think I figured a way to fix it out and I want to show you that right now now when I first received my error one of my first impulses was to go to the Arduino Forum because I figured if I'm getting this on every one of my Linux machines chances are there are other people who are as well and in the Arduino Forum in the hardware section they've got a section just for the Giga R1 and sure enough the very first topic or at least right now on the Forum is cannot blink at first attempt on gigabort and this is exactly the problem I'm having I'll go to the top of the thread here for you and you can see that this is the problem that we're getting the same one we have now interestingly enough there are people on this thread who also claim they're having a similar problem with Linux so sorry with Windows and I didn't have that problem with Windows I tried it on two windows 11 machines and a Windows 10 machine it worked fine but if you do have a problem this is a thread to head to and I'll leave a link to this thread in the article of the company's video now with the information here I was able to fix one of my other Linux machines and I created a each sheet of commands you can use with Linux to do that you can also get the cheat sheet on the dronebotworkshop.com website in the article accompanying the video and here's how the cheat sheet works it's a text file over here I'll show it to you big for a second so you can see so basically we need to close the Arduino IDE we need to open the file manager and navigate to this and open a terminal or you can open the terminal and go to there you're going to create a file and this is the name of the file we're going to create it's a rules file we're going to put these contents into the file we're going to save the file and then we are going to run a couple more commands afterwards and that could fix everything up so I've got my file manager open to the right place over here again you could open Terminal and just navigate to here it'd be the same thing I'm going to open up the terminal right now I will just make the terminal a bit smaller and we'll just have to jump back and forth so that I can see my my cheat sheet over here I apologize it's going to look a little bit odd okay so the first thing we're going to do is we're going to open up the Nano editor so I'm going to copy this let's just make this nice and big so we can see it I'm going to paste this into it and it's going to ask for a password because I'm doing a sudo and I do that note the password doesn't explain and the Nano editor is open ready to create a new file which it actually hasn't created yet this is just a buffer we have to write it out at the end okay so now let's just bring this up and see what it is I'm putting in the file and it's this line over here just one line that goes in my file so we'll move to the editor paste that line make sure we have the whole thing do enter and you'll notice at the bottom there's a control o to write it out so that actually writes it to the file so I'll do a control o it confirms the name of the file we hit enter it's written out and control X can exit okay now we're going to leave the terminal open because we have a couple of commands to run and uh so once we've done that there are two commands here's the first one it looks a little odd when I do that so I do it this way and you don't expect anything back by the way from either of those commands and there we go and you can actually exit out of the terminal right now and this is the point where we can open up the Arduino IDE and see if it works and we're back at the blink sketch right now after making our modifications let's see if we can upload it this time and it looks like it compiles which it always did and we got a brief warning but it did upload and if you look at the board you can see that indeed we are blinking the onboard LED let's go back up and see what that warning was now this is a warning again about the dfu suffix signature in a device for more update suffix signature and this is exactly what I get in Microsoft Windows I get this warning but then it continues so by doing the operation we just did with the rules file we seem to have gotten Linux at the same point and I really hope that Arduino addresses this in the next edition of the boards manager but now that we can get past this we can move on and start working with the Arduino giga now that we've got everything working we can start working with the Arduino Giga and when you install the Giga board it installs a number of example files that you can try so here they are examples for Arduino Giga R1 they have camera examples debug examples there's all sorts of examples a lot of these are taken from the Arduino portenta because it uses the same processor and has similar features and down over here is one that we're going to try out first and that's the Wi-Fi web client so let's go and take a look at that sketch right now now this is the Wi-Fi web client example sketch and it's actually a pretty simple sketch it uses the Wi-Fi library and it's fairly similar to sketches that you've seen using the Wi-Fi library with other processors like the esp32 now what the sketch is going to do is it's going to go out and connect to a website the website they're using is example.com an example.com is a real bona fide a website it's one that is used as an example you can use it for code testing you can also use it within literature if you just want to show what a website is now we start by including the Wi-Fi library and then we need the SSID and password for the network and we do that by using the second file here the Arduino Secrets file and we enter our SSID and password into that and you'll notice we included Arduino Secrets over here so it'll pick that up now down over here they show that you can go to example.com and you can place another domain in there if you wanted to to try scraping dronebotworkshop.com if you like you can also use an IP address instead and if you wish you can put a numeric IP address in here now note the format of the IP address it doesn't use periods in between the different dotted decimal places it uses commas so make sure that if you are going to use an IP you obey that format creates a client object and then just goes through setup we'll go right to the bottom first because there is a function here called print Wi-Fi status so it's going to print out things that gets like the SSID the IP address the signal strength again you've seen this before if you've used the Wi-Fi Library so we're back up here in the setup and setup we start a Serial monitor because that's where we're going to display the output we'll do the usual checking for the module we'll see if we're connected we'll connect with our SSID and password and if we're connected to Wi-Fi we'll call that print Wi-Fi status that we just looked at so that we can display some things on the screen and we'll print some more stuff on the screen the beginning of the HTTP page and then in the loop we go and print the rest of it over here so we just basically read everything from the client and write it out to the serial Monitor and that's going to be the raw HTML so let's load this up to our Arduino Giga and watch it in action okay it's all loaded up to the Giga and I've got my serial monitor open now I'm going to reset the Giga because everything went by so quickly I want to show you how it all works so you're going to see a disconnect and connect briefly so hit the reset and there we go we're in Connected now we're connected and attempting to connect to my network my Wi-Fi network and there we go there's the results and I'll scroll up so you can see them because as I said they go by pretty quickly so we connected the Wi-Fi we printed that out as you remember in the setup and then we called that function that displays the status of the Wi-Fi and we display the SSID the IP address it's the IP address I've been assigned and the signal strength which is very good but that's not a surprise because there's a repeater for the Wi-Fi right here in the workshop and then the rest of the setup was started connection to server we print all this stuff over here and then the rest of this is what we're actually scraping off of the web page so you can take a look and you can see the entire HTML of the example.com domain and everything inside there some style sheet stuff the body the actual text uh the rest of the HTML and it disconnected from the server at the very end so it does seem to work and it's one of several examples that come with the giggle when you install the board manager and you could run free through a few more of these examples if you wish and try them out with your Giga but we're going to move on and do some other things with this board so now that we have our Arduino Giga up and running and we can start exploring some of the more unique features of it and the first feature we will explore is the real time clock with its backup battery now in order to hook up the backup battery you're actually going to need to attack a connector to your board so get out your soldering iron I'll show you what it is we need to do and we can look at some code for using the real time clock in the Arduino giga before we move on to the code for the real-time clock I wanted to show you a slight modification that I've made to my Arduino Giga and it's really not much of a modification at all it's just over here I've soldered a three pin uh mail Dupont connector here and that'll be used to connect battery for the real-time clock it's also got another pin that can be used as an external on off switch for the Giga now for a battery I've got a couple of double a batteries and this is a real Overkill what you really need is a coin cell but I don't have any coin cell battery holders I have plenty of coin cells but none of the holders so I just put this together most of the coin cells I have are three volts and the Arduino documentation actually didn't specify the voltage so I assume three volts would be good now of course the Double A's are a complete Overkill could probably power the clock for five or ten years and the coin cell would be a better choice but it's a good choice for our experiments over here so I'm just going to attach that to the real time clock and the the RTC battery is on the very end over here in the ground in the center and so now that we're connected we can start doing some experiments with the real time clock in the Arduino giga now here's some code that we're going to be using with the real time clock and this was an example provided by Arduino on their website with some of the Giga documentation and it worked as advertised uh it starts off by including a couple of libraries for the time itself we Define a constant expression a print interval of 1000 that's going to be used as a time value for our print process and also we Define a function called print now over here now we're going to skip to set up and loop for a moment and look at this RTC set function because this is really what's happening over here we create a Time object called T and then we Define the parameters for T and so we have the seconds minutes hours the day the month and the year over here and the year is expressed as the number of years since 1900 so this one is preset to 2022 the 11th month November the 18th day so the 18th of November at of 1452 minutes so uh 1452 is the time that we're setting on the 11th of November now of course this is just a fixed time this is just a demonstration he would normally have a method of gathering the time settings and then applying them to the structured object over here at the end of it it just does a set time and it passes the structured object to it and so it sets up the time and this get local time is a function that's just been defined in order to print the time out to the serial Monitor and so the setup and loop become pretty simple in the setup we set up the serial Monitor and then call that ROTC set to set the time and then in the loop we just check to see if the milliseconds has elapsed more than print now and um if it has we'll go and we'll print what's on the system clock and then we go back and wait another thousand milliseconds and do it over and over again so let's go and load this up to the Arduino and there we go and now we can go into our serial monitor over here and we'll see that we've got the clock and it is as you expected set to the time and there's pretty well no surprises over here now I'm going to reset the Arduino and you'll see the serial monitor goes away for a while and then the time if you'll notice down here at the bottom of the serial monitor got reset again to the beginning of the time so it pretty well does what you expected every time that you reset this it is going to start at that time I can even pull the plug from the Arduino giga and we'll just basically delete what's in here right now plug it back in and it's going to start off again at its preset time so of course that's not too useful because every time that we started it's going to go to the same time so what we're going to do right now is do a little modification to this sketch now we've already loaded the clock up with our preset time let's go and just remark this out and then load the sketch up again so this is the exact same sketch except this time in this setup we're not going to go back and set the time and it's done uploading pop over to our serial monitor let's just clear the serial Monitor and you'll notice the time over here it's still incrementing it didn't go back to the original time and so we've got our sketch doing this right now now if I disconnect the Arduino from its power source we can see what's happened now of course we got nothing going on the serial monitor let's just remember the bottom time was 14 52 51. we'll clear that and I'll plug it back in over here and 145307 it kept the time and of course the reason it kept the time was because of the battery backup in order to prove that out let's just remove the battery backup for a second here and again I'll unplug it so there's no source of power right now and remember we've got a sketch that doesn't set the time when it starts off I'll plug it back in and the system clock has gone to 1970 0101 and for those of you who are familiar with the Unix time format that is basically the beginning of time according to Unix what a real time clock does is it counts the number of seconds the lapse since that date so this does seem to work the factory backup does indeed hold the time it won't hold it without it and as you can see the real time clock is a fairly simple thing to work with with the new Arduino giga now another method that you can use to set the time on the real time clock is to go out to the internet and grab the time from a network time protocol server and then of course you would have a very accurate time setting now this is a pretty common function in the sketch that Arduino has provided for this would have repeated over here is actually just a repeat of a sketch that's been around for quite some time you can see some of these dates down over here are about a decade since it was originally created because this is a pretty standard process the sketch starts off by including a few libraries and this is the only area that I had to modify from the Arduino code they had included the Arduino Secrets but they hadn't set it up over here to look at secret SSID and secret pass so I did that and included the second file over here as we did with the earlier sketch that contains both my SSID and password we open up a UDP port to get network time protocol we're going to pool.ntp.org and this will give us back a local time server based upon our location so that we get a very accurate signal if you want to you could change this line over here and use the IP address for the time server and that'll save you a little bit of time because it won't have to go to a DNS and resolve this but we're just going to keep back at this otherwise it sets up a few more parameters we go into the setup and in the setup we set up our serial monitor we connect to the Wi-Fi we wait for a connect and we wait quite some time for connection 10 seconds to make sure we have one and then print connected to Wi-Fi so we can expect a bit of a delay when we boot this up and then we call Print Wi-Fi status this is the exact same function down at the bottom over here that we saw earlier and then we'll go back up to the setup and then after that we do set ntp time set ntp time is a function down here that opens up the port and itself calls two different functions send ntp packet and parse ntp packet and these functions are defined below and basically what they do is send ntp packet sends the packet out in the correct format to the time server it waits a second and then parse is the one that's back so that it's a printable thing and so in the loop we basically do the same thing as we did before we just wait a second and we continually print the system clock which has now been updated through the ntp time server so let's load this up to our Arduino Giga and take a look at it in action on the serial monitor so we're looking at the serial Monitor and in order to show it to you from the start I have disconnected the Arduino so I am going to plug it back in and it could connect it says it's attempting to connect to my network now remember there's a 10 second delay at the beginning over here plus it has to go and resolve the DNS and make its first call to the time server so we'd expect a bit of a delay but it should start printing very soon there we go it's connected and it's giving me the system time and that is the correct time that's the correct time in UTC actually it's four hours off my current time as I'm on daylight savings time but as you can see it's a pretty solid sketch and it's a great way to set the clock on the Arduino giga now in my opinion one of the most amazing features of the Arduino Giga is the USB a port this is the port that would allow you to connect an external keyboard or mouse or USB storage device and use it within your Arduino sketches and that opens up a lot of possibilities we're going to work with the port right now and I'm going to use it with a USB thumb drive now before we begin though you need to have your USB storage device formatted correctly it has to be in FAT32 format it cannot be xfat or NTFS and so you'll need to format the device first you might have a problem formatting larger devices with FAT32 but there are utilities that will allow you to do that we've talked about some of these utilities when we worked with the Raspberry Pi and had a similar concern so get a drive formatted up with FAT32 throw some files onto it and we can begin working with external USB storage devices on the Arduino giga now for the next few experiments you're going to require a USB storage device and I've got a thumb drive that I have formatted with the FAT32 file system and that's very important it needs to be a fat 32 formatted device this is the contents of my USB drive which I have named USB now that doesn't sound very creative but the reason I named it USB is because the examples that Arduino provided assumed that your storage device would be named USB so it just makes things a lot simpler and as you can see I've got a few files on the drive right now I just wanted to show you that there's a text file called arduino.txt and then there are five different wav files and these are audio samples that I was playing with when I was playing with the digital to analog Converters on the board and we're not using these uh files at the moment but I just wanted to let you know that they are on the directory because that'll be relevant for our first experiment which we are going to do right now now the first USB port example we're going to use will be to list all of the files that are on the USB drive attached to the port which is why I just showed you the directory of them now this is some code which is provided by Arduino and it did work once I corrected a kind of a very funny error in it you'll need to include a library and the library is called Arduino underscore USB host embed 5. now the problem is if you go to the demo on the Arduino site at least if you go to it today they'll probably correct this eventually it'll only say USB host embed 5. there's no Arduino prefixing it and what happened is they actually changed the name of this library in mid-stream when I first got my gigabort and experimented with this it was called USB host embed 5 but then when they released the next version they changed the name of it and that sort of threw a loop for me I'll tell you but at any rate this this is the correct name of the library and this is also the library you'll need to install with your library manager and then after that we'll just go through the code now it's going to go to the fat file system of a drive called USB so if you didn't heed my warning about naming your drive USB you'll have to edit that and unfortunately they wrote uh let's not do that and unfortunately they wrote this code so that this was printed a few times in the code they didn't make it a variable so it's really just a basic demo at any rate we're gonna everything is done in the setup we'll set up the serial Monitor and then we enable the USB a port and the way we do that is to hold line PA 15 high so set it up as an output and hold it high and that enables the port so it's a very important thing to do and then while we have the serial Port open we print starting the USB duralist example we'll do a connection onto it and then we'll Mount the USB to device over here so assuming we get through here we've mounted the device we print down done and then we display the root directory and so the rest of this just basically navigates and explains the root directory again if you haven't called it USB you're going to need to change this over here so just name your drive USB it makes a lot easier we'll print out the root directory and then we will close the root directory and that's all done in the serial Port there's nothing done in the loop so let's load this up to the Arduino plugin our USB drive plug the Arduino back in and see what happens and so I have my Arduino Giga ready to go with a FAT32 formatted USB stick in the contents of which I just showed you and I'm going to plug in the USB and if we look at the serial monitor we get it amounts to USB device it opens the directory and you can see all of the names of the files that I showed you on my directory so this works and it allows us to read the contents of the directory of a USB device using our code on the Arduino giga so for our next demo we're going to use another code sample from Arduino and this one shows you how you can write a file to the USB drive once again the same caveat about the library you'll need to install this library with its new name and we're using a drive called USB so it starts off very similar as the other sketch did again we're doing pretty well everything in the setup we are going to enable the USB a port by doing this so you remember you always have to do that if you're using the USB port same setup essentially at the beginning will Mount the USB device and then we will go and we will write to it we're going to open a file called numbers.txt so that's the file that we're going to create and again the USB drive name is unfortunately buried in here so just name your drive USB and here's the actual command that does it it's an F open command we pass the name of the file we're opening which in this case is numbers.txt and the w plus means that we are writing it and we are appending to it if the file already exists and then we're going to just go through a for Loop and count from 0 to 10 and we will print those numbers out to the file and then after that we'll close the file and that's the whole program so really very simple it's going to create a file called numbers.txt and print out some numbers in that file so let's load it up and watch it work and once again I've loaded the code up to my Arduino Giga but I have it unplugged now so we can do the demo my USB stick is in here and so we will just plug this into the USBC there we go and as you can see it's on the serial monitor says that it has written the number of numbers out to it and it's file closed file closing and so it looks like it worked let's go and pull this USB stick out and make sure it actually did write a file and here's the directory of my USB stick and you'll notice I have a new file called numbers.txt and if I take a look at it in the text editor it is indeed the numbers 0 through 9. so the code appeared to work quite well and that can be a very handy thing being able to write to a text file on the USB stick you could use it to build some form of a Data Logger or a number of other different projects with your Arduino giga and the final file example that we have is of course reading a file from the USB stick and this once again was code that was provided by Arduino and it requires that Library the Arduino underscore USB host embed 5 and so you'll need to have that installed if you ran the last two programs you already do again we're going to a USB drive that we've named USB so make your life easier name your drive USB or you'll have the changes reference throughout the code the code is very similar to the right code in fact if you go down to it there really only is one big difference and it's down over here when we do a file open we're opening a file in this case the one called arduino.txt that's already on there and we're going to do a read instead of a write and that's the big difference over here is we're doing a read otherwise we're going to close the file and exit and nothing is being done in the loop it's all done in the setup and so I've loaded this already up to my Giga and so I'm going to open up my serial Monitor and I'm going to reset the giga and we'll wait a second while it resets and it should run and there we go we're starting the USB read file example mounts the device it opens the file and here's the content of the file it says welcome to the workshop and indeed that was the contents of the text file arduino.txt and then we close the file so as you've seen from this and the previous two examples we can list files on a USB drive we can read them and we can write to them and that's going to add a lot of Versatility into the programs that you create for your new Arduino giga now the next feature of the Arduino Giga that we're going to examine is the analog to digital converters now I know that's not unique to the Giga pretty well every microcontroller has analog the digital converters but these a to d converters are 16-bit high speed converters their audio quality analog to digital converters and when you use these in your code you use it a bit differently than you would with standard a to d converters now this is one of the few experiments we're doing today that's going to require an external component is the potentiometer and that system we can get an analog voltage that we can vary and experiment with so let me show you how we hook up the pot and then I'll show you how we can code for the 16-bit a to d converters in the Arduino Giga our experiment doesn't require very many parts in fact all you're going to need is the Arduino Giga and a potentiometer I'd recommend the linear pot of at least 10K or higher we'll begin by connecting the 3.3 volt output of the Arduino to one side of the potentiometer makes certain that you are plugged into the 3.3 volt and not the 5 volt output which is right next to it it will damage the a to d converters if you use the 5 volt output there were two pins marked ground and either one of them can be connected to the other end of the potentiometer and the analog a0 pin will be connected to the wiper of the pot and that's it that's the wiring now let's go and take a look at some code we can use with the 16-bit analog to digital converters in the Arduino giga now here's a sketch that we're going to be using with our analog to digital converters now generally when we use analog to digital converters you would expect that we would do an analog read and while analog read will indeed work there is a better solution for these 16-bit high performance converters and that is to use the Arduino Advanced analog library now you're going to need to install that Library so you can install that from your library manager after that it defined a pin for the analog to digital converter and created an object that we call adc1 for the pin which might be a bit confusing because we're actually using ADC 0 over here but just let's call it ADC one for the object we also have a variable that holds the value of the last millisecond reading and that's going to be because we're going to take the data put it into a buffer and read it out every millisecond okay now in setup we'll start the serial Monitor and here's where we set up the ADC and as you can see you can provide it with with a number of parameters including the resolution of it in our case we're going to do 16 bits the number of samples per channel the queue depth Etc and if it fails to start we'll print out over here otherwise if the ADC has started uh we end off the setup now there's a function called ADC print buff over here and this is where we take the data and put it into a buffer and then print it out so we take a look to see if the ADC the analog to digital convert is available we do a sample buffer and that's a data type and we call ours buff that's the name of our buffer and we will read the ADC so this is the equivalent of the analog read over here the ADC read and then we'll print the contents that buffer and then release the buffer so every time we call that we will print out what's inside the buffer and in the loop we're just basically going to call that every millisecond so we do kind of a loop over here in which we make sure we've had at least a millisecond elapsed between readings and we print those out to the serial Monitor and so it's a fairly simple sketch as I said it's different than using analog read but it has definite performance advantages with this 16-bit analog the digital converter let's load it up and take a look at it working all right so I've got my demonstration hooked up and you can see the serial monitor right now now let me move the pot to one extreme and that's the lower end and so we're getting a zero and I'll move it all the way up to the Other Extreme and 65 535 that's the maximum value you're going to get for 16 bits so as you can see you get an incredible resolution with a 16-bit analog to digital converter and of course if you really need analog Precision this is the type of thing to do now one thing I'll warn you about using 16 bits though is the inputs are very very sensitive so they're susceptible to noise Etc so if you don't need that resolution you could cut down the resolution but if you do need it or if you want to start working with audio work then using the advanced analog library and the a to d converter on the Arduino Giga is the way to go now the final experiment that we're going to do today with the Arduino Giga is to use its 12-bit DAC and we're going to use some code that Arduino provided to create a waveform generator now this waveform generator can generate square waves sine waves triangle waves and Sawtooth waves and you can also vary the frequency of the waveform and you control everything through the serial monitor using your keyboard so it's a fun experiment and it actually could be used as something practical if you wanted to modify it now in order to view these waveforms you're going to need to connect to the oscilloscope up to the output of your digital to analog converter so let me show you how you do that and then I'll show you the code that we can use to make waveforms with the Arduino giga now for this experiment you will of course require the Arduino Giga and you're going to need an oscilloscope so we can view the output waveforms that we're creating with our code connect the probe to the scope and then connect the ground of the probe to one of the Arduino ground connections connect the input of the scope probe to the Dax 0 output on the Arduino Giga and that's all there is to it now let's go and take a look at some code we can use to generate some waveforms using the digital to analog converter in the Arduino giga now the code that we're going to use has been provided by Arduino in their example codes and the code itself is actually perfect it only has one error in it and the error is right over here in the description it says on input on a12 or dac1 well a12 is actually Dax zero not DAC one but other than that it's fine so we're really going to DAC zero so everywhere with a reference stack one it's really Dax zero now once again we need the Arduino Advanced analog library for this if you didn't do the previous experiment with the analog to digital converter then you'll need to download that and we Define a couple of constants the number of samples that are going to be in every way form that's 256 and the default frequency which will be 16 kilohertz now we set up our DAC over here by creating an object which we're calling DAC one it's really the zero DAC on analog a12 which is also Dax zero well we set up a sample buffer with a certain number of samples and this is an array over here and we set the DAC frequency itself to the default frequency now this generate waveform function is actually the one that takes in the input from the keyboard in this code what we are going to do is provide a menu and the keyboard will be used to tell us what type of a waveform we want and also the arrays to lower the frequency so we look and if we get a letter T back then we'll do a triangle way the Q will do a square wave etc etc so for each one of these cases what we do is we first of all print out the type of waveform we're going to do and then we go and we fill up that array that we've had so we do this for a loop to the number of samples which in this case is 256. and we'll go and do a formula here which will create a triangle and we'll fill up the sample buffer with the triangle remember the sample buffer contains 1 complete waveform and for the square wave we do the same type of thing but it's a different formula same for a sine wave down over here and for a Sawtooth wave now if we want to raise or lower the frequency we use the plus or minus keys and if we see that in the case statement then we take a look make sure we haven't exceeded 64 kilohertz or gone below one kilohertz and we either multiply the frequency by 2 if it's a plus or divided by two if it's a minus and the final function in this in the case statement is a DAC stop which will stop the DAC after the end of the waveform and over here this the default there's an unknown command if you happen to press a letter in the keyboard that doesn't mean anything after that we'll print out the DAC frequency and we divide it by a thousand so we can display it in kilohertz now in the setup we set up the serial Monitor and we print out all of our commands so we can see them on the screen and then we call generate waveform which is the one we just showed you over here now here's how we initialize the DAC so this is the line that shows you how the DAC is initialized and we can initialize the resolution the default frequencies the number of samples Etc and then in the loop we just basically go and see if the serial Port has brought us a command and if it has brought us a command we call generate waveform and if the DAC is available we'll fill up a buffer this is the same type of thing you saw in the analog to digital converter we're going to use a buffer we will fill it up we'll write the data to the buffer and then we'll write the buffer out so the data and the buffer is going to be one-way form of the DAC sample so that's the code we're going to use let's upload it hook up the scope and make sure that we are actually generating waveforms in response to our keypad presses so I've got the Arduino hooked up to the scope right now and I've just booted it up and if you take a look at the serial monitor you can see him being asked to enter a command and it's giving me a number of commands I can enter with the keyboard to create a different type of a waveform as tell me at the bottom that I have a sine wave of 16 kilohertz being output right now and if you look at the oscilloscope we can confirm that there is a sine wave and if you can see the frequency reading at the bottom of the scope it is around 16 kilohertz so right now let's give it another command I have a t here I can give it for a triangle let's do that and as you can see we seem to have a triangle wave right now same frequency a square wave is a q so we'll do a Q and there's our Square wave a Sawtooth wave is an R and there's our Sawtooth wave that's pretty cool and uh we can go back to doing a sine wave with an S again now we can increase or decrease the frequency and if you remember the code this will either double or half the frequency so uh let's give it a uh a minus sign over here and we'll enter that and it tells it that the frequency is eight kilohertz and if you look at the scope the frequency has indeed dropped down to eight kilohertz and if I were to give it a Plus instead it'll bring the frequency back to 16 I can give it a plus again and we now have a 32 kilohertz wave going so this is a pretty cool little project it's uh obviously something you can build upon to make it even more functional waveform generator but it's a great demonstration of the accuracy of the 12-bit digital to analog converters in the Arduino giga now one feature of the Arduino Giga that I was not able to demonstrate to you today was the camera connection and it wasn't for lack of trying I bought a number of cameras from ardu Cam that can be used with this board and I followed the examples that Arduino provided but I cannot get it to work even though this particular camera here is the actual camera they use in their example and I've got two of them so I know I don't have any bad Hardware here I suspect the reason I can't get it to work is the fact that the library that I use is currently at version 0.002 and it's probably an alpha copy of something that was taken from the portentia and still needs some work to work with the Arduino Giga and you're going to find that with a lot of the code examples provided for this but that situation will improve this is an excellent piece of hardware and I think it has a lot of great applications I mentioned robotics earlier but one application that came to mind when I was using this was to use it in my water your garden with iot project where we use the Arduino Cloud to control things like moisture sensors and pumps and that well this board would be absolutely perfect for that with all of those i o sensors you could control a farm with this thing let alone a garden now I'll tell you this is not an inexpensive board although it's about half the price of the Arduino portentia it is still an expensive board to put it in perspective I could probably pick up about four or five expressive esp32 boards for the price of this one board but of course it's not a fair comparison this is much much more powerful than the esp32 and it has all these i o ports and additional features the esp32 does not have one feature it doesn't have that kind of surprised me though is it doesn't have an i Square s connection and it surprised me because it has these audio quality a to d converters it has a jack on it for audio you would think they would look at audio applications so the lack of I squared s was a bit confusing but otherwise it has a lot of great features and I think we can do a lot of great things with the Arduino gigabort now if you want some more information about the board or if you want to download the sketches I used today you'll find that on the article that accompanies this video on the dronebotworkshop.com website there's a 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 it's not a sales letter it's just my way of occasionally reaching out to you to let you know what's happening here in the workshop and of course it's free to sign up you could also join the dronebot workshop Forum where you can talk with a number of like-minded individuals about your electronic projects and get any help that you might need and finally while you're in the subscribing mood please subscribe to the YouTube channel if you haven't already I make videos about microcontrollers and Robotics and I'm sure they would interest you so all you need to do is to hit this little subscribe button that you'll find below the video and also click on that Bell notification and as long as you've enabled notifications in your web browser you'll get notified every time I make a new video so until we meet the next time please take care of yourself please stay safe enjoy your Arduino Giga if you have one and we'll see you again soon here in the dronebot workshop goodbye for now bye [Music]
Info
Channel: DroneBot Workshop
Views: 145,055
Rating: undefined out of 5
Keywords: arduino giga, arduino tutorial, dronebot workshop, arduino giga r1 wifi
Id: FsQ9kMp2GoY
Channel Id: undefined
Length: 61min 54sec (3714 seconds)
Published: Mon Mar 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.