Making a CAN Bus on a breadboard with two ESP32 microcontrollers!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up everybody in this video I'm going to show you how to make an esp32 can bus system on a breadboard so I did this using uh the esp32 from kigis uh that I've shown here on the right and the um Connie Mark Tommy mark five piece can bus module which I also got from Amazon uh which I have uh right here so first off I'll get into the wiring setup that I did for the breadboard and then I'll show you how to download a can driver system for Arduino and program the esp32s and uh I'll do a quick demo uh sending uh hello world data packet from one esp32 to the next if this is your first time on my channel my name is Josh I'm an embedded software and electronics engineer I like to make cool Electronics projects such as the one I'm going to show to you today and if you have any recommendations of projects you want to see please drop them in the comment section below and as always please drop a like And subscribe if you like the content foreign foreign foreign foreign so I found this pretty awesome article that explains the can protocol and also how to hook this up to an esp32 they used a different can transceiver from the one I have which is the only uh sort of novelty that I had to deal with although it wasn't too hard to figure out so they're using this can transceiver right here which is based on the tja 1051t um so this one right here however I bought this one uh so some other advice wasn't directly applicable for example they they connected these 10K resistors for some reason between uh the transceiver and the esp32 I tried that but it didn't work with these so uh yeah it's a good reference but you can't copy it directly um so I used this esp32 right here and one thing you have to keep in mind is that um as this image actually does depict you need to connect a can TX pin which can be in any pin of the esp32 um uh well any GPI open and you need to connect that to the TX of the can transceiver which is a little counter-intuitive usually uarts go from TX to RX but that's not the case here you want can TX to connect to TX uh and also this doesn't have to be the UR pins as a matter of fact um I did not use the UR pins I just used the GPA open that was not a uart pin maybe it works maybe it doesn't but you don't have to do that so I used um gpio 4 and 0 right here and I'll show you how I hook that up so the other thing to keep in mind is we're going to need some sort of can driver for the system and luckily um this article links us to um this GitHub repo which I have pulled up right here uh so you can take a look at this so I was just reading the readme file it says it works with esp32 uh great so uh I just get cloned it and uh installed it as an Arduino Library so um for example here you can see I did the git clone and then I put it in my downloads folder uh and then what you do is you go to sketch uh include Library add a zip Library um and then you uh go to the place that you install it so I've already done that so if I do it again it'll just say like error you've already installed this uh but yeah you're gonna need to do that another thing you're gonna need to do is open up well yeah I guess before installing um the library just go make a new sketch uh for example like this and then go to uh this this article and just copy this code right here uh so that's what I did earlier paste it uh into here just like that um so cool I don't need to do that again but uh for reference that's what you do and another thing to keep in mind is they have these definitions up here so the default for this sketch that they provide is 21-22 and I chose um to use four and zero which is why I put these up here uh and the cool thing about this provided sketches that um the sketch can either configure the esp32 to be an RX or a TX device so the way you uh switch that around is you just uncomment uh here and here so this one is going to be the receiver this one's going to be a can sender uh and then you just uh Flash the sketch onto uh your devices so we are now ready to flash uh our esp32s on the left here I'm going to flash the can receiver code and on the right I'm going to flash the can transceiver code so here on the left um we'll just double check what port we're using com6 cool then I will click upload that's going to ask me if I want to save it no I do not um and as always with esp32 we have to hold down um the reset pin uh as it flashes so I will do that another thing we have to do for some reason is disconnect the power to the can transceiver I kind of just figured this out through trial and error it wasn't working until I did this a little strange but regardless that is how you make it work uh and on the right side here we will select com 10 cool and we will click upload and then do the same thing so I will hold on to the reset and then I'm going to disconnect power and it is now flashing and I will hook this back up so now uh we can open the respective serial monitors so this would be the receiver one and then here I'm going to open up the transmitter serial Monitor and I will press both of their reset buttons [Music] oh what's going on with com6 here give me a reset try this one more time serial modern oh that is because I'm not clicking reset there we go so now we can open up their uh respective serial monitors so I'll come up here and look at that it's transmitting stuff I'll come up here and I will press the serial Monitor and look at that it's receiving stuff uh so that uh kind of shows that everything's working and uh another thing we can do just to kind of prove that it works is we'll just change the message uh slightly so we'll come here we'll click one two three uh let's flash that onto the transceiver um so we can see here that it has stopped sending packets because it is flashing I will um do the whole reset of the esp32 again connect this back in and let's press uh on to the reset button of the transceiver cool now we are transmitting a different message hello one two three and there you have it we have a working can bus system with the esp32 microcontroller
Info
Channel: The EV Engineer
Views: 39,605
Rating: undefined out of 5
Keywords: CAN Bus communication explained, Playing with CAN bus and Arduino, Esp32 CanBus Arduino, How to write CAN driver
Id: ZH_CCs12ptg
Channel Id: undefined
Length: 11min 25sec (685 seconds)
Published: Sun Feb 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.