Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By mojESP8266
#42116 I am finally back to this project. I have received Logic level shifter.

So i am trying to connect Arduino and Esp8266 through I2c.

On ESP8266 i have connected pins(5, 14)
On Arduino i have connected pins (A4, A5)
Between them i used Logic Level Shifter(also connected ground and 3.3V and 5V).

Now the simple code example:

ESP8266 Master:
Code: Select all#include <Wire.h>
#include <ESP8266WiFi.h>

int x = 0;
   
void setup() {   
   
  Serial.begin(115200);
 
  // Start the I2C Bus as Master
  Wire.begin(5,14);
 
}

void loop() {

  Wire.beginTransmission(9); // transmit to device #8
  Wire.write("x is ");        // sends five bytes
  Wire.write(x);              // sends one byte
  Wire.endTransmission();    // stop transmitting

  Serial.println(x);
 
  x++;
  delay(500);
}


Arduino Slave
Code: Select all#include <Wire.h>

void setup()
{
  Wire.begin(9);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop()
{
  delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  while (1 < Wire.available()) // loop through all but the last
  {
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  int x = Wire.read();    // receive byte as an integer
  Serial.println(x);         // print the integer
}


PROBLEM :evil: :
Serial Monitor on Arduino is empty(not showing C or X value). Serial Monitor on ESP is showing X value.

Is something wrong with bound rate on Arduino? What am i missing here?