Problème de librairie modifiée VELM6075+DS28E17

Bonjour à tous,

Cela fait trois jours que je galère sur cette modification de librairie sans réussir à me défaire des erreurs…

J’essaye de communiquer avec un VELM6075 (I2C) sur une grande distance via une passerelle 1-Wire/I2C, le DS28E17. Ce dernier fonctionne puisque je communique déjà avec un BME280 sur le réseau I2C distant avec une librairie dédiée.

J’adapte actuellement le librairie de DFRobot originale disponible ici : VEML6075
La librairie pour le DS28E17 dispo ici : DS28E17

Même en me référent aux exemple, je n’arrive pas à adapter la librairie… Actuellement cela coince au niveau des fonctions dépendantes de begin().
Est ce que quelqu’un pourrait gracieusement vérifier les codes?

Mes codes:

DFRobot_VEML6075_1-Wire.h

#ifndef DFROBOT_VEML6075_H
#define DFROBOT_VEML6075_H
#include "Arduino.h"
#include <OneWire.h>
#include "DS28E17.h"

// globals
#define VEML6075_ID_DEFAULT   0x26
#define VEML6075_ADDR         0x10
#define UVI_LOW         2.0f
#define UVI_MODERATE    5.0f
#define UVI_HIGH        7.0f
#define UVI_VERY_HIGH   10.0f
#define UVI_EXTREME     12.0f
#define Uvi2mwpcm2(UVI) (UVI * 2500.0f)

// registers
#define VEML6075_CONF       0x00
#define VEML6075_CONF_DEFAULT   0x00
#define VEML6075_UVA        0x07
#define VEML6075_UVB        0x09
#define VEML6075_UV_COMP1   0x0a
#define VEML6075_UV_COMP2   0x0b
#define VEML6075_ID         0x0c

// utils
typedef enum {
  eVEML6075PowerOn,
  eVEML6075PowerOff
} eVEML6075Power_t;

typedef enum {
  eVEML6075ActiveForceModeDisable,
  eVEML6075ActiveForceModeEnable,
} eVEML6075ActiveForceMode_t;

// write to register VEML6075_REG_CONFIG_UV_TRIG to start one measurement if VEML6075_REG_CONFIG_UV_AF = 1
#define VEML6075_TRIG_ONE_MEASUREMENT   1

// write to register VEML6075_REG_CONFIG_HD to set dynamic
typedef enum {
  eVEML6075DynamicNormal,
  eVEML6075DynamicHigh
} eVEML6075Dynamic_t;

// write to register VEML6075_REG_CONFIG_UV_IT to set integration time, for data process
typedef enum {
  eVEML6075UV_IT_50,
  eVEML6075UV_IT_100,
  eVEML6075UV_IT_200,
  eVEML6075UV_IT_400,
  eVEML6075UV_IT_800
} eVEML6075UV_IT_t;

typedef struct {
  uint8_t   SD: 1;
  uint8_t   UV_AF: 1;
  uint8_t   UV_TRIG: 1;
  uint8_t   HD: 1;
  uint8_t   UV_IT: 3;
  uint8_t   reserved1: 1;
  uint8_t   reserved2;
} sVEML6075Conf_t;

// main class
class DFRobot_VEML6075
{
// functions
  private:
    /*
     * @brief       Pointer to OneWire object.
     */
    OneWire *oneWire;
    
    /*
     * @brief       DS28E17 (1-wire <-> I2C converter) object.
     */
    DS28E17 ds28e17;
 
public:
  DFRobot_VEML6075(OneWire *oneWire);

  boolean   begin();

// config functions
void    setPower(eVEML6075Power_t ePower);
void    setActiveForceMode(eVEML6075ActiveForceMode_t eMode);
void    trigOneMeasurement();
void    setDynamic(eVEML6075Dynamic_t eDynamic);
void    setIntegrationTime(eVEML6075UV_IT_t eUV_IT);
  
eVEML6075Power_t    getPower();
eVEML6075ActiveForceMode_t    getActiveForceMode();
eVEML6075Dynamic_t  getDynamic();
eVEML6075UV_IT_t    getIntegrationTime();

// data process functions
uint16_t  readUvaRaw();
uint16_t  readUvbRaw();
uint16_t  readUvComp1Raw();
uint16_t  readUvComp2Raw();
float     getUva();
float     getUvb();
float     getUvi(float Uva, float Uvb);

// variables
protected:
eVEML6075ActiveForceMode_t    _eActiveForceMode;

eVEML6075UV_IT_t    _eUV_IT;
};
#endif

DFRobot_VEML6075_1-Wire.cpp

#include <DFRobot_VEML6075_1-Wire.h>
#include "Arduino.h"

#define UVA_A_COEF    2.22f
#define UVA_B_COEF    1.33f
#define UVA_C_COEF    2.95f
#define UVA_D_COEF    1.74f
#define UV_ALPHA      1.0
#define UV_BETA       1.0
#define UV_GAMMA      1.0
#define UV_DELTA      1.0
#define UVA_RESPONSIVITY_100MS    0.001111
#define UVB_RESPONSIVITY_100MS    0.00125

DFRobot_VEML6075::DFRobot_VEML6075(OneWire *ow)
{
  oneWire = ow;
  ds28e17 = DS28E17(ow);
}

const float UvaResponsivityList[5] = {
UVA_RESPONSIVITY_100MS / 0.5016286645, // 50ms
UVA_RESPONSIVITY_100MS,                // 100ms
UVA_RESPONSIVITY_100MS / 2.039087948,  // 200ms
UVA_RESPONSIVITY_100MS / 3.781758958,  // 400ms
UVA_RESPONSIVITY_100MS / 7.371335505   // 800ms
};

const float UvbResponsivityList[5] = {
UVB_RESPONSIVITY_100MS / 0.5016286645, // 50ms
UVB_RESPONSIVITY_100MS,                // 100ms
UVB_RESPONSIVITY_100MS / 2.039087948,  // 200ms
UVB_RESPONSIVITY_100MS / 3.781758958,  // 400ms
UVB_RESPONSIVITY_100MS / 7.371335505   // 800ms
};

boolean DFRobot_VEML6075::begin()
{
uint16_t   tmp = 0;
ds28e17.memoryWrite(VEML6075_ADDR, VEML6075_ID, (uint8_t*) &tmp, sizeof(tmp));
if(tmp == VEML6075_ID_DEFAULT) {
  tmp = VEML6075_CONF_DEFAULT;
  ds28e17.memoryWrite(VEML6075_ADDR, VEML6075_CONF, (uint8_t*) &tmp, sizeof(tmp));
  setPower(eVEML6075PowerOn);
  setActiveForceMode(eVEML6075ActiveForceModeDisable);
  setIntegrationTime(eVEML6075UV_IT_100);
  return true;
  }
return false;
}

#define writeRegBits(reg, buf, bits, value) \
readReg((reg), (uint8_t*) &buf, sizeof(buf)); \
(bits) = (value); \
writeReg((reg), (uint8_t*) &buf, sizeof(buf))

// main class config functions
void DFRobot_VEML6075::setPower(eVEML6075Power_t ePower)
{
sVEML6075Conf_t   sConf;
ds28e17.memoryWrite(VEML6075_CONF, sConf, sConf.SD, ePower);
}

void DFRobot_VEML6075::setActiveForceMode(eVEML6075ActiveForceMode_t eMode)
{
sVEML6075Conf_t   sConf;
ds28e17.memoryWrite(VEML6075_CONF, sConf, sConf.UV_AF, eMode);
_eActiveForceMode = eMode;
}

void DFRobot_VEML6075::setDynamic(eVEML6075Dynamic_t eDynamic)
{
sVEML6075Conf_t   sConf;
ds28e17.memoryWrite(VEML6075_CONF, sConf, sConf.HD, eDynamic);
}

void DFRobot_VEML6075::setIntegrationTime(eVEML6075UV_IT_t eUV_IT)
{
sVEML6075Conf_t   sConf;
ds28e17.memoryWrite(VEML6075_CONF, sConf, sConf.UV_IT, eUV_IT);
_eUV_IT = eUV_IT;
}

void DFRobot_VEML6075::trigOneMeasurement()
{
if(_eActiveForceMode == eVEML6075ActiveForceModeEnable) {
  sVEML6075Conf_t   sConf;
  ds28e17.memoryWrite(VEML6075_CONF, sConf, sConf.UV_TRIG, VEML6075_TRIG_ONE_MEASUREMENT);
  }
}

eVEML6075ActiveForceMode_t DFRobot_VEML6075::getActiveForceMode()
{
sVEML6075Conf_t   sConf;
ds28e17.read(VEML6075_CONF, (uint8_t*) &sConf, sizeof(sConf));
return (eVEML6075ActiveForceMode_t) sConf.UV_AF;
}

eVEML6075Dynamic_t DFRobot_VEML6075::getDynamic()
{
sVEML6075Conf_t   sConf;
ds28e17.read(VEML6075_CONF, (uint8_t*) &sConf, sizeof(sConf));
return (eVEML6075Dynamic_t) sConf.HD;
}

eVEML6075Power_t DFRobot_VEML6075::getPower()
{
sVEML6075Conf_t   sConf;
ds28e17.read(VEML6075_CONF, (uint8_t*) &sConf, sizeof(sConf));
return (eVEML6075Power_t) sConf.SD;
}

eVEML6075UV_IT_t DFRobot_VEML6075::getIntegrationTime()
{
sVEML6075Conf_t   sConf;
ds28e17.read(VEML6075_CONF, (uint8_t*) &sConf, sizeof(sConf));
return (eVEML6075UV_IT_t) sConf.UV_IT;
}

// main class process functions
uint16_t DFRobot_VEML6075::readUvComp1Raw()
{
uint16_t    tmp;
ds28e17.write(VEML6075_UV_COMP1, (uint8_t*) &tmp, sizeof(tmp));
return tmp;
}

uint16_t DFRobot_VEML6075::readUvComp2Raw()
{
uint16_t    tmp;
ds28e17.write(VEML6075_UV_COMP2, (uint8_t*) &tmp, sizeof(tmp));
return tmp;
}

uint16_t DFRobot_VEML6075::readUvaRaw()
{
uint16_t    tmp;
ds28e17.write(VEML6075_UVA, (uint8_t*) &tmp, sizeof(tmp));
return tmp;
}

uint16_t DFRobot_VEML6075::readUvbRaw()
{
uint16_t    tmp;
ds28e17.write(VEML6075_UVB, (uint8_t*) &tmp, sizeof(tmp));
return tmp;
}

float DFRobot_VEML6075::getUva()
{
return ((float) readUvaRaw() - ((UVA_A_COEF * UV_ALPHA * (float) readUvComp1Raw()) / UV_GAMMA)
                             - ((UVA_B_COEF * UV_ALPHA * (float) readUvComp2Raw()) / UV_DELTA));
}

float DFRobot_VEML6075::getUvb()
{
return ((float) readUvbRaw() - ((UVA_C_COEF * UV_BETA * (float) readUvComp1Raw()) / UV_GAMMA)
                             - ((UVA_D_COEF * UV_BETA * (float) readUvComp2Raw()) / UV_DELTA));
}

float DFRobot_VEML6075::getUvi(float Uva, float Uvb)
{
Uva = (Uva * (1.0f / UV_ALPHA) * UvaResponsivityList[(uint8_t) _eUV_IT]);
Uvb = (Uvb * (1.0f / UV_BETA) * UvbResponsivityList[(uint8_t) _eUV_IT]);
return (Uva + Uvb) / 2.0f;
}