How to send loong string via Wire connection (L2C) from Arduino UNO to ESP8266

Heloł friends,

Is it possible to send String longer than 32 bytes via Wires connection (L2C) From Arduino Uno to ESP8266.

I use in my sketch :

On Arduino Uno : Wire.write("longer than 32 bytes ..... ");

On ESP8266 :

Wire.requestFrom(8, 50);    // request 50 bytes from slave device #8

  while (Wire.available()) { // slave may send less than requested
    char c =;
    Serial.print(c);         // print the character

When i set 50 bytes, and send on ARDUINO UNO almost 50 bytes, i have the result on ESP8266 Serial: ���������������������������������������������������A�������������������������������������������������A�������������������������������������������������A�������������������������������������������������A�������������������������������������������������

When i set smaller than 32 bytes in requestFrom in ESP8266 , and send from Arudino UNO to ESP8266, string smaller than 32 bytes, the result is ok.. How can i repair it?

I changed the buffer size in wire.h but it doesn't get expected result

Nobody? :frowning: It's essential issue for me :frowning:

An ESP8266 is a WIFI module with a 32bit processor on it. It's able to communicate via UART or SPI, but I haven't found any reference of a I2C capability (in the hardware). So using the Wire library doesn't make sense here. Your code was wrong even if the ESP8266 was an I2C device but a description isn't suitable without a description of the corresponding I2C commands (which would have been found in the datasheet).

If you want to get help with your project, provide information about what software is loaded on the ESP8266 and how you connected it to the Arduino.

Thanks for replay friend.

I have ESP8266 WIFI + Nodemcu V2. (firmware 0.9.6)
This model :

On the website is information than this one has I2C connection. I use a SDA, SDL pins to connect my ESP8266 with Arduino Uno

ESP8266 pins : D1, D2 <-----connection by wires—> pins: A4,A5 on Arduino Uno board.

Shetch on ESP8266 :

#include <Wire.h>

void setup() {
          // join i2c bus (address optional for master)
  // start serial for output
void loop2(){
  Wire.beginTransmission(8); // transmit to device #8
  Wire.write("ESP8266");        // sends five bytes
              // sends one byte

  String b;
void loop1() {
   // transmit to device #8
              // sends one byte
     // stop transmitting
  Wire.requestFrom(8, 50);    // request 6 bytes from slave device #8

  while (Wire.available()) { // slave may send less than requested
    char c =;
    b+=c;// receive a byte as character
    Serial.print(c);         // print the character


void loop(){

Sketch on Ardunio Uno :

 #include <Arduino.h>
#include "NMEAGPS.h"
#include <Wire.h>

//  Program: NMEAloc.ino
//  Description:  This program only parses an RMC sentence for the lat/lon.
//  Prerequisites:
//     1) NMEA.ino works with your device (correct TX/RX pins and baud rate)
//     2) The RMC sentence has been enabled.
//     3) Your device sends an RMC sentence (e.g., $GPRMC).
//  'Serial' is for debug output to the Serial Monitor window.

#if defined( UBRR1H ) | defined( ID_USART0 )
  // Default is to use Serial1 when available.  You could also
  // use NeoHWSerial, especially if you want to handle GPS characters
  // in an Interrupt Service Routine.
  //#include <NeoHWSerial.h>
  // Only one serial port is available, uncomment one of the following:
  //#include <NeoICSerial.h>
 #include "AltSoftSerial.h"
  //#include <NeoSWSerial.h>
 // #include <SoftwareSerial.h> /* NOT RECOMMENDED */
#include "GPSport.h"

//#ifdef NeoHWSerial_h
 // #define DEBUG_PORT NeoSerial

  #define DEBUG_PORT Serial

String character="";
String content="";
String b="";
float dl;
float sz;
String szerokosc="brakdanych";
String dlugosc="brakdanych";
String testik[5]="beb";
String kable="";
String sent;
String StanKabla="None";

// Check that the config files are set up properly

#if !defined( NMEAGPS_PARSE_RMC )
  #error You must uncomment NMEAGPS_PARSE_RMC in NMEAGPS_cfg.h!

#if !defined( GPS_FIX_TIME )
  #error You must uncomment GPS_FIX_TIME in GPSfix_cfg.h!

#if !defined( GPS_FIX_LOCATION )
  #error You must uncomment GPS_FIX_LOCATION in GPSfix_cfg.h!

#if !defined( GPS_FIX_SPEED )
  #error You must uncomment GPS_FIX_SPEED in GPSfix_cfg.h!

#if !defined( GPS_FIX_SATELLITES )
  #error You must uncomment GPS_FIX_SATELLITES in GPSfix_cfg.h!

  #error You must *NOT* define NMEAGPS_INTERRUPT_PROCESSING in NMEAGPS_cfg.h!


static NMEAGPS  gps; // This parses the GPS characters


static void printL( Print & outs, int32_t degE7 );
static void printL( Print & outs, int32_t degE7 )
  // Extract and print negative sign
  if (degE7 < 0) {
    degE7 = -degE7;
    outs.print( '-' );

  // Whole degrees
  int32_t deg = degE7 / 10000000L;
  outs.print( deg );
  outs.print( '.' );

  // Get fractional degrees
  degE7 -= deg*10000000L;

  // Print leading zeroes, if needed
  int32_t factor = 1000000L;
  while ((degE7 < factor) && (factor > 1L)){
    outs.print( '0' );
    factor /= 10L;
  // Print fractional degrees
  outs.print( degE7 );

static void doSomeWork();
static void doSomeWork( const gps_fix & fix )
  //  This is the best place to do your time-consuming work, right after
  //     the RMC sentence was received.  If you do anything in "loop()",
  //     you could cause GPS characters to be lost, and you will not
  //     get a good lat/lon.
  //  For this example, we just print the lat/lon.  If you print too much,
  //     this routine will not get back to "loop()" in time to process
  //     the next set of GPS data.

  if (fix.valid.location) {

      //DEBUG_PORT.print( '0' );
    //DEBUG_PORT.print( fix.dateTime.seconds );
    //DEBUG_PORT.print( ',' );
    // DEBUG_PORT.print( fix.latitude(), 6 ); // floating-point display
    // DEBUG_PORT.print( fix.latitudeL() ); // integer display
      dl= ( fix.latitudeL());
      dlugosc= String(fix.latitude(), 6);
    //printL( dł, fix.latitudeL() ); // prints int like a float
    //DEBUG_PORT.print( ',' );
     szerokosc=String( fix.longitude(), 6 ); // floating-point display
    // DEBUG_PORT.print( fix.longitudeL() ); // integer display
    sz=( fix.longitudeL() );
    //printL( DEBUG_PORT, fix.longitudeL() ); // prints int like a float

    //DEBUG_PORT.print( ',' );
    if (fix.valid.satellites){
      //DEBUG_PORT.print( fix.satellites );

    //DEBUG_PORT.print( ',' );
    //DEBUG_PORT.print( fix.speed(), 6 );
    //DEBUG_PORT.print( F(" kn = ") );
    //DEBUG_PORT.print( fix.speed_mph(), 6 );
    //DEBUG_PORT.print( F(" mph") );

  } else {
    // No valid location data yet!
    //DEBUG_PORT.print( "zmien miejsce GPS-a bo nie łapie sygnału z satelity !!!");
    //dlugosc="zmien lokalizacje";


  }else{dlugosc="zmien";}} // doSomeWork


static void GPSloop();
static void GPSloop()

  //if(!=-1){ ;doSomeWork( );} else{
if(gps.available( gps_port )>0 )   {
  if({doSomeWork( );
  StanKabla="Polaczony";}else{  StanKabla="brak";
  }else{  StanKabla="brak";

String bebe="";
void setup()

 while (!DEBUG_PORT)


  // Start the UART for the GPS device



void loop()




//funkcja sprawdzajaca kabel podlaczeniowy do GPS



void receiveEvent(int bytes)
  while (Wire.available()>0) { // slave may send less than requested
    int e=0;
    char u[7];
     u[e] =;
     //break;         // receive a byte as character
     //stringOne +=  String(c);

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent() {

 // t.c_str()
  //Wire.write("aabababbabababbabababaabbbbbbba");// respond with message of 6 bytes
  // as expected by master

The main idea :

  • Send small data from ESP8266 to Arduino Uno - working ok.
  • Send data from GPS to Arduino UNO - working ok.
  • Send data (long data like,longer than 32bytes: “testtesttesttest123456789876543321234556778”) from ARDUINO UNO to ESP8266. it isn’t working.

Helppp :frowning:

ESP8266 does not have I2C hardware.

I2C can be implemented in software by bit-banging.


but… on the website, the give information that esp8266 nodemcu v2, support L2C, and I use the wire library to send a data with replay and it’s working, but not for longer data than 20 bytes…

So, what is the best way to send data and replay From ESP8266 Nodemcu V2 <–> Arduino Uno ?

but… on the website, the give information that esp8266 nodemcu v2, support L2C,
So, what is the best way to send data and replay From ESP8266 Nodemcu V2 <–> Arduino Uno ?

Being argumentative is not going to help here… just because the ESP8266 does not have hardware I2C does not mean you cannot use the I2C protocol … it just means that user code (and clocks cycles) have to be utilized.

Do not believe marketing on a website - you may know more than the person that wrote the advertisement.

I have no idea what is best for you, but the easiest to implement is likely plain-old ASCII serial data: Google this “esp8266 to arduino serial connection”


Thanks but, i tried a connection via normal, old type serial but it isn’t working on my esp8266, could you help me?

  • Send small data from ESP8266 to Arduino Uno - working ok.

Are you saying that you successfully transmitted data from the ESP8266 to the Arduino using I2C?

If so, that would suggest that this model does have some sort of I2C connection (possibly bit-banged).

In that case, to send more than 32 bytes in one transmission, you will have to find all the libraries (for both processors) and increase the buffer size from 32 bytes to something else.

I did IT . I changed a buffor size in Wire.h from 32 to 64 bytes , but the regult in sending data didn't change

I did IT . I changed a buffor size in Wire.h from 32 to 64 bytes , but the regult in sending data didn't change

One more time...
The ESP8266 does not have hardware I2C but it does have bit-band [bit-bang] I2C capability. You MUST use libraries that understand I2C bit-bang and do not make assumptions.

There are a lots of I2C examples for the ESP8266; for example the OLED displays. Find the examples, find out how they manage I2C (it will be bit-banged) and take it from there.


Added Google search ...

The module you bought is made for standalone usage (using the integrated MCU) and not as a Wifi module for the Arduino. If you want to control it from the Arduino you have to load software on it to do that. That software may even use the I2C interface but that may be a bigger challenge.
I would suggest to implement your project in LUA on the ESP8266 or buy an ESP8266 wifi module for Arduino (without NodeMCU) and use the UART interface.