i am trying to communicate between ESP(master) and arduino nano(slave). This is only a prototype and all works fine. But i want to add multiple arduinos and therefor i need to detect if the arduino is connected.
I use the return function from wire.endTransmission as shown in i2c scanner to detect devices. But it doesnt work.
On the arduino i have this program:
#include <Wire.h>
const int16_t I2C_SLAVE = 0x22; // 0x22 = 34 cize izba 3(30)
void setup() {
Wire.begin(I2C_SLAVE);
}
void loop() {
// put your main code here, to run repeatedly:
}
on the ESP i am trying this:
Wire.beginTransmission(I2C_adress[adress]);
int error = Wire.endTransmission();
Serial.println(error);
It returns only 2 (received NACK on transmit of address) Why? When i have other code on the slave (with onRecive and onRequest all works and comunicates)
Thank you.