Skip to content

Sensor VEML770 data not change (Wire) #1657

Closed
@asetyde

Description

@asetyde

Hardware:

Board: ESP32 Wroom
Core Installation/update date: 1.0.0_rc3
IDE name: Arduino ide 1.8.5 and visual micro
Flash Frequency: 80Mhz
Upload Speed: 115200

Description:

Sensor VEML770 data not change after commit a59eafb before, data is updated correctly and sensor work, I've tried to go back with git but too many error with esptool, it's not possibile create a special realese before 27 June ?, too many big commit to find error .

Sensor VEML770 use wire, i2c;

Debug Messages:

none

Activity

stickbreaker

stickbreaker commented on Jul 19, 2018

@stickbreaker
Contributor

@asetyde there was one significant change to Wire() with this last update, A Wire() transaction with SENDSTOP=FALSE is queued until a transaction with SENDSTOP=TRUE is send. This is necessitated because the ESP32 i2c hardware will go into a lockedup state if the transaction is not completed with a STOP within 13.1 ms.
So, this queuing is necessary, the Wire() library reports the queued status by returning a ERROR=7 (continue) for all calls that use a ReSTART operation, for example:

// set i2c device internal register pointer and read 20 bytes from there
Wire.beginTransmission(id);
Wire.write(registerHigh);
Wire.write(registerLow);
uint8_t err = Wire.endTransmission(false);
// since sendStop==false, this write() command was queued until a stop if issued, so the returned status
// is set to 7 (continue) to indicate this.
 
if( err!=7){ // something went wrong
  Serial.printf("Error setting register pointer =%d (%s)",Wire.lastError(),Wire.getErrorText(Wire.lastError()));
}
else { // read from device 
  uint8_t count = Wire.requestFrom(id,20); // sendStop==true, default argument value if not explicitly set
  if(count == 0){ // error condition for requestFrom()
    Serial.printf("Error reading data =%d (%s)",Wire.lastError(),Wire.getErrorText(Wire.lastError()));
  }
else {
 while(Wire.available()){
   Serial.printf("0x%02x ",Wire.read());
}
Serial.println();
}

Chuck.

asetyde

asetyde commented on Jul 19, 2018

@asetyde
Author

schermata 2018-07-19 alle 15 40 30
as you can see , light sensor (Sensore Luce) report always same value, there are no debug wire print about strange events.
SHT21 sensor hasn't this issue but code is more recent, I'm not expert of i2c, I not see particular point to change in sensor library
https://github.com/Ribster/arduino-VEML7700

asetyde

asetyde commented on Jul 19, 2018

@asetyde
Author

( Also I've tried to restore to 27 June i2c.h/c and wire.cpp/wire.h but came many strange errors on WIFI generic and WIFISTA files .. on complier )
At now I can't ve idea to correct it

stickbreaker

stickbreaker commented on Jul 19, 2018

@stickbreaker
Contributor

@asetyde I'll look through that library and see if I can find any problem.

Chuck.

asetyde

asetyde commented on Jul 19, 2018

@asetyde
Author

Many many thanks @stickbreaker !

stickbreaker

stickbreaker commented on Jul 19, 2018

@stickbreaker
Contributor

@asetyde found one Wire.endTransmission(false), I'll keep looking through the code.

Chuck.

stickbreaker

stickbreaker commented on Jul 19, 2018

@stickbreaker
Contributor

@asetyde change this code in the VELM7700.cpp from:

uint8_t
VEML7700::
receiveData(uint8_t command, uint16_t& data)
{
  Wire.beginTransmission(I2C_ADDRESS);
  if (Wire.write(command) != 1){
    return STATUS_ERROR;
  }
  if (Wire.endTransmission(false)){  // NB: don't send stop here
    return STATUS_ERROR;
  }
  if (Wire.requestFrom(uint8_t(I2C_ADDRESS), uint8_t(2)) != 2){
    return STATUS_ERROR;
  }
  data = Wire.read();
  data |= uint16_t(Wire.read()) << 8;
  return STATUS_OK;
}

to:

uint8_t
VEML7700::
receiveData(uint8_t command, uint16_t& data)
{
  Wire.beginTransmission(I2C_ADDRESS);
  if (Wire.write(command) != 1){
    return STATUS_ERROR;
  }
  if (Wire.endTransmission(false) != 7 ){  // NB: don't send stop here
    return STATUS_ERROR;
  }
  if (Wire.requestFrom(uint8_t(I2C_ADDRESS), uint8_t(2)) != 2){
    return STATUS_ERROR;
  }
  data = Wire.read();
  data |= uint16_t(Wire.read()) << 8;
  return STATUS_OK;
}

Chuck.

asetyde

asetyde commented on Jul 19, 2018

@asetyde
Author

Seems worked !!!

asetyde

asetyde commented on Jul 19, 2018

@asetyde
Author

many many thanks chuck !

asetyde

asetyde commented on Jul 30, 2018

@asetyde
Author

Sorry but with last 1.0.0 sensor FAIL @stickbreaker

stickbreaker

stickbreaker commented on Jul 31, 2018

@stickbreaker
Contributor

@asetyde I think I found another problem in i2c.

I posted an updated esp32-hal-i2c.c in #1694. Try it. I think both of these are the same problem.

Chuck.

asetyde

asetyde commented on Jul 31, 2018

@asetyde
Author

it's fixed for me @stickbreaker !! do you fix on library ?

20 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Sensor VEML770 data not change (Wire) · Issue #1657 · espressif/arduino-esp32