I2C Setup - Can't find devices

I’m a bit confused over how I2C really works. I made the setup displayed below. The two sensors are both a JSN-SR04T, but they have the same pinout as the HC-SR04 (Vin, Trig, Echo, Gnd).Both sensors work fine on their own. However, when I use the I2C Scanner, I can’t find either sensor. They do get powered (red light on breakout board lighting up)

What am I doing wrong in this setup? One thing about I2C that I do not understand is that while D1/D0 function as SDA/SCL, these ultrasonic sensors have a Trig/Echo pin instead. Am I wrong in trying to connect them in this way?

Essentially they are not I2C devices which is why the scanner did not work.

What happens with an ultrasonic distance sensor is that a wave gets sent out (once you trig) and an echo come back, calculating the time taken to estimate the distance.

It seems like you are connecting the trig and echo pins together. Probably need to use a separate set for each of them. :slight_smile:

3 Likes

Aha, I see. Yeah, come to think of it, first thing I should’ve done was to check if they were even an I2C device :sweat_smile:

I have some ultrasonic sensors that are in fact I2C, so that’s where the assumption must’ve come from. I’ll just give them each their own set of pins :slight_smile:

EDIT: I did find some examples of the HC-SR04 being used as an I2C device, but upon closer inspection they also used the AT-Tiny with it. But since I don’t need an excessive number of sensors, using two more pins on the Electron is fine :slight_smile:

1 Like