I2C Part 2 – Build a I2C Sensor
In the second look at I2C, we will design our own I2C sensor. We’ll also look at the protocol used to exchange data on the I2C bus.
Full article with code at https://dbot.ws/i2cpart2
More articles and tutorials at https://dronebotworkshop.com
Want to suggest new content? Join the newsletter at https://dbot.ws/dbnews
We are back working with the I2C bus, this time to examine the protocol used to exchange data on the bus. We will also look at the addressing scheme.
Then we will take four HC-SR04 ultrasonic distance sensors and create our own I2C sensor using them.
A lot of inspiration for this came from an excellent video by Andreas Spiess, the ”guy with the Swiss accent”. In his video, he created a 3-sensor device using an ATtiny85. You can check it out at https://www.youtube.com/watch?v=aLkkAsrSibo.
In my implementation, I used an Arduino Uno, but this is only to make development a bit easier. If I were to create a permanent version of this sensor I would probably use either an Arduino Pro Mini (which would also allow a 3.3-volt version to be created) or an ATmega328 chip.
Here is the outline of today’s video:
I2C Protocol and Addressing – 1:26
Ultrasonic Sensor Wiring and Testing – 7:14
Remote I2C Sensor Intro – 14:09
Remote I2C Sensor Code – 19:21
While this sensor certainly could be improved upon it should serve to illustrate how easy it is to create your own I2C device.
You can get all of the code that I used in this video at https://dbot.ws/i2cpart2.
By the way, the next video will be a subject that was suggested to me by some of my viewers. If you would like to have a say in what subjects I create articles and videos about please join the newsletter. Every newsletter (and the welcoming letter) has a link to a survey you can fill out to let me know what content YOU would like to see me create. You can join at https://dbot.ws/dbnews.
And, of course, if you haven’t subscribed to the channel please do me the honor of having you as one of my subscribers.
Thank s, I hope you enjoy the video!
source