I2C Part 2 - Build ...
 
Notifications
Clear all

I2C Part 2 - Build a I2C Sensor

3 Posts
3 Users
0 Likes
1,034 Views
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1073
Topic starter  

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

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. 

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:

00:00 - Introduction
01:26 - I2C Protocol and Addressing
07:14 - Ultrasonic Sensor Wiring and Testing
14:09 - Remote I2C Sensor Intro
19:21 - Remote I2C Sensor Code

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.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
Quote
(@khurram)
Member
Joined: 2 years ago
Posts: 1
 

Thanks for posting an excellent tutorial. Although the topic of your video is "building an i2c sensor", but i am struggling to find some information about building a true i2c sensor. If I have a bunch of analog sensors like pressure, distance or temperature with analog current or voltage signal, how can I connect them as slave directly to a microcontroller over i2c line? There are many dedicated i2c sensors available but I would like to build an i2c sensor board with specific sensor of my choice.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6861
 

@khurram Check out a company called WaveShare, they have a few interesting I2C products.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote