#233 ESP32/Arduino IR🔴Fan Control - RESOLVED! 👍🎄❄️

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and welcome back yes now this is the follow-up video to the infrared saga that uh we did last week about why i couldn't get my wall fan to work using an infrared transmitted from san arduino or esp32 or something it just would not work so i asked for your help and it came in spades i want to do a shout out for pcb way now we all know about their five dollars for 10 pieces and their 30 dollar special offer for smt prototyping but what else have they got to offer remember they've got their 3d printing cnc machining but let's have a look at their big sales first and see what's going on there first of all we've got some coupons now these are valid for 90 days so now's your chance to go in there and get some of those now we all know about their five dollars for 10 pieces but look they've upgraded their material and here the pcb assembly and the advanced pcb and the rigid flex pcbs are all available with a discount now i mentioned the 3d printing and cnc machining look at the discounts on offer here 37 45 and 26 depending on the material used 3d printing has similar offers and so does sheet metal now did you know that pcb way has a store look you can buy all these things here look at that one on the left the six claw welding table i've got one of those i use it all the time and finally there's a lucky draw log in have a look around and see what there is available yes pcb way has got some big sales this december so why not check them out now yes indeed i got so many comments and so many suggestions obviously there was quite a bit of overlap between the suggestions but there were some themes running clear through those comments um the main theme was don't trust the library because i said i'd got my library that i'd found on the internet and it was in fact this one here and that seemed to um well it was all things to all men really i mean as you can see there it says uh 50 ir protocol supported yeah and 39 sending on receive it's you know it's a it's a big thing if you look at the code it's like whoa it's grown arms and legs and got a life of its own now and uh i did say in the last video i said well how do i know in fact that it actually is doing what it says it's going to do although it's saying yes i've detected what the code is from your original remote down here and i've told you what the codes are how do i actually know so i tried it on my bathroom heater didn't i write that which has an nec code it says and immediately it worked so i thought okay there's nothing wrong with the library okay let's have a i'll drop in a bit of video here to show you what the original code on the oscilloscope looks like so this one compared to what was being sent out using that library and yeah as many many of you said don't trust the library so what we have here then this is the trace that was being output by that infrared led from the library that uh identified it as a nubert protocol okay now what we want to do of course is compare this to what's being output by the actual remote control so what we'll do we'll take a a reference on this so if we press ref oh i don't want the help right okay i want to save this on the internal memory so save i think it's done it so we clear that memory right so now if i bring this wrong one this one up there we are so you can see that the white one is the reference is the one we've just captured right because what i want to do on channel one now the yellow case you see here is to now take the output from the actual remote control and compare them of course so here's the uh the real remote control yes i'm gonna aim that at the led receiver down here and press the same on button so let me just start it going there we are right so let's compare what we've got by moving things in position that's the end of the pulse there well i can't i can't actually make them match can i they're almost matching down if you look here they're matched here yes yes yes yes not bad um here though it's starting to get a bit out of sync isn't it you know it's this the the pulses here are longer than what the actual pulses are so the time you get here look the pulse is finished on the actual um proper remote control where this one's still going and basically if i move this down or move it up over the um the reference you'll see that they do not match i mean there's there's quite a discrepancy and that was the problem now another common theme that ran through the comments was go and get yourself a universal remote control a learning remote control and um see if that works so i bought this one here and this one was only um well less than 10 pounds about nine pound fifty actually from amazon it's a one for all which um well it does pretty much what it says it learns remote controls and um and also of course it's got a million and one uh remote controls that come with it so if you see this list here like from tv and there's mp3 players and you name it it does it right there are thousands well certainly hundreds i wouldn't be surprised if there's not thousands of codes on here right all for different tvs and mp3 players and dvd players and all the rest of it none of which of course i was in the slightest bit interested what i was interested in could this learn the code from here and if it could will it work because i thought if there's something weird and wonderful about this being sent out i'm really stuck and i did in fact take this apart as some of you suggested against my better judgment because i thought if i damage anything by taking this apart yeah sometimes they work sometimes they don't when you can get them apart but i've got some uh spudger tools as they're called they look like this hang on so i've got some various tools that look like this you know plastic little inserts that can go into the the gap between the case well the two parts of the case in there and i've got some metal ones all nicely rounded some of the sort of rounded points some of this this is very good i've got loads of these tools now and they they absolutely work you know for phones or remote controls mainly they work really well so i took this apart and there's two things i did on here one is i looked to see what the circuit was and all it is is one black blob you know round circular blob with all the tracks from these buttons going into it there's no components to be seen at all apart from the black blob which is some kind of um unique chip i guess i don't think there's a circuit under there but who can tell yeah so i couldn't do that but what i did do is put the um oscilloscope across the led here as well just to make sure that what this was sending out is what that library was telling me it sent out and it was it was it was true so okay that's fine so then i set this into learning mode press the on button this went flashy flashy and all the rest of it and it learnt the code and if i press this now you might actually hear the fans off at the moment so if i press this red button you might hear a little beep let's be very quiet listen for it they are hear that and my fan is in fact now on what else did i do oh yes i programmed the swing button you know so it swings backwards forwards with this this arrow here because it looked a bit like a swingy button so if i press that now i went beep again oh yes if you press this multiple times it just goes faster and slower and cycles through all the different speeds okay now i can't turn it off oh yes i've used the original one to turn it off cool so what did that prove to me that proved to me that this was nothing special it was sending out codes that could be easily identified by this and that believe it or not gave me a whole new lease of life about right if that 10 quid less than 10 quid remote control can learn those codes so can i so i started looking at the oscilloscope trace and thinking okay these are only mark space ratios with 12 different um bytes coming out i can start doing that so down the rabbit hole i went i was looking at this looking at that thinking okay how many microseconds of this do i just guess and you know or have a starting point long story short while i was doing all that i stumbled across another infrared remote control very very simple one but it was meant for the arduino and it's it's this one here what this one does it receives a code on that infrared receiver there and that three-legged infrared receiver by the way you can see it doesn't look like a diode it's actually three legs and it demodulates the infrared signal that is it takes out all the 38k modulation and just leaves you with the individual bytes it's it's very useful for us developers in the world because we don't necessarily want the raw data with all the 38k going up and down do we which is another thing i discovered incidentally when i put on the scope yes it said it's 38k coming out of here which is pretty standard so it receives the code on here and then it says right i'm sending it out now on this one over here and as you can see i've put a transistor in there just to sort of boost it up make sure it's getting the full five volts um the instant i did that the fan started up so i think yay got it except not quite because as you know this is going to be part of my workshop smart heater controller down there which you saw last week and i thought hang on i haven't got an arduino i'm using esp32s and if you look at the code behind here um it's talking about you know timer one timer two i think it uses timer two mainly on pin uh two and three and all that i think that's that's not gonna happen that code is not gonna compile on esp32 it doesn't know what it's doing but hang on i've used pwm on my smart heater controller already to control the the fading in and out of my lcd screen so i thought i know how to do that so this has given me the codes of what it detected and let me just show you those right so what you see here is the sketch running when it was running and it says um it says okay press the control button right that's a bit slow so set it again get on with it bacon that's what it's saying so i press it as quickly as i could just to get one burst out but i think here it got it's still got multiple repeats of that code at least one repeat so it sent out all these codes and that's basically it's in microseconds so you've got on for 1340 microseconds off for 352 onto 1308 off of 372 and so on and if you look down here if i counted up the 12 bytes i think it ended somewhere oh down here somewhere i'm not going to add them all up there anyway so obviously was repeated and then i did it again with a different code what was that that was off and this was on i think so oh yes it did end with this eight one two oh but it looks like so it starts with a fairly long mark and ends with a fairly long mark on period so i think that is the individual code at the top there maybe anyway the point is it told me what the mark space ratio was i thought right okay i can just now program that into an esp32 which is this little unit on my desk here so this one now transmits that code and all i did in that code is this so this is the code and at the top there you can see those codes that i've just showed you on the the cool term serial monitor i've just pasted them in here as a raw data array then i've basically set up the pwm on the esp32 which you do very differently from the arduino so basically here pm w channel you say which channel you're using and naught to 15 that is so i'm using naught i'm saying 38 kb 38 kilohertz output and i'm saying 8-bit resolution because frankly we don't care um basically that means i can set the mark space ratio between naught and 2-5-5-2-5-5 being permanently on zero being off so i've set it to i think it's 125 or something we'll see later on anyway we attach a certain pin because any pin on the esp32 can be a pwm output sorry any output pin so not your 39s and 38s they're input only but any output pin can be a pwm pin right so we go right attach that pin to this channel that i've told you here and then basically work your way through that array uh the first if it's an odd number then it's um a mark and if it's an even number then it's a space did i say that right around oh you know what i mean the first one's on and the second one's off right this works its way down the list and these are the two little things that i wrote just to say go you know write the output on and off so basically write it on here at 125 kilohertz that's about 50 percent mark space ratio you delay for the certain number of microseconds coming in and then the next bit stops it basically it turns it off again right now i was worried of course that the processor is going to take time leaping between these functions and then obviously going to be a few microseconds i guess between each one as it jumps around so i was going to make these in line if there was a problem um but as it happens i didn't need to let's have a look what this generated compared to the the reference output from the original remote control right then let's repeat that exercise the first trace you'll see on here now is going to be the actual trace of the remote control and then whatever the arduino sends out so first of all we want to capture the real trace don't we so let's see if we can do that right so that's the trace we want to emulate so let's press ref and save that to internal right that's that's fine now you can hear a beeping because that is in fact the the fan responding now to the art we know so let's see what kind of um output that's giving out let's just trace that on channel one there it is right let's compare the two now i'll just turn off the infrared otherwise it yeah it beeps right so the trace at the top um is the one now generated from the arduino and the one from the bottom is the actual one from the remote control and if i bring them a bit closer together you'll see that look look at this there i would say pretty much identical they overlay each other beautifully and they look at that yes much much better so that's obviously why my fan now responds now that was the on and speed controls or combined on one button but it works for all the buttons and the beauty of the library i'm using is that it will tell me what the mark and space ratios in raw format are and i can just code that into my program now fantastic now you might think at that point wow you've cracked it it's all pretty much identical yeah and of course the original bit of software this one here says oh yeah that's still your new bert protocol sending out the same bite or series of bites that you said you were going to do and yet the fans still refuse to do anything so what i did on here because i was driving it directly from the 3.3 volt pin uh i i'm now powering it via 5 volts and the transistor looking like that a little bit on the circuit diagram very simple right now i think current what that is that's a what is that that's like a 1k in series with the um bass and also i've got um i think i've got a resistor in series with the five volts or maybe not i don't know i'll put something in the quad i was just playing around you know now there's one other thing that um a lot of you suggested about leds let me show you what i mean right here we have two types of led the crystal clear water clear ones are 850 nanometer length wavelength and the bluish ones are 940. well these have got a 30 degree spread and they've got a 15 degree spread because some of you said well it might be a different type of led that you need well the news is i can use either of those and that still responds it just doesn't seem to make any difference these might well be transmitting on that frequency 850 or 940 but the receiver seems to accept any sort of wavelength as indeed did all my stuff down here this thing down here accepted anything so it was an interesting idea but apparently not needed one final thing i want to share with you and this is all down to you guys it's this one here no it's not i can't see for the wood for the trees there we are there okay yes google this morning sent me a summary of my year in youtube for 2021 and considering i was off youtube from well january through to our camera but it was now april may or something while i was moving house and having this lovely workshop built i think we did pretty well 2299 comments which i mostly replied to if you remember i had a cull a few weeks back now all the ones i couldn't respond to but look at 22 and a half 000 likes there's a little bit more information actually which i'll drop in to this video about how many views and things but it's it's mind-boggling considering my channel was pretty small in the in the scheme of things isn't it the amount of people who look at it is quite amazing and i thank you from the bottom of my heart not only that for all the coffees you've bought me oh yeah there's a bit of a fly in the ointment in there yes my coffee has a fly in it the reason i chose buy me a coffee to help support my channel so many of you asked was that it was a paypal thing it can go directly into my paypal account um pretty easy right yes they took a commission said buy a coffee but i mean unfortunately now for whatever reason buy me a coffee and paypal are no longer friends again no can't use paypal anymore well i think you can use paypal but it doesn't end up in my paypal account it ends up in buy me a coffee account and i've got to withdraw it from that oh i thought i don't know i think might be ditching that idea again we'll just how it goes okay cool i think we're done yeah i think we're done great stuff thank you so much for the comments and suggestions if you like this video and if you like the fact i've got it working with your help please do like the video give it a good thumbs up do comment down below obviously uh google youtube like the fact that people comment on my channel and i like responding to you guys you know there's quite a few names crop up now and again but i love to hear from newbies yeah you you you i like to hear from you this week great i know you're hiding in the corner there and i'll see you next time i hope you're finding these videos useful and interesting there are plenty more videos to choose and a couple are shown below and if you'd like to subscribe to this channel just click on my picture below and enjoy the rest of the videos thanks for watching
Info
Channel: Ralph S Bacon
Views: 3,528
Rating: undefined out of 5
Keywords: Arduino, Beginners, electronics, C++, microcontrollers, programming, gadgets, ardiuno
Id: 91EpTlhjWDc
Channel Id: undefined
Length: 19min 50sec (1190 seconds)
Published: Fri Dec 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.