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);
}