Joining I2C bus as slave grounds SCL pin

Hi there, I'm trying to connect a Pixhawk Orange with an Arduino via I2C. I've created a barebones setup where the pins from the pixhawk (5V, GND, SDA_3.3v, SCL_3.3v) are connected to the appropriate pins of my slave arduino uno, with the two 3.3v level pins going through this level shifter first. The pixhawk is running an I2C scanner program to repeatedly scan every I2C address and report if one is found.

I couldn't get the two to connect to each other. While troubleshooting, I used a second arduino uno as a monitor to constantly read and print the SCL line. I found out that when the SCL pin is plugged into the slave arduino, the clock line goes from normal-looking to completely grounded. This turns out to only happen when the slave arduino joins the I2C bus (if I run a hello world blink LED program, this does not happen).

Interestingly enough, holding down the RESET button on the slave arduino does not resolve the issue; the SCL line remains grounded. However, if I upload code to it, the issue is briefly resolved while the slave arduino is being programming. Afterwards, however, the SCL line goes back to being grounded.

Any insight would be greatly appreciated, thank you.

Slave arduino code:

// for I2C communication
#include <Wire.h>

const int airspeed_i2c_address = 40;

const int board_addr = 8;

#define DEBUG_LED 2

int addr = board_addr;

void setup() {
  // put your setup code here, to run once:

  // configure test LEDs
  pinMode(DEBUG_LED, OUTPUT);

  digitalWrite(DEBUG_LED, LOW);

  Serial.begin(9600);
  
  Wire.begin(addr); // join i2c bus as follower

  Serial.println("Joined I2C Bus with address " + String(addr));
}

void loop() {
  // put your main code here, to run repeatedly:
}

Monitor arduino code:

#define SDA 3
#define SCL 2
#define SCL_3V3 A1

void setup() {
  // put your setup code here, to run once:
  pinMode(SDA, INPUT);
  pinMode(SCL, INPUT);
  pinMode(SCL_3V3, INPUT);

  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println(digitalRead(SCL));
}

I can not find which Arduino you're using as the slave?

I'm using an arduino uno for both the slave and monitor; I edited the original post to reflect this, thank you.

Valid I2C addresses should be higher than 8.

Your master code lacks a Wire.begin() that makes the related pin act as SCL/SDA. Okay if "monitor" does not mean "master".

Do you have installed pullup resistors on each part of the I2C bus?

Can you use another Arduino for the slave?

Does that pin conflict with SCL on that controller?
Remove the LED related code and try again.

Oh my god, thank you so much. I did have pullups on each I2C part via the level shifters, but you were right. I switched the address to 9 in the slave code and now it's working.

Glad to hear that :slight_smile:

Weren't it time now to update all the Arduino Wire examples not to use slave ID 8?

Or what's the truth about this I2C slave ID?
Wikipedia states that 8 is the reserved "SMBus Host" address.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.