New contribution: HTU31D temperature sensor library

I’ve modified the HTU21D(F) I2C library to support the HTU31D temperature and humidity sensor:

Would be great to get it moved to the mogoose-os-libs org in Github.

I don’t think you need CONTRIBUTING.md. AFAIK, the author of the htu21df-i2c library works for Google.

You don’t need to declare mgos_htu31d_i2c_init. The name is generated by the build process from the name of the library, and it’s not meant to be called by the user. The library must implement it.

There are some formatting errors when building for ESP8266:

/data/fwbuild-volumes/latest/apps/htu31-demo/esp8266/build_contexts/build_ctx_321248439/deps/htu31d-i2c/src/mgos_htu31d.c: In function 'mgos_htu31d_create':
/data/fwbuild-volumes/latest/apps/htu31-demo/esp8266/build_contexts/build_ctx_321248439/deps/htu31d-i2c/src/mgos_htu31d.c:91:20: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   91 |     LOG(LL_DEBUG, ("HTU31D serial number %02x created at I2C 0x%02x", version, sensor->i2caddr));
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~
      |                                                                       |
      |                                                                       uint32_t {aka long unsigned int}
/mongoose-os/include/common/cs_dbg.h:114:21: note: in definition of macro 'LOG'
  114 |       cs_log_printf x;                                \
      |                     ^
/data/fwbuild-volumes/latest/apps/htu31-demo/esp8266/build_contexts/build_ctx_321248439/deps/htu31d-i2c/src/mgos_htu31d.c:91:45: note: format string is defined here
   91 |     LOG(LL_DEBUG, ("HTU31D serial number %02x created at I2C 0x%02x", version, sensor->i2caddr));
      |                                          ~~~^
      |                                             |
      |                                             unsigned int
      |                                          %02lx

It would be nice to format the code using clang-format using .clang-format which is used by most of the mos libraries, mongoose-os, mjs, frozen.

Awesome thanks for the tips @nliviu will have a go at that

Fixed (I think), let me know if it’s OK on your side @nliviu

Looks good.
Created htu31d-i2c and added you as admin.

Done @nliviu, if there is anything else required let me know. I’ve tested my personal project and it seems to be working OK