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

Поделиться
HTML-код
  • Опубликовано: 4 дек 2024

Комментарии • 95

  • @Pyromasaur
    @Pyromasaur 2 месяца назад

    Seems to me on a fundamental level you don't actually know what we're talking about but you're learning and you do a good enough job to contribute.. So thanks for that. That's what really matters.

  • @thile2675
    @thile2675 Год назад +1

    Really appreciate your lesson.
    Thank you so much. Please keep it up so we can get more of amazing lession like this.

  • @Delali
    @Delali Год назад +3

    Thanks for this video. I've always wondered if i could use CAN bus commmunications in my projects.

  • @Андрей_Гурьянов
    @Андрей_Гурьянов Год назад +2

    5:41 you can use CAN or UART on any esp32 pins.

    • @badwolf4469
      @badwolf4469 Год назад +1

      there are pins provided specifically for the CAN?

  • @bigpickles
    @bigpickles Год назад +3

    Great video. Thanks, mate.

  • @redmundperrz7234
    @redmundperrz7234 Год назад

    Finally an esp32 canbus project thank u

  • @grahambrown5874
    @grahambrown5874 9 месяцев назад

    This video serves as an excellent introduction to the fundamental aspects of the CAN Bus setup. I'm eager to learn more so I can gain a deeper understanding of the communication system within my Ducati. I presume that if there's a need to continuously transmit dynamic data, such as throttle position codes, there must be a method to relay this information to the microcontroller without requiring a flash and reset of the device. In my scenario, the constantly changing throttle position codes would be transmitted over the CAN Bus to the Engine Control Unit (ECU) to regulate the engine's power output.

    • @hiperformance71
      @hiperformance71 9 месяцев назад

      Why you want to transmit to the ECU? Usually, this is a data wich is transmitted by the engine ECU over CAN Bus, you can read the CAN traffic and maybe datalogging it on an SD card or send to a Display. In you case, the TPS position is hardwired to the ECU, readed the analog signals (more than 1 signal in case of multiple Throttle bodies independently controlled with TBW system).

    • @alastorgdl
      @alastorgdl 3 месяца назад

      @@hiperformance71 Why would you want to transmit accel COMMAND to ECU? Think hard

  • @Bravo_L
    @Bravo_L 6 месяцев назад +1

    Thanks again for this brother. Lots of help❤

  • @LordPhobos6502
    @LordPhobos6502 Год назад +5

    The upload may be blocked, as you're using gpio0 in your wiring.
    Try switching gpio0 to any other pin, as that's the pin that the BOOT button connects to.

    • @EV_engineer
      @EV_engineer  Год назад +2

      Wow that’s an obscure failure mode 😆, thanks for the tip!

  • @assemkhalifa3230
    @assemkhalifa3230 Год назад +4

    Good job 👏 hope in the future you do a tutorial how to connect with mcp2515

  • @Paramore1999
    @Paramore1999 Год назад +2

    I want to warn you all- my ESP32-D0WDQ6 (yes, I know - discontinued) didn't want to work with any of the chips. How much time and effort). Just replacing with ESP32-D0WD-V3 solved everything. Good Luck in Ur projects!

  • @focusford7590
    @focusford7590 Год назад +1

    pin 0 on esp32 can cause probs pull high or use differnt pin

  • @haroldthibault9921
    @haroldthibault9921 Месяц назад

    I often see an MCP2515 used in conjonction with a TJA1050. You're only using the TJA1050 ans I don't really understand how it is possible ?
    Or, is in your example, the workload that should be done by the MCP2515, is done in software by the ESP32 ?

  • @redmundperrz7234
    @redmundperrz7234 Год назад

    There is TJA1051 chip also,i think its good for 3.3v

  • @thaisclaudino7913
    @thaisclaudino7913 5 месяцев назад

    Insteady of using the tja1050 can we use a TJA1040
    High speed CAN transceiver

  • @AlphonseMugisha11
    @AlphonseMugisha11 4 месяца назад +2

    Hi, I cannot seem to get this library to compile for me. I keep getting this error. "Arduino\libraries\CAN\src\ESP32SJA1000.cpp:6:10: fatal error: esp_intr.h: No such file or directory". What am I missing? Thank you.

    • @alejandromonavel6553
      @alejandromonavel6553 2 месяца назад

      I´m having the same problem. I downloaded the library and copied it directly into the folder where the other CAN libraries are but now it is showing a new error: 'gpio_matrix_in' was not declared in this scope
      61 | gpio_matrix_in(_rxPin, CAN_RX_IDX, 0);
      | ^~~~~~~~~~~~~~
      'gpio_pad_select_gpio' was not declared in this scope; did you mean 'esp_rom_gpio_pad_select_gpio'?
      62 | gpio_pad_select_gpio(_rxPin);
      | ^~~~~~~~~~~~~~~~~~~~
      | esp_rom_gpio_pad_select_gpio
      'gpio_matrix_out' was not declared in this scope; did you mean 'gpio_iomux_out'?
      66 | gpio_matrix_out(_txPin, CAN_TX_IDX, 0, 0);
      | ^~~~~~~~~~~~~~~
      | gpio_iomux_out
      does anybody knows what to do?????????????????

    • @solmobil
      @solmobil 2 месяца назад

      @@alejandromonavel6553 i have the same problem. Plz let me know if you guys solved it! Thanks.

  • @timblack4628
    @timblack4628 Год назад +1

    Very nice video. it would be great to see the TCAN 1051 (i think the same), and this library to to transmit using CANOpen. do you have a video on CANOpen with this chip/MCU?

  • @chrisward5314
    @chrisward5314 Год назад +2

    The ESP32 is a 3.3v chip. The dev board provides a 5v to 3.3v regulator. The can transceivers use 5v. You have them connected to the Vin pin, which is 5v from USB. The CAN H/L lines swing from 0 2.5 and 5 to 2.5. This normally would be too much for a ESP32. I thought maybe the resistors are placed there in the reference doc to help with the voltage difference. In series like this is not the best, it will slow down transmission. Using a logic converter is the best way. But it also looks like this particular chip can handle 3.3v signals. Not the one you have. Is seems to work though. Interesting.

    • @EV_engineer
      @EV_engineer  Год назад +3

      Hi Chris, you are right, the ESP32 operates at 3.3V, and the dev board down-regulates 5V input. It's worth noting that the voltage levels on the CAN bus are specified by the CAN standard, not by the TJA1050 transceiver itself. High-speed CAN signalling at 5V input drives the CANH wire towards 3.5 V, which very slightly exceeds the 3.3V max of the GPIO pin, probably fine. Taking a look at the TJA1050 datasheet, it also works in 3.3V mode, so I'll probably use this instead to make sure I don't fry my micro, nice catch! :)

    • @LordPhobos6502
      @LordPhobos6502 Год назад

      You might also try a 100 ohm resistor to clamp the Rx line to the esp, instead of a 10k resistor :)

    • @Paramore1999
      @Paramore1999 Год назад +2

      ESP-WROOM-32 datasheet clearly states that maximum input for high logic level is VDD+0.3 where max VDD is 3.6V so max level is 3.9V

    • @Quemedices684
      @Quemedices684 Год назад

      @@EV_engineer After reading the datasheet, it seems that it only works at 5V

    • @alejandroperez5368
      @alejandroperez5368 7 месяцев назад

      @@Quemedices684 TJA1050 datasheet states: "Input levels compatible with 3.3 V and 5 V devices"
      If you power the transceiver from 5V, and the controller from 3.3V, the transceiver should not fry the controller.

  • @edinetgrunhed6000
    @edinetgrunhed6000 Год назад +1

    this projects seems interesting because very few tutorial and success dealing ESP32 to can bus network due to 3.3v , i hope you will make another video similar to that one but add an arduino uno and join the 3 MCU, it wil be more interesting

  • @Hhtfvhrcbgrejkkjhffvbhb
    @Hhtfvhrcbgrejkkjhffvbhb 6 месяцев назад

    Sir, electric vehicles charger not on without bms battery.
    Now sir how to on charger without bms battery?
    Please guide

  • @olegkozlov302
    @olegkozlov302 Год назад +1

    Thanks! If I just want to pass 1 or 0, what will be the scheme?

    • @EV_engineer
      @EV_engineer  Год назад

      If you mean the payload literally has a 1 or 0 bit then I'm not sure if that's possible with the library I used. I'm considering writing my own CAN driver in a video, stay tuned!

    • @EV_engineer
      @EV_engineer  Год назад +1

      Sending a character '0' or '1' should be fine with the current schema

  • @sbtl8888
    @sbtl8888 11 месяцев назад

    Is there hardware that is in a shock proof case, meaning can be use in more of extreme conditions that has both the comimark transceivers and ESP32 in one ? I have a project where i need to control 10-15 CAN bus components, but its outside and i need something in a case that can withstand this environment.

  • @rifkireynaldi9155
    @rifkireynaldi9155 Год назад +1

    Previously, thank you for making this video. I want to ask why when I run the program, the Sender only displays Sending Packet and the Receiver only displays CAN Initialized
    . I'm using MCP 2551 Transceiver

    • @omarashraf4662
      @omarashraf4662 Год назад

      I'm facing the same problem , did you find a solution ?

    • @HuyLe-ki2dn
      @HuyLe-ki2dn 8 месяцев назад

      Same problem, did you fixed it 😢😢

  • @solmobil
    @solmobil 2 месяца назад

    Hi, great video. I am working on copying this system for a little canbus project over here. I did everything up to the point where I need to add the CAN library to the code, (including soldering up the different boards) but I keep getting a persisting error message that says 'library not found.' Even though I saved it directly in the Arduino library folder. Any help to get past this little block would be greatly appreciated ! Thanks. Once I correctly compile the code using CAN library, I can most likely make it work for our project (to activate a CAN controlled ev charger).

    • @solmobil
      @solmobil 2 месяца назад

      I fixed the problem by going into the 'Board Manager' and reinstalling an older version of ESP32 (2.0.11) instead of the current version (3.0.4, in my case). This allowed the board to recognize the CAN library. found the answer on the 'github issues' page. Thanks!

  • @kawtarbelhinani1496
    @kawtarbelhinani1496 6 месяцев назад

    thanks for you video i watched can connection btw esp and esp32 and also between stm32 and STM32 THAT U just posted can u do between stm32 AND esp32 with can protocol I NEED IT FOR MY project

  • @milindtuplondhe4944
    @milindtuplondhe4944 Год назад

    Hi sir, i have daly battery. But can't read massage, sending query. Using this code

  • @habtamusium8646
    @habtamusium8646 4 месяца назад

    helow Ev , do you give me an idea from where I start my project w/c is helping stop collusion of two cars after proximity sensor sending a signal x- distance to clutch or brake system ( i.e, to follower car ) ?
    ( it most means of accident in my city ) . I am eager to listen any guideline that help me go steps .

  • @arthurfricchione8119
    @arthurfricchione8119 Год назад

    Hi Josh can you explain to me what is CRX wire and gauge. I just am hearing that call out for the first time. Thank you Artie 👍

    • @EV_engineer
      @EV_engineer  Год назад +1

      Hi Artie, the CRX/CTX (CAN RX/TX) lines are the interface with the CAN transceiver. Connect them to any GPIO on the microcontroller. CTX allows your microcontroller to send data to the CAN transceiver, and CRX allows you to read from the CAN transceiver. Given they are simple GPIO cables that only carry around 20mA, you can use any simple jumper cable (22-28 gauge I think?). Cheers

    • @arthurfricchione8119
      @arthurfricchione8119 Год назад +1

      @@EV_engineer thanks I’ve got it now. Much appreciated for your reply. Cheers mate

  • @pravallikakakarla
    @pravallikakakarla Год назад

    can i use another CAN module instead of TJA1050 can i use mcp2515

  • @simaroaerial7237
    @simaroaerial7237 Год назад

    One more thing. The transceiver board in your link seems to be 5 volts device where as ESP32 is 3.3! Any comments?

    • @EV_engineer
      @EV_engineer  Год назад +1

      Hey! Yea it also seems to work fine if you power it with 3.3V. There was another comment thread discussing this you might want to check that out too.

  • @Delali
    @Delali Год назад

    In your experience, what would you say is the advantage of CAN bus over UART or I2C?

    • @Gengh13
      @Gengh13 Год назад +1

      Noise immunity and distance, I2C and UART(at least at TTL levels) are designed mainly for short distances.

    • @EV_engineer
      @EV_engineer  Год назад

      Couldn't have said it better! Also transmission speed is usually faster on CAN, although there may be a few edge cases with high-speed I2C

    • @badwolf4469
      @badwolf4469 Год назад +1

      and there is another major difference it seems to me, the UART is not addressable and can only communicate with 1 single device and the CAN protocol solves this

  • @something_different8968
    @something_different8968 Год назад

    subscribed right away

  • @abdalrhmanahmed3187
    @abdalrhmanahmed3187 6 месяцев назад

    im using esp 32 LILYGO can rs485 is no working

  • @chungta1132
    @chungta1132 Год назад

    i have followed your instructions but esp 32 can't receive the data that esp32 send. Can you help me fix the error? please! because I am in need for a project of mine. thank you very much

    • @EV_engineer
      @EV_engineer  Год назад

      How do you know that the data is being transmitted?

  • @gokusaiyan1128
    @gokusaiyan1128 Год назад

    any info on how to read data from votol em 200 ?

    • @EV_engineer
      @EV_engineer  Год назад

      I've never used this particular device, but I imagine the process is similar to reading from any CAN bus. You'll need to follow these steps, roughly speaking:
      1. Create a CAN Bus Connection
      2. Initialize the CAN Bus, as per the votol documentation
      3. Listen or Poll: Now you can either listen for CAN frames (passive) or actively send query frames to the Votol EM-200 to request data (polling). Again, the specific CAN IDs and query commands would be found in the Votol documentation.
      4. Decode the Data
      Hope this helps,
      Josh

  • @AKKJ420
    @AKKJ420 Год назад

    Why do you need a transceiver? I thought esp32 comes with twai (can) in them. Are these transceiver acting like CAN devices? Like sensors or something?

    • @EV_engineer
      @EV_engineer  Год назад +1

      The ESP32 has a twai (CAN) controller. This handles the Data Link Layer. Still need a CAN transceiver for the PHY layer

    • @AKKJ420
      @AKKJ420 Год назад

      @@EV_engineer Thanks for your quick reply. Such a shame I thought esp32 would have transceiver in them. Damn! Great video by the way liked and subscribed.

  • @rustyrobinson8027
    @rustyrobinson8027 Год назад +2

    recent subscriber thanks 👍

  • @shabinaa6407
    @shabinaa6407 Год назад

    Can you help to develop CAN for renesas using C++?

    • @EV_engineer
      @EV_engineer  Год назад

      Only if I can find a cheap supplier :)

  • @quaeft
    @quaeft Год назад

    Hello. I am a bit stuck and I don't know why. I am using the same library as you and the documentation say but somehow I get the following message: class ESP32SJA1000Class' has no member named 'beginPacket'; did you mean 'endPacket'?
    And yes. Indeed in the ESP32SJA1000 Class of CAN Library is no attribute called beginPacket. Only endPacket..

    • @EV_engineer
      @EV_engineer  Год назад

      Did you use the same example sketch?

  • @ljj84
    @ljj84 Год назад

    where i can download the arduino source code in video for sender and receiver board?

    • @EV_engineer
      @EV_engineer  Год назад

      Check the description, I posted all the links

  • @gobrbrr3558
    @gobrbrr3558 Год назад

    In my case, Can.endPacket() do not implement because readRegister(REG_SR) & 0x08) != 0x08 ( Tx not completed) . I am stuck in this problem. Can you help me?

    • @EV_engineer
      @EV_engineer  Год назад

      Did you use the same example sketch?

    • @gobrbrr3558
      @gobrbrr3558 Год назад

      @@EV_engineer yes, i did

  • @juancervantes6404
    @juancervantes6404 Год назад

    Hey boss if I would like to connect to a vehicle and write a script to send a command upon connection is that possible

    • @EV_engineer
      @EV_engineer  Год назад

      Hello! You can certainly connect to a car's OBD port which will give you access to the CAN bus. I'm actually planning on doing a video on this :)
      For sending messages, check out SocketCAN: blog.mbedded.ninja/programming/operating-systems/linux/how-to-use-socketcan-with-the-command-line-in-linux/

    • @PremKumar-ex7pm
      @PremKumar-ex7pm Год назад

      @@EV_engineer is it possible if i use same hardware setup , where one end is connected to car obd port , to read the can messages .?

  • @ismailtarek6558
    @ismailtarek6558 Год назад

    amazing work , can u make it with MCP2515 can module I tried all the methods didn't work so can u help me✌

    • @EV_engineer
      @EV_engineer  Год назад +1

      Thank you! I'll consider making a video on it

    • @affieuk
      @affieuk Год назад

      @@EV_engineer if you do, please mention can bus fd, I found some designs on a pcb that had both can and can fd, it was using mcp2515 and mcp2518fd. I'm trying to figure out if you need both, or if you can simply use mcp2518fd, meaning is it backwards compatible?

  • @jyvben1520
    @jyvben1520 Год назад

    video shows demo situation, how to really use, needs wifi added i guess, local esp32 is connected to wifi access point,
    can bus wiring extends maybe thru a steel wall (blocks wifi) and then the other esp23 is a wireless access point ...
    might be totally wrong

    • @EV_engineer
      @EV_engineer  Год назад

      There are many use-cases indeed!

  • @Rkemobilitywork
    @Rkemobilitywork 7 месяцев назад

    Hello, need your help , for project, I am from India, pls update me fast

  • @zoeyzhang9866
    @zoeyzhang9866 Год назад

    Nice sharing pal. Wondering if any custom PCBs are required for any upcoming videos? If so, would love to sponsor some freely and wish to have any collabs together! (PCBWay zoey)

    • @EV_engineer
      @EV_engineer  Год назад

      Hi Zoey, I am not planning on doing any sponsorships on this channel for the moment, but thanks for reaching out!

    • @zoeyzhang9866
      @zoeyzhang9866 Год назад

      ​@@EV_engineer Sure, feel free to let us know anytime you need our prototyping services, would be an honor to get involved.🤗

  • @LordPhobos6502
    @LordPhobos6502 Год назад

    Got a couple of questions...
    Is there any way of the recieving ESP32 to send the acknowlege bit?
    And how many bits (bytes) can be sent in an extended frame?
    Thankyou for this tutorial, I'm having fun building and learning CANbus, and this video is an excellent guide for getting started 🙂

    • @EV_engineer
      @EV_engineer  Год назад +1

      Hello, glad you find the content helpful! The extended CAN frame holds the same amount of data as the standard frame, it just has 29 bits for the identifier. Regarding your question about ACK, the short answer is yes. The ACK bit is part of the CAN frame itself. The transmitter sends recessive (1) and any receiver can assert a dominant (0). This logic is handled by the CAN controller, which can be a hardware or software implementation depending on the CAN node. Since I showed an ESP32 acting as a CAN receiver in this video, I think it's safe to assume it implements the protocol correctly.

  • @captaindunsell8568
    @captaindunsell8568 Год назад

    Fibre channel transceivers… SFP s

  • @ragohy
    @ragohy Год назад +3

    ALLWAYS use bus termination (120 Ohm)!!

    • @EV_engineer
      @EV_engineer  Год назад +1

      Agreed! And these transceivers in fact do have 120ohm resistors built-in, (R3)

    • @ragohy
      @ragohy Год назад

      Not the transceiver!!! NEVER!!
      Your breakout board might be equipped with a 120 Ohm termination resistor. In a circuit Diagramm they should be included and be placed at the right position.

  • @craigdoyle8225
    @craigdoyle8225 7 месяцев назад

    G'day Josh, Am having trouble compiling with this error:
    f:\Workbench\Arduino\libraries\CAN\src\MCP2515.cpp: In member function 'virtual void MCP2515Class::onReceive(void (*)(int))':
    f:\Workbench\Arduino\libraries\CAN\src\MCP2515.cpp:270:9: error: 'class SPIClass' has no member named 'usingInterrupt'
    270 | SPI.usingInterrupt(digitalPinToInterrupt(_intPin));
    | ^~~~~~~~~~~~~~
    Any help would be very much appreciated
    Craig