I2C with Arduino and Raspberry Pi - Two Methods

Sdílet
Vložit
  • čas přidán 8. 07. 2024
  • In the third installment of the I2C series, I will show you two ways to interface a 3.3-volt Raspberry Pi with a 5-volt Arduino Uno.
    Article with code samples - dronebotworkshop.com/i2c-ardu...
    More tutorials and articles - dronebotworkshop.com
    Join us on the forum and have your say - forum.dronebotworkshop.com
    Sign up for the newsletter - dronebotworkshop.com/subscribe/
    Today we are back working with the I2C bus, and this time we’ll be interfacing an Arduino with a Raspberry Pi.
    By hooking an Arduino to a Raspberry Pi we can get the best of both worlds. The Raspberry Pi is a powerful single-board computer, capable of running a Linux operating system and connecting natively to the internet. The Arduino is a very capable microcontroller with several I/O pins, an Analog to Digital converter, and precise timing and interrupt capabilities. Together, they make an incredible team.
    But one issue is that the two devices use different logic levels. The Raspberry Pi GPIO (General Purpose Input/.Output) bus operates using 3.3-volt logic, while most Arduino’s use 5-volt logic. Incorrectly interfacing them can lead to a non-functional Raspberry Pi, a situation best avoided!
    You CAN hook the two devices together directly, providing that certain specific conditions are met. Alternatively, you can use a very inexpensive logic level converter to isolate the 3.3-volt and 5-volt logic safely. In this video, I will show you both methods.
    Here is what you will see in today's video:
    00:00 - Introduction
    03:42 - I2C Logic Levels
    06:47 - Raspberry Pi I2C Busses
    08:30 - Setting up the Raspberry Pi
    14:15 - Direct Hookup
    15:35- Arduino Sketch
    17:31- Raspberry Pi Python Code
    20:30- Running the Demo
    24:02- Using a Logic Converter
    While the demonstration is extremely simple it does effectively illustrate how easy it is to interface these two popular boards.
    We will be looking at I2C one more time, in a couple of weeks. So if you haven’t subscribed to the channel yet please do, that way you won’t miss out on anything.
    Thanks for watching! Looking forward to chatting with you on the DroneBot Workshop Forum soon.
  • Jak na to + styl

Komentáře • 148

  • @Dalamain
    @Dalamain Před 4 lety +86

    This is the best channel for IoT devices, soo much detail and clarity - amazing tutorials, thank you!

  • @la3135
    @la3135 Před 4 lety +5

    Again an excellent and easy to follow instruction video! Looking forward to I2C part 2!

  • @rahulas721
    @rahulas721 Před 4 lety +6

    Absolutely Love your Workshop!!
    Keep up the Good Work :)

  • @Mystic0Dreamer
    @Mystic0Dreamer Před 4 lety +1

    Glad to see you're back with your superbly detailed videos. Now I'm anxious to get my Pi talking to my Arduino. Also looking forward to the installment where you address increasing the distance I2C can be used over. Great work Bill. Top notch CZcams presentation.

  • @quaternion-pi
    @quaternion-pi Před 4 lety +4

    Another excellent, useful, educational video. Awaiting part two.... Thanks!

  • @capistor1
    @capistor1 Před 4 lety

    Appreciate all the hard work you do.

  • @mandelbro777
    @mandelbro777 Před 4 lety +1

    always a concise explainer. Thanks heaps. Keep up the amazing videos.

  • @fabricemotard4312
    @fabricemotard4312 Před 4 lety +3

    Hello ! I'm french and I think you are the best youtube channel in english to explain electronic simply ! It's clear and understandable ! 👍👏 Thank you for your work ! ( Sorry for my english if I make a mistake ) 😁

  • @SufiShahHamidJalali
    @SufiShahHamidJalali Před 4 lety

    Very nice and professionally prepared.

  • @weeeBloom
    @weeeBloom Před rokem +1

    great tutorial, thanks a lot!

  • @tubeDude48
    @tubeDude48 Před 4 lety +8

    I'm impressed with your presentation's. I also follow Mr Carlson's Lab. Your are both clear and concise.

  • @electronic7979
    @electronic7979 Před 4 lety +1

    Helpful video 👍 Thank you

  • @heyitsdrew
    @heyitsdrew Před 4 lety

    nailed the camera transitions *thumbs up*

  • @ahnjongchan
    @ahnjongchan Před 4 lety

    Thank you for the good I2C explanation

  • @GeekMustHave
    @GeekMustHave Před 4 lety +1

    I give you the award for the best video explaining I2C and warnings for I2V Bus 0 and voltage considerations. If you find yourself in East Lansing, MI I will present the Award to you at the local brewery. Nice job, I like you video technique and editing hope you don't mind if I copy parts of that technique. Keep broadcasting!!

  • @vincentcaudo-engelmann9057

    Super high quality instruction. Thank you for this video.

  • @slashghero
    @slashghero Před 4 lety

    Great explanation!

  • @kenseastrand7428
    @kenseastrand7428 Před 4 lety +3

    Thanks, I just ordered a five pack of the converters.

  • @dominiksagn788
    @dominiksagn788 Před rokem

    Awesome Video!

  • @HelgeKeck
    @HelgeKeck Před 4 lety +1

    I really love this Guy.

  • @aberateklehaimanot9804

    very educational,thank you.

  • @gokulraj8614
    @gokulraj8614 Před 4 lety

    You are amazing,your videos are very much usefull to me,keep it up don't stop your tutorials,thank you so much🤖

  • @gerhardseipp5544
    @gerhardseipp5544 Před 2 lety

    once again learned something with joy. great explains how to connect a raspberry pi to an arduino Thank you from Germany

  • @minhtruong9408
    @minhtruong9408 Před 3 měsíci

    Thank you so much for the information

  • @ratanpal6760
    @ratanpal6760 Před 3 lety

    You are genius.Your detailing and way of description is just marvelous. If you can make some videos related to some basic electronics, It would be so useful for laymen like me.

  • @mini_special
    @mini_special Před rokem

    Thank you for your video. It helped me a lot.

  • @caffeinatedinsanity2324
    @caffeinatedinsanity2324 Před 4 lety +5

    I would like to see a comparison video on using UART vs i2c vs SPI, etc... As means to establish communication between an Arduino and a Raspberry Pi (or between 2 arduinos and etc). As a quick guide on why should you use one protocol over another one for your project.

  • @filiperibeiro4768
    @filiperibeiro4768 Před 4 lety

    Great tutorial my frind u helped me so much, bis später

  • @arzanist
    @arzanist Před 4 lety

    Cool work

  • @MyOwntuahur
    @MyOwntuahur Před 4 lety

    thanks for all.

  • @JohirulIslam-lm2vz
    @JohirulIslam-lm2vz Před 4 lety

    Excellent!

  • @It4heath
    @It4heath Před 2 lety +1

    Thank You for covering this subject. I was having an issue powering/grounding an IoT project that has an UNO R3 connected to a DHT11 with 2 way communicating with an ESP8266 that is connected to wi-fi and a 4-way relay. The 3.3/5 volt common grounding was giving me a head ach, and causing issues with the sensor data transmitting continuously. No one else really covers things as well as you do. AWWWsome and thank you again.

    • @ahmedabdussalam728
      @ahmedabdussalam728 Před 2 lety

      i am having a similar issue im unable to make the esp32 slave.........may be its because of common grounding

  • @amsunaakage
    @amsunaakage Před 2 lety

    God Bless you, thank you very much for sharing your experience and knowledge with us, you are a great tutor

  • @wishicouldarduino8880
    @wishicouldarduino8880 Před 4 lety +1

    I love this python code I haven't gotten into it much but I guess its going to be inevitable in this design plus it increases code knowledge cool ! Thanks for illustrating that you can have a free flowing design and integrate many things all culminating to make an awesome robot like db 1 is 😁👍

  • @charlieangkor8649
    @charlieangkor8649 Před 3 lety +7

    Imagine in the year 3070: I have Raspberry Pi with 3.3 V I2C and Arduino with 3.3 V I2C, but Arduino is made out of antimatter and Raspberry Pi from matter. Incompatible. Need a special wireless conversion module with a ton of millitary grade safeguard systems to prevent me from blowing up the whole city in a nuclear detonation should these two accidentally touch on my benchtop.

  • @troyfrei2962
    @troyfrei2962 Před 4 lety

    Thank you a lot!! Very good. :-)

  • @jjjxxxaime
    @jjjxxxaime Před 3 lety

    Interesting video, thanks a lot for the information..great videos.. thanks a lot!...

  • @Damoon2543
    @Damoon2543 Před 3 lety

    Thank you! It was really helpful and informative. I also think educational and scientific could be a little more smiley ;)

  • @FikiFirmansyah
    @FikiFirmansyah Před 4 lety

    Thank you ❤

  • @TheOleHermit
    @TheOleHermit Před 4 lety +1

    This is just what I needed to know. I'm about to use I2C between a RPi 3B+ and a D1 mini (w/motor shield for a stepper motor. Thanks for those videos, too.). Are there any gotcha issues that I should know? Looking forward to your next I2C video.
    Thanks! 😎

  • @ericmcgrath7554
    @ericmcgrath7554 Před 4 lety +1

    Loved the episode. Looking forward to the next I2C episode. THANK YOU for making these.

  • @askquestionstrythings
    @askquestionstrythings Před 4 lety

    Is there a good I2C GPIO breakout board for analog inputs? I would like to wire up lots of potentiometers (minimum 26) and a bunch of switches (minimum 27)...

  • @rajcodes100
    @rajcodes100 Před 4 lety

    Thanks for the Video sir - great explanations however in terms of your connections - i am not clear on arduino usb connection.Do you have the arduino separately connected to pc via usb?

  • @neilAneerGAmAI
    @neilAneerGAmAI Před 3 lety

    Very helpful. Thanks!

    • @Silentsobs
      @Silentsobs Před 3 lety

      Is there a way to use I2c interface on a standard pc mother board to check authenticity of port or control a device

    • @neilAneerGAmAI
      @neilAneerGAmAI Před 3 lety

      @@Silentsobs I don’t know, I suck at programming. You should ask an extremely good hacker.

  • @belkhiriasadok7245
    @belkhiriasadok7245 Před 3 lety

    My absolute heartfelt thanks for your incredible contribution.
    I am looking to setup a project and after doing a lot of research on the subject i've decided to go with a single rpi connected to multiple arduinos slaves over i2c . So is there any way to do that and how to connect more than an arduino board????

  • @Donder1337
    @Donder1337 Před 3 lety

    Your the best!!! :D

  • @dustydodge1781
    @dustydodge1781 Před rokem

    I have really appreciated all your videos!! Any advice on how to set up the RPI as the slave? I can’t seem to find any examples on how to do that. I have the logic converter connected, but can’t get the code working.

  • @madguernseyboy
    @madguernseyboy Před 4 lety +2

    hey i would love to see an video on the use of rs485 communication between arduinos. hope you can add it to your list

  • @NielsHvid
    @NielsHvid Před 4 lety

    13:44 Is there a way I can measure if a device uses pull up resistors with a multimeter? I'd like to use a pi to interface with a 5V device, and if possible, I'd like to do that without a logic converter.

  • @wissamchahla6793
    @wissamchahla6793 Před 3 lety

    Hello,
    Thanks for great tutorials.
    I have a question on the logic level converter.
    i have two arduino boards (Nano and Nao 33 IOT) they operate at different voltage levels.
    how can we do serial communication between these two boards ? will the I2c level convertor work in this scenario or i need something else?
    Regards

  • @admiretechnologies1218
    @admiretechnologies1218 Před 4 lety +2

    I'd love a video Arduino --> Jetson Nano communication with I2C.

  • @AhmadAsmndr
    @AhmadAsmndr Před 4 lety

    Thanks

  • @berndhe5798
    @berndhe5798 Před 4 lety

    👍thank you

  • @davidmc105
    @davidmc105 Před 2 lety

    These are the most easily understood and trustworthy tutorials I have seen. I'm trying something similar but unsuccessfully so far. Does an Arduino Nano have a 5V I2C pull up? Specifically, can I use an Arduino Nano (5V) slave with an ESP8266 ESP01 (3.3V) master without a Logic Level Converter?

  • @devluz
    @devluz Před 4 lety +1

    Just trying to connect an ESP32 (3.3V) and arduino. That was a perfectly timed video :D Thanks!

  • @rodrigoventuri6631
    @rodrigoventuri6631 Před 3 lety

    Congrats on the video, it is very helpfull. However I have some questions about many I2C devices. If I want do connect 2 arduinos into the raspberry Pi, I stiil can use 0x8 as a slave address on both arduinos? Or i need to use 0x8 on one arduino and another address (idk which address) on the another? About the phisical connections, I Still use the same pins on the rasp/arduinos, right?

  • @pausecafe8533
    @pausecafe8533 Před 4 lety

    super thx

  • @h82fail
    @h82fail Před 4 lety

    Can this be used for two way communication without the logic converter as long as the Pi is the master? So the Pi can send a request and get data back from the Aurdino. Seems like it should work since the pins are pulled low to send data and the only pull up is in the Pi but I'm not sure and don't want to destroy my pi.

  • @aqiiiiiiiil
    @aqiiiiiiiil Před 3 lety

    Hi, do you have a guide on connecting multiple slave arduino from master raspi ?

  • @swalker157
    @swalker157 Před 3 lety

    Did you make the video about extending the I2C range?

  • @sagarshrestha3717
    @sagarshrestha3717 Před 4 lety

    hi please make video for the foward and inverse kinematics for robotic arm

  • @andreipata321
    @andreipata321 Před 3 lety

    I got a question...if i want to use them in a portable project and i will use a battery pack probably where should i connect the battery and how and what voltage should the batteries output ?

  • @rgdphome8974
    @rgdphome8974 Před 4 lety

    Gr8 Sir

  • @rajatmamidwar8591
    @rajatmamidwar8591 Před 4 lety

    How do load cell or strain gauge work???
    Can we get a video on it

  • @andrewferg8737
    @andrewferg8737 Před 2 lety

    Can you wire a Pi Motor HAT directly to an Arduino by just connecting the corresponding I2C pins (A4 & A5 to pi 3 & 5) ?

  • @user-qc9vz8nz7z
    @user-qc9vz8nz7z Před rokem

    You channel is amazing! I learn a lot from you. I am trying to send a string from a Raspberry pi to Arduino 1. Do you have any special advise for it? Thank you!!!

  • @BleepKing
    @BleepKing Před rokem

    will a pico work as a peripheral using the arduino ide?

  • @seanteng1234
    @seanteng1234 Před 4 lety

    any plans on finishing the part 3 of the Google AIY series? Thanks

  • @DiyintheGhetto
    @DiyintheGhetto Před rokem

    Hello, I'm new to coding my skills are mostly in hardware. But I was wondering If I'm controling over 30 relays from the arduino how do I control them through the raspverry pi using a web server page from the pi itself?

  • @azyfloof
    @azyfloof Před 4 lety

    29:20 was that your belly, or do you have a cat? :D
    ALSO, what is the "bandwidth" of those logic level converters? I tried one with some Neopixels before, because I was powering a Arduino with five volts and wanted to run the Neopixels from 3.7 volts, but they wouldn't work

  • @jeremymorris112
    @jeremymorris112 Před 3 lety

    @ 28:00 you mention another i2c video that would be out in "a couple of weeks" but a search through your channel didn't turn up the video, was it ever made? The proposed topics are of interest for a project I am working on. Thanks!

  • @ndk8111
    @ndk8111 Před 4 lety

    Can’t wait for multi master/slave video

  • @shaider1982
    @shaider1982 Před 4 lety

    Hi there. Is this more reliable than connecting the RPi to the Arduino via USB serial? I have been using that arrangement and once in a while, the arduino changes its address (ACM0 becomes ACM1). I am thinking this might be a more robust connection.

  • @N1ghtR1der666
    @N1ghtR1der666 Před 3 lety

    I have no trouble sending data from pi to arduino or from arduino ot pi but I cant work out both, I need 2 way communication, what would I need to change to get this going. simply adding the read and write commands to both causes either a communication error or causes the arduino to power cycle

  • @Frisky0563
    @Frisky0563 Před 4 lety

    Can we do SPI between the Pi and Arduino?

  • @tetraquark2402
    @tetraquark2402 Před 4 lety

    nice

  • @mathieugrenier1756
    @mathieugrenier1756 Před 3 lety

    Would it be possible to send a ps4 controller user inputs from a pi to an arduino mega using this method?

  • @oriwiesel5363
    @oriwiesel5363 Před 3 lety

    can someone please explain 13:46 for a dummy, what does he mean by pull up resistors that will pull the line up to 5V? I mean, isn't the arduino itself is pulling the line up to 5V?

  • @MartinFerenec
    @MartinFerenec Před 4 lety +1

    I would love to see a video how to have one Raspberry Pi (master unit server that does all the processing) and then multiple Arduino clients (over ethernet, they work as actuators; they send sensor data to rapsberry server and raspberry then sends data back on what port to turn on)

  • @consolenichecsn6930
    @consolenichecsn6930 Před 2 lety

    Great video. Didn't use the Arduino as a master and raspberry as a slave.

  • @orsimhon133
    @orsimhon133 Před 3 lety

    It is possible to do the same on (RPI Zero w & Teensy) or on (RPI Zero w & Arduino Nano) ?????

  • @bestest43
    @bestest43 Před 2 lety

    how does raspberry differ from being master to slave in the first and the second setups? Moreover, I couldn’t fully understand why we shouldn’t you use any other i2c device while we connect arduino and rasp?

  • @raisagorbachov
    @raisagorbachov Před 2 lety

    I2C on a Pi Pico would be interesting. That's the route I'm trying to follow - after I understand I2C a bit more.

  • @Lunarspear2023
    @Lunarspear2023 Před 2 lety

    Can anyone point me to the right way to send an array from arduino to raspberry pi over i2c? Sending from the py to arduino works as intended.

  • @net51cc
    @net51cc Před 2 lety

    Did you actually upload the video on using multiple i2c masters and extending the bus? I can't find it. BTW I love your videos.

  • @nagireddy3341
    @nagireddy3341 Před rokem

    Can we connect 5v operating sensor to Arduino while using i2c

  • @Actrl51
    @Actrl51 Před 4 lety

    Great tutorial as always, thank you!
    I have one question, is it possible to rather than just blink an led, use this method to send a specific IR signal through the NEC protocol? I followed your tutorial on that but I'm not sure how the Sketch should look for that to work. Thanks!

  • @francescolaporta9704
    @francescolaporta9704 Před 3 lety

    but what if i want to send strings? how can I do? can you give an example?

  • @user-qc9vz8nz7z
    @user-qc9vz8nz7z Před rokem

    Hello. I was able to connect the Raspberry pi 4 (Master) to arduino uno. It works perfectly. But when I want to install the 7inch touchscreen from Raspberry Pi, AND the arduino via i2c, there is a conflict and it stop working... Are there any clues you can share for this situation?. Thank you very much!

  • @420niles
    @420niles Před 3 lety

    How do you hook 128 devices up only a meter away from the master?

  • @jackd6134
    @jackd6134 Před 4 lety

    Love to watch this channel and one of the best instructional videos. But where can you purchase "a handful" of bidirectional converters for a "couple dollars" ? I'm finding one sells for $10 with shipping (Adafruit, Sparkfun) .

    • @mannhansen9337
      @mannhansen9337 Před 4 lety

      On Ebay you can buy a pack of 10 for $2-3 . From 2-8 pin converter.

  • @taranagnew436
    @taranagnew436 Před 4 lety +1

    what are you using to hold up the pliers and stuff?

    • @jjab99
      @jjab99 Před 4 lety

      There is a tour of the workshop where everything is described about all the storage solutions.
      czcams.com/video/n838ifEFGTk/video.html
      Follow the link and you will have your answers and lots more.
      Have Fun,
      Joe

  • @m.a.sherif6878
    @m.a.sherif6878 Před 4 lety +1

    don't really understand what these addresses are, where did you get them from or how do you know that is the address you are trying to access, can they be anything else like 0x9 for example. How do they actually work? . In the python program you had 0x0 and 0x1 where did you get them from or are they just simple address variables that can be declared/set to anything you want.

  • @karthikregu6952
    @karthikregu6952 Před 3 lety

    is it possible atmega 328 chip as i2c with out Arduino ,after programming in with Arduino

  • @MrFlae
    @MrFlae Před 4 měsíci

    Great video! What about connecting say 2 Arduino as slaves to a Pi as master, do we need that LLC?

  • @akshitsharma2737
    @akshitsharma2737 Před 4 lety +1

    do a video on stm32 board plz

  • @Fleurlean4
    @Fleurlean4 Před 4 lety +1

    Is the logic converter necessary? Why not just run the arduino at 3.3v?

    • @Fleurlean4
      @Fleurlean4 Před 4 lety +1

      I know you can’t make it run full speed clock but should still work.

  • @ivanrojas1475
    @ivanrojas1475 Před 2 lety

    PLEASE HELP, WHICH VERSION OF PYTHON IS HE USING? I used 3.9.0 and it doesn't recognize the smbus and also the smbus2

  • @aremumuiz6994
    @aremumuiz6994 Před 3 lety

    is it possible to expand or increase raspberry pi pico GPIO

  • @fsxaviator
    @fsxaviator Před 4 lety

    Can the code on the Raspberry Pi side be written in Java instead?