Link between Arduino clock speed and I2C clock speed?

I recently switched from using a 5V 16Mhz Arduino pro micro to a 3.3V 8Mhz one. I kept the exact same wiring as before, and I checked it numerous times with a multimeter, so the issue doesn't come from bad wiring.

I'm trying to communicate with a magnetometer sensor through I2C, and it worked on the 16Mhz board, and now it doesn't, at all : the I2C scanner code doesn't find any adress connected to the arduino.

So, my thinking is it has to do with the difference in clock frequency, although I tried changing the I2C clock speed, to no avail. Voltage isn't the issue, the sensor is made to run on 3.3v.

How can I check if the clock speed is the issue ?

But if you kept the exact same wiring it probably doesn't.

I2C pullups should be different for 5V and 3.3V.

Post your wiring diagram, schematics of the breakout board of your magnetometer and links to it's datasheet.

Most probably it's isn't a clock speed problem.

1 Like

No such problem because the I2C clock only is generated by the bus master, the slaves have to obey.

Use a level shifter to increase the 3.3V signals to 5V expected by 5V slaves.

I didn't use any external pull-up on the 5V board, so I think the 3.3V board should work the same, no ?

Here's what you asked :

Magnetometer datasheet

Are you in fact using the Adafruit LIS3MDL magnetometer module?

That has level converters on SDA and SCL, and should work with 5V or 3.3V Arduinos.

The red wire should go from Vcc on the Arduino to Vin on the magnetometer module, NOT 3VO as diagrammed. If you really did wire it that way using a 5V Arduino, you may have destroyed the magnetometer.

Well, I'm using the one I ordered from here, so I think so ? Unless I'm really missing something.

Oh, it is indeed a mistake in the diagram, I wired it to the VIN, not 3Vo.

So, in theory, it should be able to work ? Then, what could cause this ?

A problem with the code you forgot to post.

Oh, right, sorry, I used this code, that I found on the I2Cscanner arduino page :

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
 
#include <Wire.h>
 
 
void setup()
{
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

Bad solder joints? Post a clear, close up, focused picture of your setup.

The soldering is pretty bad indeed ( I'm not good at soldering, and it's supposed to be as small as possible, so it's hard to do ), but I checked it with a multimeter, each wire seems to have the correct current when plugged in.

Here are the pictures, theres a second sensor that I hadn't mentionned before, a transistor and a vibrating motor, but they're ( I think ) irrelevant to the issue. I couldn't get a picture of the magnetometer, since it's soldered right below the other sensor ( an accelerometer ).

Also : I know it's pretty terrible, I did my best x)

The soldering is almost certainly the problem. You may have a short circuit or low resistance connection from excess flux between two adjacent pins.

There are good tutorials on Adafruit and Sparkfun. Study them and practice on discarded PCBs.

For temporary projects, solder header pins to the MCU and sensor modules, and mount them on a solderless breadboard, using solid wire jumpers for connections.

Okay, well, I guess I'll have to desolder all that, and try again x)
I especially struggle with having the 2 sensors right on top of each other, how would you advise soldering them ? Right now there's really short wires that goes between each ports they have in common, then the top sensor is connected to the board. Is there a better way ?

Hello again !
I desoldered everything, and layed it out on a breadboard and... no result. Damn. Here are pictures, it's wired exactly like before, I can't start to figure why it's not working, the ports are clean, and I don't think the sensor is dead..? It lights up when I plug it in.

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