#33 ESP8266 WiFi Web Server, Arduino style – Introduction

and welcome back now today I’ve got a very strong longing for something remote controlled or at least communicated by remote control so I’m looking at an rfid reader a we must wife web board which I’ve had for so long that they’ve actually brought out a new revision for this now this is the r1 and there’s an r2 I’m not quite sure what the differences are yet but I’ll be looking into that basically this is an Arduino type board it hasn’t got a an AVR chip on it at all it’s got the esp8266 ence but you can still compile to it and everything else once you’ve installed all the relevant drivers so I’ll be looking at that while I was doing that I also got a color brother esp8266 bits now this this one let’s get the right bits together this is a module that’s quite commonly used in not binos it’s just the the chip itself that you’re supposed to then solder on here like they are bleed so you’re supposed to place this on here line it all up and then just solder it on like that and then put your pins in here and attach to it but then I just happen to spot and this little board which was very cheap and they say caters for lots of ESP modules look and this is a this is a 12v anyway this this solders in there just the same way as the other one and same similar fashion but then they give you or man all the pins come out down the bottom and they give you this right angled header you put it into there and solder up and then that can plug into your breadboard or whatever for playing about it and I think now that’d be ideal for I want and when we know it’s all working everything else I can just get another one of these modules and perhaps solder it on to the and then use that in the project now the reason I got that is because I realized after a while that this wasn’t particularly standard and I’ve had this now for several months and the minute I got it I was fired up turned it into a server connected it to a time computer what do they call it an NTC is it any way to see if you had work I did the the absolutely essential turn and led off and on viral web browsers on this now work just absolutely fine and that was all on Christmas Eve that I did that then I just put it to one side and first about with a few more bits and then forgot about it so I think I’m tempted to get this out and try it once I’ve added look at what the difference is between the r1 and they are two because everybody on the Arduino forum loves to do things with remote control Wi-Fi or something like that so this would be ideal I’m also very tempted to give this our RFID reader running and this is just a couple of other oh yes one thing you have to know about this RFID reader this is a my fare type breeder now this is a no it doesn’t actually tell me the frequency I know it’s some several megahertz though this is the fixed standard frequency that we use for all RF IDs in fact there are three frequencies for RF IDs there’s the low frequency which is something like I think it’s around about 135 kilohertz and that’s used in industrial applications this one though is a thirteen point five six megahertz and that’s just about every card you’re going to get in a in a hobbyist type realm and then they do another one for RF IDs it’s ultra high frequency at something like 850 to 900 and 60 megahertz now the old high frequency ones have a massive advantage over over this one in as much that the range is much bigger so whereas the range on here you can probably think well if you get it to win and about two centimeters something like that but the UHF one it says the the range unlike this one which is about a couple of centimeters or thereabout so if there is the four you can get that wind about there and that’ll read it we’ve used these at work in fact we’ve given cards just like this and we have to swipe in again something some of them you have to go right up to it almost touch obviously they’re in a plastic housing because the lifter you know touch them more or less like that and there’s a couple you can go about that far away but that’s about it now the ultra-high frequency ones that

can work a metre or more away and I’m guessing they’re the ones they use in places like well there’s a costco warehouse near i live and a Christmas when things get really really busy they take a traders trolley and just run this huge scanner over it and it just picks up everything but they’re not doing it you know within a couple of centimeters they’re doing it well from at least thirty centimeters a foot away probably double that in fact and then just giving him the bill at end of it so obviously reads every single RFID tag on the trolley which is amazing but I guess it’s not ready for mainstream supermarket use just yet anyway we won’t be concentrating on the on driving c1 because I couldn’t possibly afford to buy one and they’re not generally available to hobbyists so we’ll concentrate on this of ubiquitous one and just get this set up but what was gonna say is that these this is a three point three board and you can’t therefore use that with a standard uno without doing something to adjust the levels now luckily in my little kit I’ve got these level adjusters there’s this one here does it say anything no but it is it’s a level adjuster now this one here I have another one somewhere here we up there’s this one as well one of these possibly both is bi-directional so it’s three point three and one end five or what’s out of the other and the signals can go both ways whether it’s this one here or this one here I’m not sure I’m gonna have to look it up to see where I bought it from the other one whichever one it is it’s just a single duration now the thing about RFID readers of course is that not only do you want to read RF IDs from the Forbes and cards ideally you want to write to them as well so that if they’re compromised you can change it so I want to get this working to reads and writes to this fob let’s hope we don’t make any mistakes because I’ve only got one fob normally these come in packs of like five or something but this was particularly cheap on eBay so just snap afford one well we’ve got two anyway I got a card and a fob so we got two okay what else there’s one other little thing if anybody’s been following my load cell coffee coaster which is this thing here which will recognize and it’s flashing away still now the day after I finished my last video the poultra byte LEDs arrived look so I’ve got red yellow hyper bright and super bright and they were ready nearly so one of these is gonna find its way into here and I’ll do all that over the next so nine to three months sorry days and get back to you and the other thing that I found if you notice look this Cable has got this sort of magnetic thing on here here’s a spare one so you I bought this from banggood as a sort of way of maintaining your cables you unclip this bit here it’s quite tight there we are so you open that up clamp your cable in there now it’s got this all star making as a so case you could clamp it in any direction but well I’ve only clamped it straight up so you clamp your cable in there that’s a magnet and then that fits on a little magnetic sticky device that I’ve got but you won’t bear to see very well it’s actually under there it’s that blue line this thing here the individual little magnets once they attached our cable just stick under here to hold your cables securely so if I can demonstrate with the one law did have plugged into my coffee cup so that goes under there like that just off hangs on there just keeps them off the desk and out of the way the other thing if you can just see at the back there might better zoom in a little tiny bit that that is also a cable management systems a little bit messy at the minute but the idea is that your cables if you didn’t have the magnetic ones go through then and as they fall back which this one’s absolutely refusing to do now it gets stopped by the actual plug itself now this one’s being stopped by the magnet but this plug this is a micro still doesn’t fit through this little tiny slot so that keeps the cables from disappearing down the back of my desk which I found pretty useful I’ve got two of those one at each hand very difficult to film though because the cameras on a on a moveable tripod not free-ranging so that’s on BAM good I’ll drop in a picture first of all I’m gonna have a sip of my afternoon Zinfandel wine thank you very much hmm dry mouth that’s what it is that’s

my excuse and I’m sticking to it right I’m gonna look up the difference between B 1 and B 2 and as I’ve already got a sketch for this which we might better say let’s go into my code window oh well you got it twice there now because he thinks one’s the debug window we’ll come to that and then we see about the v1 and v2 changes awful you would expect there to be some improvements otherwise there wouldn’t be any need for v2 one thing I did read I think on the we must forum is that the pinna arrangement is different which unless strikes me as particularly bizarre they’re only if you’ve managed to generate some sort of shield for this one then you couldn’t use it on the next one which is for recipe for disaster isn’t it let’s get that we must be one Wi-Fi module load it up and have a look at some very simple code again and we’re back now the last board I was going on about was this one here and I was can this board d1 this and this board d-von that it’s only one that looks at the 50 hell afterwards I suddenly thought Oh Pooh that wasn’t a d1 that was an ESP tween I mean it says it big enough on there I was actually referred to this board here which is a d1 Wi-Fi and this is the release one of which there now is a release – so this is superseded but not not enough to make us worry about what’s going on here so I’m going to show you both really because the D 1 r2 is actually reasonably well thought of in the we must community and the ESP do we know frankly looks almost like a clone sort of not quite it’s not quite as a little clone these pins you see across the top here are close but not the same as this and the pins as specified on here are most definitely not what you might expect it’s not like do you know if every time side down that way around you can see the GPIO pins here and there’s a sort of a translation required to translate those into these top ones and find out exactly which pin is working so you’ve got only a limited number of pins on any we must I bought this one and that one specifically you’ve only got one analog look a zero same as that one there so you go up to a zero and the other one says NC not connected well okay well that’s not a concern for me at the moment the other thing is this is the 3.3 board so this could in fact connect quite happily to that that Tamar F ID fobs that I mentioned that was the 3.3 volts but I won’t I mean I’m just mentioning it as a bit of interest don’t connect up any 5 volt peripherals to this but it’s not peripherals were interested in really what we really want is to get this thing installed and running so it was fun and games really getting the the d1 and the ESP do we know sorted out but luckily for you I’ve got all the links and everything I’m gonna put all this in the comments below this video okay so if you’re watching it now it’s somewhere below this video here in the comments or in the information section and there’ll be some links to the PDFs that you’ll probably need and the library so I’ve got all that so if we look at the browser window so this is the installation of the ESP do we know so that’s this one here okay and that’s um it it’s fairly straightforward I mean I did have the Chinese one just begin with so that was real funny game so if I don’t manage to dig out this English run that’s the 10th of January 2016 so you can say it’s um you know it’s a current board everything was fine I mean the drivers for the 3ch 340 serial port we’re already there and it says the first thing now you need to know this this is the these are the parameters you need to select in the tools for the board we’re going to then just a sec look at this just look flash size four megabytes megabytes I’ll say that again slowly the flash on this board is four megabytes now she asked before you get too excited you’ll see that the blink program which is probably about 20 bytes I suppose in real terms actually takes up about 200k however that notwithstanding this is still one huge leap up and also of course look at this bit here 80 megahertz processor so it really is a much more powerful bore than

you know okay well it tells you a few things about how to upload things it says put the blink program on so well let’s try that first of all that whether it’s the air speed we know or the d1 I mean it’s pretty much the same so let’s go onto that code now this is my big Wi-Fi thing but I don’t want to do that first of all so this is the code window for the link which is pretty tiny what we’re gonna do now is go to the board’s tools there’s the board that we need to select but I’ll show you where it is so in here look it says he espied we know ESP 13 module now ESP modules have increased over the years so just make sure you pick the right one now have a little bit lower down you’ll see here we are look we must D one retired that’s the other one I’ve got the r2 is now the preferred one by I’ve got an r2 so we won’t go into that and we’re gonna do it on the ESP we know model module because that’s what I just happened to have it’s 80 megahertz oh look it could go 216 well some variants but we’re using 80 flash size 4 megabytes I don’t know a 3m espe or FF s stands for but the only other option is the 1 Meg don’t know anyway it’s for Meg upload speed 115 K 1 point 2 K and the port is of course depending on your machine over anyway yeah so as you can see I’ve got a number of things attached to the moment that one there where it says comm 60 and that’s the disabled port remember for my video switching touch since they’re kept on one a networking become 18 is the one we’re looking at at the moment for this link and the comm 5 that’s in fact my we must be one also attached now waiting for us to use that’s in a little while right thank you very much so now it says this is where the following game lies let’s come back to the code window again now what it says is for this board in that PDF which you’ve probably downloaded by now hope this is to upload here there are two buttons there once there’s rst and once is flesh and what you’ve got to do you see there lights on here the minute whoo all the noise mean but we have to hold down the flash button and the reset button for six seconds so flash first it says so hold down flash now the reset well so something happened there look it says for six seconds and now you can upload well okay it’s about six seconds listen I go just his warning mm-hmm okay well soon know if it’s worked or not when the uploading here is finished because all we’re gonna get is a blinking LED we hope done uploading is is fine what’s the LED do oh there it goes yes I think that is the standard blink frequencies in it one second on one second off okay so what we’ve established now is that the board’s themselves both this one and the d1 have all been installed correctly so now we can actually do something more meaningful with it so I want to go back to the d1 now because that’s what I know is gonna work and have a look at the other code though I am bill I know a few months back now so let me just find that code this is the Wi-Fi so that’s that one as you can see I’ve already uploaded it once just to make sure we’re still working in fact I think it probably was on this board anyway cuz I’ve got nothing else to test with it so what about this code then well basically you have to include this library but that happened automatically once that installed the boards via the board manager so if we look at file preferences now this is this place here is where you specify additional boards so you click on this little button here and you type them in one line at a time we’ll paste them in because most of these sites give you the code so this first one you can forget this is all about spark fumbles or some balloons and work on and if you’ve watched in my previous videos you would have seen that I’ve been using the spark fun but this is the one here look this is the interesting one so it’s Arduino esp8266 calm stable package esp8266 calm index Jason so that’s what you’ll find I’ll put a link down below where you can find all this so I haven’t got that in here you can then go to tools board if you go right

to the top boards manager now in here what this is now doing is downloading all the descriptions of the boards that you could possibly install now course Arduino boards as you can see here is already installed but if we go a bit further down there we are ESP eight two six six by the esp8266 community that’s installed because I’ve already done it but you could install a different version or remove it well on me on my machine here that said install so I did and lonely old installed and then this library magically was available so I haven’t even looked to see whether it’s put it into the libraries where it where he’s put it well this is a different place but it worked now that’s my SSID there is B this is obviously our SB play on my name and this code here basically what it’s saying is going connect to the Wi-Fi that you’ve specified and you’ll excuse me if I don’t actually show you my password for that who knows you should be listening in hey let me go back to the code windows think it’s probably easier there out right so we say go and connect to that SSI days of what this is what this is doing what it’s not connecting your printer dot and it says I’m connected this is all standard code that I’m guessing I’ve obviously taken from the internet somewhere perhaps it was the same website when it had this library but I’ll put a link to all this as well so you can play without there it then comes back and says because I’m connecting as a server which I think I’ve specified somewhere yeah Wi-Fi server here and that’s what your terms where there’s a server a client so basically this board is going to give out webpages so you connect to it from your browser to it and it will serve up webpages big clunky but it works so having got itself a server address from your Wi-Fi it then displays more layers so you know how to connect and then this bit here I’m not going to go into all basically turns on the built-in LEDs here that le blue LED there blue white to you on the camera that’s the one that’s going to go on and off according to this now as you can see these these print lines climbed up dot print line these are quite important especially this one here even mentions in don’t forget that blank line after you’ve given out the header this header here so you must have that and so I’ve left it all in and there’s a title okay there’s a star like I’ve probably changed some of this since it came down as that’s what I do for a living cream web pages so I just made it slightly easier and then you click a button on the page let’s fire this up on the browser so do you get an idea of what’s happening as you can see I’ve somehow it’s changed the the comp or here was calm eighteen quite happily then he decided no commenting wasn’t up I think it’s because I’ve had to code winners open at the same time both connected to calm eighteen and things get totally convoluted you wouldn’t normally do that when you’re doing it as part of this sort of video really right so I’ve got calm eighteen debug window open now and I’m hoping that says you’re gonna display something when or resent this well there we are now it’s connecting to my Wi-Fi all look at that look that was quick so now it’s saying this is the address to use to connect to this board so this is now waiting for me to connect on my browser so let’s switch back to the browser window and actually try that so that’s one nine two one six eight 2.12 I’m pretty sure I’ve used that before twelve there we are so we’ve we’re on we’ve connected so we’re seeing everything now so here’s the browser connected and this here is the debug window from that as you can see as we connected it says although we’re connected and didn’t do anything they’re never here right so now I’ve got my camera pointed to this what we’re hoping is that this led here which isn’t pin 13 mother ways that’s why you’ve got me really careful when you’re looking at the code it says built-in LED right so here we are as soon as I opened up the browser we start getting messages here about a new client it does it stuff wait some something an incest client disconnected so fight the LEDs on at the moment I’ll just bring them really closing so that’s on so if I come up here and say off there we are off it is and then it just waits no we’re to click again on again now you might say well hang on it you’re connected by this USB to your computer I mean how about

freestanding well yes I thought that so what I’ve got here is my power pack this is a kid from one of my video tutorials here so this is a standalone 18 650 rechargeable practice what we’re gonna do is disconnect that now so of course soon as I disconnect this we will not get any more information on here because it was obviously not connected anymore but we still see the browser windows so let’s flip over to the browser we’ll disconnect this and connect it to the power station right power station is on 93% as you see right so we’re now connected well we hope we’re connected the LED light is on and I’m now gonna say turn it off and lo and behold and you saw there the page refreshed and this said off so if we click the on again on and the page refresh slightly slowly and on it says now that is about a similar to yet with Wi-Fi so this is a standalone board now connected only to this power pack to my computer so it’s just sitting there waiting for commands it says well I’m a server I’m on this address come and connect me and of course what happens when you do connect well that’s entirely up to you but the fact you we’ve managed to turn this little idiot LED on and off which is quite fascinating isn’t it turn it on well I think we’ve lost the connection we got played about too much oh dear disaster you know why the LED is off because my power bank despite its a swishy off perhaps I’ll press that button or something all right let’s turn that back on the on button yes right okay we’re back in business we’re on this is initializing so I’m hoping just by sending that frankly you should turn it off should know let’s send that oh the light went off the page is refreshed and we’re back in business so now let’s turn it back on they well here’s all and the page refreshes now let’s take the page refreshes what it means is of course is this is sending out information to your browser all right that your browser then interprets as this web page as the commands to display something on the screen now if you’re not familiar with HTML here’s your chance let’s all get involved a little bit and just do some simple things because you don’t need a lot of HTML to turn a few things on or off on here and or to read the value so it’ll be useful to look at the codes and it’s whizzed back to the code window and just have a quick look so the bits I wanted to show you quite frankly was a little bit further down having connected and it tells us all the IP address so in the loop here we’re saying look have we are we connected or not and we assume we are now it’s waiting until we send some data that’s us pressing the send button and saying I’m sending you something down the line via Wi-Fi so it reads it until we get the /r which is carriage return as returned T’s tab what else you got flush means just flush that buffer make sure there’s nothing stuck in that buffer now what we’re really doing here is we’re reading the actual URL coming in so I’m saying on that request and this is a very quick and dirty way to doing it but it serves that purpose can I see slash led who’s on if we can just look at the browser for a second so I mean there’s this bit up at the top here you see this bit here so it’s looking for everything after the address to say is it on or is it off now so they’re clicking these pins I could quite easily right so we’re gonna say off now I’m gonna hit return so this is all of the minute so I’m not clicking a button I’m just sending that that’s string this string here down the line and as you saw there it’s gone off and it’s refresh the page so back to the code window so it’s looking at that parameter I suppose you could call it on in the code window looking for amateur and just setting the LED high and little deter bits off then it sets it off and of course it then does write the correct value to the LED pin now just a word of

warning all ESP boards have got a reverse output so when we want the LED on we have to say well what I’m doing here saying set it to the value it’s not currently set because it should be set here to a low value and deter when work when it’s off which would normally set it to a low value and as you see have been playing about really we could have set it to a high value because high as off and low as on but here I’m just saying set it to why the value 8 isn’t at the moment now to serve up that page was just a couple of lines this is what the HTML language looks like play about with this by all means but some things you do need like that blank line after the header it’s just a convention of HTTP protocol what else okay these this is the little links you can click on that page as anchor as my layers but as we’ll go into some HTML programming a little bit later on one of forget out a use for this and then finally it says I’m disconnected right there we are so that’s that’s some d1 the ESP do we know works the same way but I’ve got to upload for this yet is it’s trickier with these pins but I’m definitely gonna do that next step would be to get this module here soldered up so we can play about on the breadboard a bit more with the standard uno rather than one of these boards so that your Uno can then connect one of these and send some data across the airwaves so that’s for a future projects in the meantime this gives you a flavor of what to do and it’s getting the setup correct that’s probably the biggest hurdle Bob put as much information as I can in the video down below the links to how to set it out the boards and anything else I can find it took probably took me I don’t know an hour in total to get my d1 sorted out and then this one as well but for you it should probably take about fifteen minutes with the correct documentation to hand so I’m gonna do that for you and thanks for watching see you in the next video I hope you’re finding these videos interesting and useful you can leave comments down below and also click that little button that says subscribe ok thanks for watching and see you in the next video