I2C with Arduino and Raspberry Pi – Two Methods

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 – https://dbot.ws/i2c3
More tutorials and articles – https://dronebotworkshop.com
Join us on the forum and have your say – https://forum.dronebotworkshop.com
Sign up for the newsletter – https://dbot.ws/dbnews
More code on GitHub – https://dbot.ws/github

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:

I2C Logic Levels – 3:42
Raspberry Pi I2C Busses – 6:47
Setting up the Raspberry Pi – 8:30
Direct Hookup – 14:15
Arduino Sketch – 15:35
Raspberry Pi Python Code – 17:31
Running the Demo – 20:30
Using a Logic Converter – 24:02

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.

source

You might be interested in