RobTillaart / SHT85

Arduino library for the SHT85 temperature and humidity sensor
MIT License
11 stars 4 forks source link

Demo fails to compiule #26

Open mitra42 opened 6 hours ago

mitra42 commented 6 hours ago

None of the demos that I tried managed to compile e.g. examples/SHT85_demo_plotter/SHT85_demo_plotter.ino

I'm using the esp32->Lolin Wemos D1 Mini, - if I set to Arduino Uno it compiles

I tried various permutations of including Wire.h and attempting to include code from the SHT31_SW library, but nothing I tried worked.

Note ... you don't need a board to repeat this - simply setting the board type makes it fail to compile

Note that the SHT31_SW library demos fail to compile on either Arduino Uno or Lolin Wemos D1 Mini see https://github.com/RobTillaart/SHT31_SW/issues/14

I'll do some research and see if I can figure out what is going on, but since I haven't used I2C (or TwoWire or Softwire) I'm not sure where to start.

/private/var/folders/h7/r6nsnp591vq9t17_q33mks_c0000gn/T/.arduinoIDE-unsaved2024820-15193-1hk34uu.tyqqf/sketch_sep20a/sketch_sep20a.ino:18:29: error: invalid conversion from 'int' to 'TwoWire*' [-fpermissive]
   18 | #define SHT85_ADDRESS       0x44
      |                             ^~~~
      |                             |
      |                             int
/private/var/folders/h7/r6nsnp591vq9t17_q33mks_c0000gn/T/.arduinoIDE-unsaved2024820-15193-1hk34uu.tyqqf/sketch_sep20a/sketch_sep20a.ino:27:11: note: in expansion of macro 'SHT85_ADDRESS'
   27 | SHT85 sht(SHT85_ADDRESS);
      |           ^~~~~~~~~~~~~
In file included from /private/var/folders/h7/r6nsnp591vq9t17_q33mks_c0000gn/T/.arduinoIDE-unsaved2024820-15193-1hk34uu.tyqqf/sketch_sep20a/sketch_sep20a.ino:16:
/Users/mitra/Documents/Arduino/libraries/SHT85/SHT85.h:184:18: note:   initializing argument 1 of 'SHT85::SHT85(TwoWire*)'
  184 |   SHT85(TwoWire *wire = &Wire);
      |         ~~~~~~~~~^~~~~~~~~~~~

exit status 1

Compilation error: invalid conversion from 'int' to 'TwoWire*' [-fpermissive]
RobTillaart commented 4 hours ago

@mitra42 This sounds like a bug I had in a few other libraries too, good you found it The cause is that the Arduino interface differs slightly over platforms.

Will create a develop branch asap with a fix. Give me half an hour. Can you do a verification with HW as I have no Lolin nearby.

RobTillaart commented 4 hours ago

If you patch the example sketch

define SHT85_ADDRESS ((uint8_t)0x44)

RobTillaart commented 4 hours ago

I'm using the esp32->Lolin Wemos D1 Mini,

I do not have that one in my boards set, need to install it (takes some extra time).

RobTillaart commented 4 hours ago

Created a develop branch with a minimal patch. Build-CI has started, If you have time please try this develop branch.

RobTillaart commented 4 hours ago

@mitra42

/Users/mitra/Documents/Arduino/libraries/SHT85/SHT85.h:184:18: ... 184 | SHT85(TwoWire *wire = &Wire);

Which version of the library did you test with?
As my constructor definition in SHT85.h (0.6.0) does not have that version. (Looks like 0.5.x version or earlier)

From 0.6.0 SHT85.h

class SHT85 : public SHT
{
public:
  SHT85(uint8_t address, TwoWire *wire = &Wire);

  //  catch incorrect calls with an address, only 0x44 allowed, see #19
  bool begin();

  //  EXPERIMENTAL for 0.4.1
  uint32_t GetSerialNumber();
};
RobTillaart commented 4 hours ago

@mitra42 BUild-CI was successfull - https://github.com/RobTillaart/SHT85/actions/runs/10960803780

Ran for these platforms - uno, m4, esp32, esp8266, rpipico

So please download the develop branch and check if the fixes work for you.