How I2C Communication Works and How To Use It with Arduino

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

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

  • @rahulfromkerala
    @rahulfromkerala 5 лет назад +307

    2 hours of reading and then here comes this video where everything is well explained in under 10 minutes... You tube is spoiling me...

  • @nobodyspecial313
    @nobodyspecial313 8 лет назад +74

    Sweet tutorial! Really like the illustrations that went along with your explanation. After looking at a few cool project videos where people are using Arduinos and other microcontrollers, it makes me wish my college had a class on these!

    • @iancorcoran7560
      @iancorcoran7560 7 лет назад +1

      Dejan Nedelkovski

    • @Gupatik
      @Gupatik 8 месяцев назад

      it's been 8 years now or so, are you still alive bud, and did you learn this arduino and microcontrollers stuff. Anyways, hope you are doing good

  • @mark879
    @mark879 7 лет назад +36

    Awesome video! I especially appreciated the protocol/packet breakdown. Thanks very much!

  • @kamuizero
    @kamuizero 7 лет назад +19

    What a great video! Very clear explanation and simple demonstration on how to use it.
    Thank you very much.

  • @markconger8049
    @markconger8049 3 года назад +1

    Thank you for this tutorial! I knew the overview of how i2c works but not the specifics. It looks similar to packets in TCP/IP.

  • @cmulder007
    @cmulder007 2 года назад +1

    In the breadboard diagram at 5:56 both the + and - are connected to ground on the Arduino

  • @tarunrjain9748
    @tarunrjain9748 2 года назад +1

    Macha, I am a big fan of your channel. Macha I think u did a mistake .......in the tinkercad sample which u have shown in the video .....both the power supply are connected to ground.......Shouldn't the VCC one connect to 5v power supply? btw lots of luv from India

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

    Brilliant, and exceptional narration.

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

    Thank you. It's simple to comprehend

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

    Great video, really appreciate it! But I really think that explaining every line of the code would've been great!

  • @adamsvette
    @adamsvette 2 года назад

    It's incredible that you can communicate with so many different devices using only 2 wires. also, the 2 SAME wires.

  • @chinhcd
    @chinhcd 8 лет назад

    It saved me so much time and hassle. Good job!

  • @miguelluisrodrigues3704
    @miguelluisrodrigues3704 4 года назад +1

    Thank you brother, you help me a lot in my projects

  • @MkmeOrg
    @MkmeOrg 9 лет назад

    This is fantastic! Sharing on Mondays live show. Great vid. Cheers!

  • @morgard211
    @morgard211 6 лет назад +3

    Thanks! I didn't want to memorize it, but to understand it and it worked! :)

  • @andremendes5116
    @andremendes5116 8 лет назад

    Nice explanation... the protocol I2c is very usefull, fast and need... Thank's for your time and information.

  • @RandomMusingsOfLowMelanin
    @RandomMusingsOfLowMelanin 8 лет назад

    SUPERB WORK MAN!

  • @q12x
    @q12x 2 года назад

    very nice explained !

  • @nikoslykouresis2275
    @nikoslykouresis2275 5 лет назад

    Man I don't know if it's the weed, but your explanation made me understand most of this very clearly

  • @andrebernardmennicken4685
    @andrebernardmennicken4685 7 лет назад

    Verywell explained, clear, direct to the point, Thank you...

  • @ismzaxxon
    @ismzaxxon 8 лет назад

    Fantastic. Apreciate your effort.

  • @tomtina6079
    @tomtina6079 8 лет назад

    Bravo pour cette explication detaillé.
    Care, stvarno si precizno i ukratko objasnio IIC.
    Jedino sto fali po meni je kako prelazis sa 8 bitnog adressiranja na 10-to bitno adressiranje

  • @marklowe7431
    @marklowe7431 8 лет назад

    Perfect explanation. Thank you.

  • @aragonv1
    @aragonv1 8 лет назад

    ΤΗΑΝΚ ΥΟU.. ! A VERY CLEAR EXPLANATION OF i2C DEVICES

  • @arunraj5275
    @arunraj5275 8 лет назад

    I'm telling that, it will be very useful for novice because I'm novice.

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

    Thank You!

  • @alentech6091
    @alentech6091 7 лет назад

    Amazingly well explained!

  • @yapandasoftware
    @yapandasoftware 7 лет назад

    I believe you could get way more components on the lines if you went to a 4 carrier freq using OFDM platform and using a simple B QPSK to create your binary. I've done this with PLC designs with the IPL0201 MPU. We used a balun coil and passive phase filters .01uf capacitor to reduce the 120 hz signal noise from the AC line and we transmitted the signal 12 miles on a 7620 powerline. We've been doing PLC 2 wire transmissions for decades now. I'm surprised they are just now getting around to it with arduino.

  • @JohnSmith-bj7uc
    @JohnSmith-bj7uc 8 лет назад

    Great video

  • @SamirSogay
    @SamirSogay 8 лет назад

    Awesome tutorial

  • @Ravi007teja
    @Ravi007teja 7 лет назад

    Amazing video sir!! You are brilliant :))

  • @dradexx
    @dradexx 6 лет назад

    great video!! thanks!!

  • @akshayn3926
    @akshayn3926 8 лет назад

    nice explanation

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

    6:05 the power and ground wires (red and black) are both connected to ground on the mega?

  • @crazycoolguy109677
    @crazycoolguy109677 5 лет назад

    Can you please make a comparision video on I2c, 485 and 232??? Thanks

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

    thanks

  • @didiersee
    @didiersee 6 лет назад

    Congratulations very good explanations. I'm subsribe.

  • @roboticacreativa9851
    @roboticacreativa9851 8 лет назад

    Great!, Thank you for the contribution.

  • @naveenchoudhary2675
    @naveenchoudhary2675 8 лет назад

    dejan you are great.. thankx buddy :)

  • @senai_mecatronicabeta3737
    @senai_mecatronicabeta3737 7 лет назад

    Muito bom este tutorial, parabéns.

  • @haroon552
    @haroon552 6 лет назад

    great Video

  • @Steven-jf4cs
    @Steven-jf4cs 2 года назад

    What if you have one i2c component that HAS a pull-up resistor and another i2c which requires a pull-up?

  • @AGeekNamedRoss
    @AGeekNamedRoss 6 лет назад +1

    Great video. New subscriber here.

  • @toolzshed
    @toolzshed 5 лет назад

    awesome!

  • @Ishanchawla61
    @Ishanchawla61 3 года назад

    I want to read 8 rotary encoders simultaneously. Each encoder is a quadrature encoder with 2400 counts per revolution. Two interrupt pins are required to read the direction and position of each encoder. In total, I require 16 interrupt pins. But Arduino mega has only 6 interrupt pins. Should I use 2 Arduino mega as slave and 1 Arduino as Master in I2C communication ? Will this alternative work ? Is there any easy alternative to this problem

  • @DPaquette
    @DPaquette 7 лет назад

    Wow, 1024 devices on 10 bit addressing...cool.

  • @caonguyenvan8890
    @caonguyenvan8890 7 лет назад

    Thank you very much about this tutorial , But could you help me ? I have a question, Can any modules use I2C ? In my case , they are module sim800 and DFplayer mini module ?
    Sorry because my English grammar is not good :))

  • @thesauceboss5995
    @thesauceboss5995 2 года назад +51

    This is one of the only videos I've found that explains how pull up resistors can affect the speed at which data can travel on the SDA line. Fantastic video that explains how I2C works. Great job.

  • @aodreds
    @aodreds 5 лет назад

    Great video

  • @mohanmanoharan1387
    @mohanmanoharan1387 8 лет назад +22

    super, really appreciate for the tutorial. Request similar other Serial protocols SPI explanation. CAN, UART. thanks

  • @vijaykumar-hc6jz
    @vijaykumar-hc6jz 4 года назад +12

    The bit sequence was so well explained that I had to print the screenshot of it for future reference.

  •  8 лет назад +30

    Very useful for beginner like me, thank you! :)

  • @ipadize
    @ipadize 2 года назад +1

    i know its an old video and you probably already know that but you can shorten the Serial.print commands to one like this:
    Serial.print(String("X0= ") + (X0) + ("X1= ") + (X1)); then when the numbers are bigger or shorter it will automatically fit them together

  • @roidroid
    @roidroid 9 лет назад +121

    6:00 just a headsup: You have the Arduino connected to two GNDs, with no 5V line.

    • @AdityakrishnaMr
      @AdityakrishnaMr 5 лет назад +4

      Yes, that bothered me too.

    • @AngryRamboShow
      @AngryRamboShow 5 лет назад +3

      @Blondie SL the white race needs you to make blond haired blue eyed babies. Stop being a degenerate and man up.

    • @taimooramin1272
      @taimooramin1272 5 лет назад +1

      Bro thats not a big deal he is also a human and if he has done any mistake that does not matter because if you have used arduino or any other types of microcontroller in past u can correct the connections easily

    • @ksawery6568
      @ksawery6568 5 лет назад +2

      @Blondie SL Well that escalated quickly.

    • @cinibar
      @cinibar 5 лет назад

      @Blondie SL Dark matter....hmmmm I once cut open a dead flashlight battery and found it to be very dark, black as coal in fact. I just figure it got full of the dark that it was displacing with light, and died when it got full. :)

  • @dorianmccarthy7602
    @dorianmccarthy7602 8 лет назад +44

    Intro RIP headphones users. But great info :)

  • @thomashvnmusic
    @thomashvnmusic 3 года назад +1

    Guys, any idea where i can read about the Wire.h library about what it's functions do?

  • @BatsAwesomeIn2030
    @BatsAwesomeIn2030 4 года назад +4

    To the point, simple and clear, well done! which most people struggle to explain.
    ~This is coming from a Professional Embedded engineer.

  • @GetElectronics
    @GetElectronics 5 лет назад +16

    I always like tutorials that show how to use sensores without relying on 3rd party libraries other than the wire one. Very useful for learning.

  • @suzesiviter6083
    @suzesiviter6083 6 лет назад +3

    To clarify; the I2C lines are either high impedance or 0, you never drive the bus line high directly; that is achieved by de-asserting the '0' and letting the internal pull up resistors tie it to Vcc. The high impedance or low state on the bus prevents bus contention; that is a ground connecting to Vcc directly causing a short between any masters or slaves.

  • @HowToMechatronics
    @HowToMechatronics  3 года назад +5

    I hope you enjoyed this video and learned something new! If you'd like to support me making more content like this, please consider supporting me on Patreon: www.patreon.com/howtomechatronics

    • @Scudmaster11
      @Scudmaster11 3 года назад

      I know you can get composite video out of it or something

  • @J-K-AG
    @J-K-AG 8 лет назад +1

    Great tutorial mate. Just wondering is there any tutorial on how to change address on unique slave devices.

    • @J-K-AG
      @J-K-AG 8 лет назад

      No problem. Thanks for the video anyway really helpful.

  • @ngkhai5935
    @ngkhai5935 2 года назад +1

    There is an error at the circuit diagram. Instead of 5V you're connected to a GND. However, thank you so much, I learnt a lot from your wonderful video. Merry Christmas

  • @TheSateef
    @TheSateef 5 лет назад +1

    thanks, can you tell me in the program you test for Wire.available=2?

  • @philippedrolet4853
    @philippedrolet4853 4 года назад +2

    May I take a screenshot of the diagram at 3:30 for my undergraduate research paper if I cite its origin?

  • @sorenium
    @sorenium 7 лет назад +5

    This is so beginner friendly! Thank you so much. I used the same illustrations to make few students understand the same. :)

  • @hubertmargreiter3508
    @hubertmargreiter3508 3 года назад +1

    Like all of your videos, also this one is very educational. Thanks for uploading!!
    But how do you approach the problem if you want to transfer 128 bytes from a slave node to a master (e.g. Arduino or Teensy)?
    Do you know of any link that might help me with a code fragment?

  • @rajr4168
    @rajr4168 3 года назад +1

    Wire.available() returns the number of availabe bytes. So the if condition should be (Wire.available() >= 2)

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

    Master put address to I2C bus.
    Then corrosponding slave identify and match with his own address .
    Then slave say Hi to master ( send ACK to master)
    How slave match address which is send by master .
    Which register compare received address and its own address . Thanks.

  • @pixelsquarelight
    @pixelsquarelight 13 дней назад

    Google tells me that this video is in English. 52 years using English as a primary language and being a native English speaker I am fully qualified to point that Google is a liar, liar with pants on fire. This video is definitely nor in English.
    Epic AI fail, Google.

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

    Thank you for ur very good explain. I have one quastion. Why is in Code wire.write(8) ? Can anybodd explain that fot me thank you 8:49

  • @walterblanc9708
    @walterblanc9708 3 года назад +1

    I really wish this video had been available when I first tried learning this protocol, it took ages wading through Datasheets and writing the code in assembler with no library! Without an Oscilloscope I would never have got it to work . Happy days ...Not.

  • @Fubo777
    @Fubo777 3 года назад

    What if I want to have two same sensors, which will have same I2C address right?
    I'm planning on building a weather station, which has one HDC1080 for measuring indoor temp and humidity, and one HDC1080 for outdoor.

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

    Great video!!
    In pi pico we have I2C0 in Gp0 and gp1 and also in GP16 and GP17
    What is the potential use of such configuration
    And do they have the same bus internally ?

  • @iancockrell5920
    @iancockrell5920 2 года назад

    With the gy521/MPU6050, how is all of the data able to be transferred with only one register (0x68)? does this component always transmit all of its data or can I request that it only send certain information?

  • @fr3ddyfr3sh
    @fr3ddyfr3sh 2 года назад

    1. honest: Good explanation
    2. “Good old old times”, when people had no issue using slavery terms in technology, which are associated with hundreds of years of murder, torture, rape and suffering. 😢

  • @icarossavvides2641
    @icarossavvides2641 3 года назад

    There are a lot of Tubes about I2C but none of them make note of the fact that I2C is an abbreviation of Inter IC Communication, it was invented by Philips to help reduce the amount of communication tracking between IC's on a PCB, consequently it is a reliable communication system when used over short distances in a controlled environment, a PCB, but it was never intended to be sent overlong pieces of wiring (>200mm?). If you use this to connect to devices over long lengths of wire, especially if there are noisy items around like motors etc, be prepared for random communication problems.

  • @WaveOfDestiny
    @WaveOfDestiny 4 года назад

    i tested every library and sketch i could find. Nada. One guy said wire.h is incompatible with the chip of the mkr wifi 1010 board but i don't get why or how to fix it. All i2c tutorials use something that depends on wire.h or comes from it. If the board has dedicated i2c pins there gotta be a way to use them. I put the pins as shown in every tutorial, i don't think 2 accelerometers came already broken

  • @Hector-ts2dw
    @Hector-ts2dw 3 года назад +1

    patatass
    brocoli
    verduras
    tampones
    supositorios para gatos
    pan
    silla
    0,5 magdalena

  • @michaelvogt7787
    @michaelvogt7787 8 лет назад +8

    Dejan,
    I was looking through youtube for a decent tutorial about the I2C bus as implemented on the Arduino. I have a class of high school students who could use a good demo. I didnt expect to find your EXCELLENT tutorial, one that would be useful even to professional electronics engineers. I wanted to let you know you did a nice job, and it was appreciated.
    Dr. Michael Vogt - North American Robotics

  • @alextrujillo8861
    @alextrujillo8861 2 года назад

    In the circuit diagram at 6:00, I notice GND is connected to the red and blue rail. Is this accurate or am I missing something? I thought I2C was active low? Was this a mistake in the wiring diagram?

  • @gk780
    @gk780 2 года назад

    400Kbps and each data is 24bits long with their addresses. it can transfer 16,666 characters or 8 bits numbers in a sec. that is fast enough.

  • @pratikgauns5091
    @pratikgauns5091 4 года назад

    Program get stuck at Wire.endTransmission() command. Can anyone please provide for a solution.

  • @simplynilsw
    @simplynilsw 7 лет назад +1

    You said 124 devices instead of 1024 devices (0:52 min), but great video it helped me alot, thanks :))

  • @sandrosalessales6324
    @sandrosalessales6324 5 лет назад +1

    Very good video !!! Thanks

  • @z3my4l
    @z3my4l 3 года назад

    Is it really "Wire.available()=2"?

  • @drcl7429
    @drcl7429 5 лет назад +2

    Excellent. I thought i2c was going to be complicated

  • @ElectroMentor
    @ElectroMentor 3 года назад +1

    Utterly informative video much appreciation 👍

  • @BlagojceKolicoski
    @BlagojceKolicoski 8 лет назад

    You have both VCC and GND connected to the GND on the Arduino @ 05:56. Is this a mistake?

  • @cordawg89
    @cordawg89 3 года назад

    The real takeaway is not to use I2C in the first place... at least not off board. It’s not robust enough

  • @vasilyh4588
    @vasilyh4588 3 года назад

    Eeeeh. Why RED wire inserted into Arduino GND? Isn't it must be inserted in 5V?

  • @Gereon_
    @Gereon_ 4 года назад +1

    Very good explanation! Thank you very much.

  • @MarcelHIC
    @MarcelHIC 9 лет назад

    What about if I want to use two of the same sensors? The adresses and register adresses will be the same? How can I store the informations which I got from both sensors?

  • @moussafiradil1700
    @moussafiradil1700 4 года назад +1

    absolutely brilliant @

  • @jameselliott9397
    @jameselliott9397 6 лет назад

    Where do you get data sheets? I never heat any documentation with components we buy. I need a data sheet for CJVL53L0XV2.

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

    thanks.very well explained

  • @MrPritz007
    @MrPritz007 2 года назад

    That Fritzing diagram is wrong. Red wire connects to VCC. Rest is fine.

  • @michaelliles6755
    @michaelliles6755 8 лет назад

    What are pins xda, xcl and ado used for? Do you have a video on how they can be used?
    thank you

  • @kiranbs5057
    @kiranbs5057 4 года назад +1

    Watched many videos on this protocol I was never able to grab the concept clearly and I found your tutorial and it made my life simple . Thanks man u have explained and visualised the concept neatly .

  • @DRZME400
    @DRZME400 4 года назад +1

    how will you know if the particular I2C device / sensor being used already has the pullup resistor in the breakout board or not?

    • @lordsebas893
      @lordsebas893 4 года назад

      It should be specified on the datasheet !

  • @ahmedalshekly4899
    @ahmedalshekly4899 5 лет назад +1

    thank you very much fantastic explanation