I2C between esp32 and Attiny85

Emygma
Posts: 4
Joined: Thu Apr 18, 2019 12:30 pm

I2C between esp32 and Attiny85

Postby Emygma » Wed Apr 24, 2019 1:57 pm

Hello,

I am attempting to communicate between Esp32 (devkit1 version) and ATTINY85 (digistump version) over I2C.

The attiny is a slave and the esp32 is the master, but for some reason, I cannot get it to work at all.

I tried the to run the master code on arduino UNO, where it works flawlessly and communicates with the attiny slave with no problems at all, so the slave isn't the problem here.
But with esp32 as a master, I can't even get it to see the slave.

I am using the pins 21 and 22, with 100000 frequency ( Wire.begin(21, 22, 100000);)

I have placed a 2k1 resistor between the 3v3pin and the 21 pin on the ESP32 and another between the 3v3 pin and the 22 pin to make sure both I2C lines are pulled up.

I also tried to run the example I2C scanner code to check if it sees the I2C device at all, but the scan reports that no I2C devices were found.

Code: Select all

#include <Arduino.h>
#include <Wire.h>
 
void setup() {
  Wire.begin(21, 22, 100000);
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; 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.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow 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);          
}
I am not sure why it isn't working, when it works without any problems on UNO.

Five_O
Posts: 5
Joined: Wed Apr 24, 2019 11:06 am

Re: I2C between esp32 and Attiny85

Postby Five_O » Fri Apr 26, 2019 10:46 am

Do You have grounds connected between each device?

Emygma
Posts: 4
Joined: Thu Apr 18, 2019 12:30 pm

Re: I2C between esp32 and Attiny85

Postby Emygma » Sun Apr 28, 2019 9:31 am

Five_O wrote:
Fri Apr 26, 2019 10:46 am
Do You have grounds connected between each device?
I do.

I managed to solve the problem.
It turned out, that the built in wire library for the esp32 arduino is very flaky (at least the i2c part), so I used a 3rd party library instead and now it is working as expected.

moibueno
Posts: 1
Joined: Wed Jan 06, 2021 4:33 pm

Re: I2C between esp32 and Attiny85

Postby moibueno » Wed Jan 06, 2021 4:35 pm

I'm dealing with the same problem. Could you share what library worked for you?

Who is online

Users browsing this forum: No registered users and 36 guests