"Wire.h - requestFrom" Error Warning

Hello!! :slight_smile:

I see that related issues have been asked before, but after exhaustive research, I have been unable to find neither an explanation of the problem nor a solution.

This is my setup:

  • OS: Ubuntu 20.04
  • Arduino IDE: 2.0.4
  • Board: Version 1.0.6 of the ESP32 library.

This are the libraries I'm importing:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#include "Wire.h"
#include <Arduino.h>
#include <ADS1115_WE.h>
#include "EEPROM.h"

#include "Seeed_SHT35.h"

And this is the error I get went trying to compile:

In file included from /home/lisandro/Escritorio/1 - MECA trabajos/Zaxis - Flow Meter Study/Principal References/FlowMeter Prototype/Original Zaxis Code References/Flow_Controller/Flow_Controller.ino:6:0:
/home/lisandro/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Wire/src/Wire.h: In function 'void ReadDif()':
/home/lisandro/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Wire/src/Wire.h:103:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)
     uint8_t requestFrom(int address, int size);
             ^
/home/lisandro/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Wire/src/Wire.h:101:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)
     uint8_t requestFrom(uint8_t address, uint8_t size);
             ^
In file included from /home/lisandro/Arduino/libraries/Grove_-_I2C_High_Accuracy_Temp_Humi_Sensor_SHT35/Seeed_SHT35.h:36:0,
                 from /home/lisandro/Arduino/libraries/Grove_-_I2C_High_Accuracy_Temp_Humi_Sensor_SHT35/Seeed_SHT35.cpp:32:
/home/lisandro/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Wire/src/Wire.h: In member function 'err_t SHT_IIC_OPRTS::request_bytes(u8*, u16)':
/home/lisandro/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Wire/src/Wire.h:103:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)
     uint8_t requestFrom(int address, int size);
             ^
/home/lisandro/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Wire/src/Wire.h:101:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)
     uint8_t requestFrom(uint8_t address, uint8_t size);
             ^
Sketch uses 245282 bytes (18%) of program storage space. Maximum is 1310720 bytes.
Global variables use 15272 bytes (4%) of dynamic memory, leaving 312408 bytes for local variables. Maximum is 327680 bytes.

The code seems to compile though, so I'm not sure either if this is ok and I can upload it.

Any hint will be much appreciated. Thank you in advance!!

Welcome to the forum.

I think that you don't need all the includes.
Could you try to change this:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#include "Wire.h"
#include <Arduino.h>
#include <ADS1115_WE.h>
#include "EEPROM.h"

#include "Seeed_SHT35.h"

with this:

#include <Wire.h>
#include <ADS1115_WE.h>
#include <Seeed_SHT35.h>
#include <EEPROM.h>

The problem that you have is a sadly a known and common problem. There is no good documentation and no good rules for the parameters of the functions of the Wire library. A library written for a different board might not work on your ESP32.

Could you show the sketch ?
You have to change the parameters of Wire.requestFrom() in the function ReadDif().
I'm afraid that you also have to change the code of the Seeed SHT35 library.

For example in the file: https://github.com/Seeed-Studio/Seeed_SHT35/blob/master/Seeed_SHT35.cpp
You could replace this:

    Wire.requestFrom(_IIC_ADDR, data_len);
    while (data_len != Wire.available()) {
        time_out_count++;
        if (time_out_count > 10) {
            return ERROR_COMM;
        }
        delay(1);
    }

with this:

  Wire.requestFrom( (int) _IIC_ADDR, (int) data_len);
  if(data_len != Wire.available()) {
    return ERROR_COMM;
  }

There might be better libraries.

Are you using the EEPROM of the ESP32 ? It does not have an internal EEPROM. It emulates the EEPROM with its Flash memory.

1 Like

Thank you so much!!! And sorry for the delay in my response :pray:

No words to thank you enough for such a fast and precise answer. You landed every hit, thank you for sharing such expertise.

I implemented the exact modifications you indicated. And to be precise for the part of

You have to change the parameters of Wire.requestFrom() in the function ReadDif().

The code indeed was starting with:

void ReadDif()
{
  Wire.requestFrom(address, 2);

Your hint made me realize that "2" was causing the problem, so I casted it with:

// Diff Sensor setup
uint8_t address = 0x28;
uint8_t size = 2;

void ReadDif()
{
  Wire.requestFrom(address, size);

And finally the code compiled without a single error.

Thank you so much, you helped/saved me with this one. I hope this will be useful for anyone else having the same problem! :grin:

Why are you using such an old version of the ESP32 Package?

Hi gfvalvo :slight_smile:

I'm developing a firmware for a device I was given with the indication that that version was needed in order for the two kernels of the ESP32 to work properly (it's working indeed). I have enough to do, so I didn't want to question that :sweat_smile:

Sorry, I forgot to answer that: the libraries I'm using for the "EEPROM" are for ESP32, so I asume they take care of that and let you work like if you do have an EEPROM. It works so far!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.