EEVblog #998 - How To Program ESP8266 WiFi With Arduino

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi let's take a look at the esp8266 a very cool little Wi-Fi module chip that allows you to and basically add Wi-Fi into any project you've got for like a couple of bucks fantastic so let's take a look at it not only can you add it for a couple of bucks but it also now has add we know integration so you can actually program this thing which is not not we know but you can program it with the arduino ide and it's really incredibly simple to do so let's take a look at it because there's actually three different things going on here one is the actual chip which is under this metal thing here and that's made by a company called expressive and then there are these modules here which is the black module with the caste elations on there soldered onto a base board which is the third thing over here in this case it's a we must D One mini so there's three different things going on here so for the first part of this is the actual esp8266 chip itself and that's made by a company called expressive and yes you can just buy the chip and integrate that into your product but you know a lot of people don't do that because they're so cheap as I'll show in a minute and the module based things it's just easier to use the modules but if you're saving you know penny-pinching saving every cent integrating a real high quality product you could just use the Wi-Fi chip itself but then you've got to add the external antenna and a couple of external parts there it says that their minimum is 7 external component and it basically it uses a 32-bit 10 C Lea control micro in it it's a 16-bit RISC processor runs a real-time OS it's got a Wi-Fi stack and all that stuff to make it work it's got low power management although Wi-Fi is not hugely low-power so you can't run it from a coin cell for example that's why you do like something like that you use ble the loads of power are bluetooth and so it's basically the chip in there and we won't take a look at the datasheet and everything else so if we have a look at the Wikipedia page for the 80 to 66 you'll see that it comes generally on these little modules like this and if we have a look at these these are actually manufactured these modules are manufactured by a third party company called AI sinker and there's generally different ones and these are the most prevalent ones available everyone seems to be using these what we're going to the one we're going to look at today uses the ESP 12 F or 12s and it's got four Meg of flash memory in there I think it's 64 K of RAM and you can run applications on this process you don't need any other external micro or anything so it's more than just a Wi-Fi interface you can actually run applications and programs on this chip on this module it's fantastic so the next level out from that is people take these companies take these AI thinker modules and then they add them onto more useable boards because the the cast elation ones are great if you want to the cast elations are the small little cutouts circular half hole cutouts on the side that allow you to surface mount it onto your own board great for a high-volume product not so good for like one-off stuff and things like that so third-party companies make these boards that you know are to fruit do a Hazara and Ollie mechs do one and there's you know a whole bunch of them one we're going to look at today is the we mas d one mini the they sell a couple of different ones but it basically takes the ESP 12's module there and it puts it on a more usable board with the pins because this chip has the eighty 266 has up to 1600 pins and Scott urs and ADC interfaces and all sorts of stuff so it just basically breaks these out so this is a three level solution that we're playing with here and this is only like five or six dollars for the we must board I got it for like on eBay for nine bucks Australian from an Australian supplier delivered interestingly I think my seller actually gave me a dodgy like a fake one because it hasn't got the rounded corners it hasn't actually got we must written on it although that sort of advertised as so I think actually got a fake one so anyway we're going to use the we mas D 1 mini in our example today but just be aware that the esp8266 could be up to a three level solution like this the chip the module and then the board choose which one suits your purpose and these things are insanely cheap look at this Aliexpress for like a module based one that we've got here seventeen bucks for ten a dollar seventy each or you can just buy like the a I think of my choice self the ESP 12s that we're looking at here or the twelve F for eighteen dollars for ten a dollar a th just like think you can probably even get them cheap and that you know imagine what they you know get them cheaper in volume if you're manufacturing 10,000 items or Southern's just nuts and the we mas module we're looking at here comes in the pro version the mini and the light we just happen to have the mini they've got little display shields and all sorts of you know it was all sorts of variants on this so if we go in and have a look at the we must see one minute for US dollars from we must on Aliexpress for box insane and you've got to remember this is for box frame module that's not just a Wi-Fi module it's a complete processor with a DC's IO and everything you can run applications on this it's got four mega flash memory like 64 K of RAM or whatever it is and just amazing this is a complete solution for a Wi-Fi product you just hook sensors up to it and a battery and bam done so how do we program this wonderful little widget I'm glad you asked expressive ever released various our SDKs over the years and various these various tool change GCC and all that sort of stuff and you can get a basic version and Zed basic and all sorts of stuff but by far I think the probably the easiest way for any beginner to get involved with this is to use the Arduino environment so you can actually I get an Arduino plug-in for this that allows you to use the Arduino IDE no it's not another way no compatible board it doesn't use the app metal processor with it like nothing to do that they're just using the Arduino IDE and everything to make it easy and I'll show you how easy it actually is so what you want to do is go to the github repository for the esp8266 arduino environment and so hats off to the people who have written personal people who have written this and are involved in this project because it's absolutely fantastic doesn't have names there does it but yeah hats off to everyone involved in this because you'll see it's just great so what we do is we simply download this and we'll download this as a zip so we'll just download that zip it's not particularly big and we've got Arduino master zip there it is it's downloading done so what this is going to let us do is run Arduino sketches on this actual module so your regular Arduino environment that you used to when you go in here and go to boards like this after we install this we'll see it pop up as a board so just like any other board that will work with the Arduino environment okay so what we have to do is go into our Arduino environment here we've got the latest one one point eight point two I'm not sure which version has previously supported it but this one is going to work so you notice that we don't have anything in here like this so what we need to do is go into file preferences here and you'll notice that there's an additional boards manager URL and we just copy and paste this one from over here there it is dot JSON Arduino esp8266 etc we cut and paste that one in there and if you've already got multiple boards installed you just separate them with a comma like that so we should be ready to additional board manager URL done so now we simply go into tools and we go into a board manager over here and it's downloading downloading because it now has that new address that we've got and bingo these are all our additional boards arduino sam and we know nr f50 - intel i5 8 6 boards by Intel they've added added Intel Curie board all this sort of stuff so all these weird and wonderful boards that are Windows 10 IOT core and all that sort of stuff a lot of big-name companies like Intel and Microsoft and they'd have gotten onto this Arduino thing and produced boards that are compatible with the Arduino environment and here it is it's automatically listed this because we've put in that address and where it can get the information from esp8266 community we just want to install that so click on install it'll download all of the requisite stuff and you can see that this actually includes support for the art of fruit hazhar and all sorts of boards node MCU and the we mas board so there might be other boards out there that are not particularly supported by this they may still work in some way I'm not entirely sure I haven't tried them but this one definitely supports our we must board or where any of the other ones listed here no worries now we've got next 153 made to download modern software anyway it works the amount of capability you get you're damn right I'm going to download 150 yeah 3 Meg no worries installed let's go check it out so we'll close that down and we go into tools and we go into board and bingo there we have it SP 82 66 modules all the different supported ones including our we mas D 1 and our 1 mini awesome - easy but there's more one of the great things about this not only have we installed our board in there so it has all the support for it but it's also automatically installed all of the examples so what do we want of course we want a blinky there you go let's give it a go and there's our example code Oh too easy but of course this doesn't mean diddly-squat unless we program our board so let's plug it in this is plugging in for the first time and of course it's got all the USB to serial driver on the back and everything else and it's installing my device driver here we go search in search in usb-to-serial that will eventually pop up bingo we're in like Flynn ready to use on the comm 11 and we'll choose our comport here it is comm 11 so we'll choose that and we're ready to go are we yep we don't need to open the serial port we should just be able to compile this and run and upload so we've got our board set to the we must d1 mini we'll just leave everything as default flash sighs this has a four Meg I'll just leave it all hunky-dory port 11 let's go here we go compiling sketch could take a little bit because it's got lots of stuff to install it's got all the Wi-Fi stack and the whole kit and kaboodle so that's to be expected archiving builder built core sketch uses 22 222 k 21 percent of the program space for a legislature because it's got all of the Wi-Fi stack away blinky blinky it works whoo-hoo that's how easy it is to program an esp8266 in Arduino piece of cake just go back and look at the examples here just look at all these different examples DNS server stuff EEPROM stuff and we've got the regular blink with what we did our TC and you can make it into an AVR ISP programmer so you don't need to apply an AVR ISP programmer HTTP clients update updates HTTP update server mdns no idea what half this stuff is but it's awesome your own web servers as a holo server or your Wi-Fi our staff client moldy scanning Ethernet advanced chat server barometric pressure webserver like all these example files this is absolutely brilliant if you want to do some encryption hash stuff I guess as I said the SD card stuff you want to hook up an SD card to this piece of cake cereal that touchscreen stuff just brilliant thank you to everyone who's written all these examples and built this entire core it just makes it so easy so let's demo the Wi-Fi features of this thing shall we and by connecting to my our youtube channel to actually get my subscriber and view count from this thing so we can somebody's written that of course you don't have to write it from scratch so thank you very much Whitman witness me now who's written this Arduino YouTube API it's just on the github here and which should be able to get out our subscriber and view count and stuff like that and connect it's a good example that it's got to connect to the Wi-Fi connect through and so we can just simply download the zip for that and we can store that one too fantastic let's go so what we do is we simply go over to our sketch here include library and add a zip rot library like I said you don't have to unzip these things which is fantastic and we select the Arduino YouTube API master we open that and that Oh yep it's done library added Beauty so now if we go back to our examples we should have right down here examples from custom libraries this is great this is what I love about the Arduino environments now so polished that these things are so trivial to install and get run in for you know some idiot like me to actually do it channel statistics with Wi-Fi manager I don't think I need the Wi-Fi manager but here it is we've opened it up and shut down the other window there and that is all the code we need for actually connecting to the connecting tip while connecting to Wi-Fi the all the stuff we install before for the esp8266 or handles all that but this is all we need to connect so I need to get my API he and I need to get my channel ID I won't show you those at my Wi-Fi SSID and Wi-Fi password and it should just connect let's try it all right so let's give this a bill once first of all we need to open the serial monitor here if it pops up there we go we've got our serial monitor that's comm 11 and it looks like it's a hundred and fifteen k board here so we need to select that and we're good to go let's actually download this I've put in all my credentials up the top with my API key and stuff like that my youtube channel ID and Wi-Fi password so let's OH era compiling Oh Arduino JSON oops yep sorry I forgot about that so we go to the Arduino JSON github here thank you very much be blanchin so we'll download that and we'll install that once again just like we did for the previous YouTube API easy so we'll add the zip library again JSON master it is now library added to your libraries and we should now be able to compile that again and could take a while once again because it's got to compile a huge stack and everything else but there's not much code in here as you can see it like to connect to YouTube and get your stats it's pretty easy someone's done all the hard work for us Beauty we using 27% of our program space 40% 47% of our memory so it's still alright oops mm failed nope something went wrong what what what mwah so what I did is just rebuilt that we'll try the end I just went up there and simply Reeve Arif I compiled done compiling okay okay so yeah I'm not sure maybe I didn't install their library give it enough time I don't something like that anyway let's see if we can download shall we so it compiles okay so the problem is we programming the thing I'm not sure why this is looking good tada we're in like Flynn we've got some garbage come up but those dots yeah Wi-Fi connected there you go it could take a while to connect to the YouTube API but you can see it obviously connects to the Wi-Fi which is fantastic so the compile worked all the stack worked everything else is connected to the Internet and bingo it just took a bit I'm not sure why it took so long to pop up but there it is stats subscribe account yep fantastic that's all there is to program with the esp8266 even doing something to me that's really complicated because I'm not into the web programming you know side of things I can program embedded stuff all right but all this you know internet connected and JSON stuff and everything else a I'm clueless about but hey people have done all these examples I can work from the examples and compile these that's how easy it is so I hope you found that interesting and useful if you did please give it a big thumbs up and as always discuss it down below catch you next time
Info
Channel: EEVblog
Views: 376,042
Rating: undefined out of 5
Keywords: eevblog, video, youtube, esp8266, wemos, d1 mini, json, how to, tutorial, api, programming, module, wifi, arduino, code
Id: Q6NBnPfPhWE
Channel Id: undefined
Length: 19min 24sec (1164 seconds)
Published: Sun Jun 04 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.