Wire.h - something changed

I had a project that was working fine. This morning I wanted to make a slight code change. When I uploaded, the include statement in my sketch showed <Wire.h> highlighted in brown with the following errors. Coincidentally enough, yesterday there was an update to Arduino IDE. Not sure if that had anything to do with it or not. Despite the error messages, it still allowed the upload to happen and the project stopped working. Tried re-adding the Wire library, as well as the AHT10 library. I had another sketch that I created for testing that is throwing the same errors as this sketch is.

/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp: In member function 'long unsigned int AHT10Class::readSensor(boolean)':
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:126:38: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
126 | Wire.requestFrom(AHT10_address, 6);
| ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:70:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
70 | uint8_t requestFrom(int, int);
| ^~~~~~~~~~~
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:68:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
68 | uint8_t requestFrom(uint8_t, uint8_t);
| ^~~~~~~~~~~
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp: In member function 'unsigned char AHT10Class::readStatus()':
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:149:38: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
149 | Wire.requestFrom(AHT10_address, 1);
| ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:70:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
70 | uint8_t requestFrom(int, int);
| ^~~~~~~~~~~
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:68:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
68 | uint8_t requestFrom(uint8_t, uint8_t);
| ^~~~~~~~~~~
Executable segment sizes:
ICACHE : 32768 - flash instruction cache
IROM : 294184 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 29460 / 32768 - code in IRAM (IRAM_ATTR, ISRs...)
DATA : 1576 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 2612 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 26640 ) - zeroed variables (global, static) in RAM/HEAP

The library is broken by multiple requestFrom() prototypes. Try to get the previous version or wait until the library is fixed.

Optionally comment out one of the requestFrom() prototypes.

Thanks for the reply. I'm not sure what any of that actually means. Is there an expected timeline for resolving? Or where to get a previous version?

Quick hack:
Locate Wire.h in your library folder.
Move the requestFrom() methods with uint8_t arguments from the public section up into the private section.

Thanks for that but unfortunately it had no effect. This is what my wire.h file looks like now:

#ifndef TwoWire_h
#define TwoWire_h

#include <inttypes.h>
#include "Stream.h"



#define BUFFER_LENGTH 128

class TwoWire : public Stream
{
private:
    static uint8_t rxBuffer[];
    static uint8_t rxBufferIndex;
    static uint8_t rxBufferLength;

    static uint8_t txAddress;
    static uint8_t txBuffer[];
    static uint8_t txBufferIndex;
    static uint8_t txBufferLength;
    
    uint8_t requestFrom(uint8_t, uint8_t);
    uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
    uint8_t requestFrom(int, int);
    uint8_t requestFrom(int, int, int);

    static uint8_t transmitting;
    static void (*user_onRequest)(void);
    static void (*user_onReceive)(size_t);
    static void onRequestService(void);
    static void onReceiveService(uint8_t*, size_t);
public:
    TwoWire();
    void begin(int sda, int scl);
    void begin(int sda, int scl, uint8_t address);
    void pins(int sda, int scl) __attribute__((deprecated)); // use begin(sda, scl) in new code
    void begin();
    void begin(uint8_t);
    void begin(int);
    void setClock(uint32_t);
    void setClockStretchLimit(uint32_t);
    void beginTransmission(uint8_t);
    void beginTransmission(int);
    uint8_t endTransmission(void);
    uint8_t endTransmission(uint8_t);
    size_t requestFrom(uint8_t address, size_t size, bool sendStop);
    uint8_t status();

    virtual size_t write(uint8_t);
    virtual size_t write(const uint8_t *, size_t);
    virtual int available(void);
    virtual int read(void);
    virtual int peek(void);
    virtual void flush(void);
    void onReceive(void (*)(int));      // arduino api
    void onReceive(void (*)(size_t));   // legacy esp8266 backward compatibility
    void onRequest(void (*)(void));

    using Print::write;
};

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE)
extern TwoWire Wire;
#endif

#endif

It now gives me these errors:

/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp: In member function 'long unsigned int AHT10Class::readSensor(boolean)':
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:126:38: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  126 |     Wire.requestFrom(AHT10_address, 6);
      |                                      ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:48:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
   48 |     uint8_t requestFrom(int, int);
      |             ^~~~~~~~~~~
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:46:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
   46 |     uint8_t requestFrom(uint8_t, uint8_t);
      |             ^~~~~~~~~~~
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:126:38: error: 'uint8_t TwoWire::requestFrom(int, int)' is private within this context
  126 |     Wire.requestFrom(AHT10_address, 6);
      |                                      ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:48:13: note: declared private here
   48 |     uint8_t requestFrom(int, int);
      |             ^~~~~~~~~~~
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp: In member function 'unsigned char AHT10Class::readStatus()':
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:149:38: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  149 |     Wire.requestFrom(AHT10_address, 1);
      |                                      ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:48:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
   48 |     uint8_t requestFrom(int, int);
      |             ^~~~~~~~~~~
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:46:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
   46 |     uint8_t requestFrom(uint8_t, uint8_t);
      |             ^~~~~~~~~~~
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:149:38: error: 'uint8_t TwoWire::requestFrom(int, int)' is private within this context
  149 |     Wire.requestFrom(AHT10_address, 1);
      |                                      ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:48:13: note: declared private here
   48 |     uint8_t requestFrom(int, int);
      |             ^~~~~~~~~~~

exit status 1

Compilation error: exit status 1

When something does not compile in ESP8266, I use version 2.7.4

It looks like you use an ESP8266 and have to make the changes there as well.

That is where I made these changes, in the ESP8266 folder

Do you still have errors reported? Warnings are less important right now.

Yes. Still getting warnings. It uploaded to the board okay but nothing on the serial monitor.

That's a different problem. Please describe and post related code.

I tried it with a different sketch that also used wire.h and the aht10.h and it threw warnings, but I'm getting output on the serial monitor.

/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp: In member function 'long unsigned int AHT10Class::readSensor(boolean)':
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:126:38: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  126 |     Wire.requestFrom(AHT10_address, 6);
      |                                      ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:70:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
   70 |     uint8_t requestFrom(int, int);
      |             ^~~~~~~~~~~
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:68:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
   68 |     uint8_t requestFrom(uint8_t, uint8_t);
      |             ^~~~~~~~~~~
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp: In member function 'unsigned char AHT10Class::readStatus()':
/Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:149:38: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  149 |     Wire.requestFrom(AHT10_address, 1);
      |                                      ^
In file included from /Users/zcrow/Arduino/libraries/AHT10TK/src/AHT10.cpp:29:
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:70:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
   70 |     uint8_t requestFrom(int, int);
      |             ^~~~~~~~~~~
/Users/zcrow/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/Wire/Wire.h:68:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
   68 |     uint8_t requestFrom(uint8_t, uint8_t);
      |             ^~~~~~~~~~~
Executable segment sizes:
ICACHE : 32768           - flash instruction cache 
IROM   : 240676          - code in flash         (default or ICACHE_FLASH_ATTR) 
IRAM   : 27913   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...) 
DATA   : 1516  )         - initialized variables (global, static) in RAM/HEAP 
RODATA : 936   ) / 81920 - constants             (global, static) in RAM/HEAP 
BSS    : 26152 )         - zeroed variables      (global, static) in RAM/HEAP 

You should not include multiple Wire libraries. Decide which one you really want to use.

The aht10.h library I'm using doesn't include wire.h in it so I'm loading wire.h separately

Which AHT10 library do you use ?
I suggest to keep Wire.h original and change the I2C address to 'int'.
In the AHT10.h file, change this:

uint8_t          _address;

to this:

int          _address;

Then everything is 'int'. If you use a other library, change the 'AHT10_address' to 'int'.

I'm afraid there will no solution. The parameter types are different on different platforms. I can not find that someone set a goal to solve this. It just lingers on :cry:
My opinion is that the sketch should be simple and that the Wire library should deal with every combination of 'int' and 'uin8_t'.

Okay will give that a try. Thanks

Or cast the parameter to 'int' in every call.

Wire.requestFrom( (int) AHT10_address, 1);   // using 'int' to avoid compiler warnings

I am using a different AHT10 library. Seems that something happened recently and the old library isn't working as it should. The new library has stopped throwing any warnings.

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