Skip to content

LIDAR Lite V3 HP with ESP32 #24

@Speedy2k

Description

@Speedy2k

Currently it seems that the ESP32 wire library doesn support the 5 params requestFrom() command. So as it is now, your library isn't compatible with ESP32. I have modified your read() function to be compatible on the ESP32, i am unshure it is the best way to do it, but it is working on my setup.!

`void LIDARLite_v3HP::read(uint8_t regAddr, uint8_t * dataBytes,
uint8_t numBytes, uint8_t lidarliteAddress)
{
// This single function performs the following actions -
// 1) I2C START
// 2) I2C write to set the address
// 3) I2C REPEATED START
// 4) I2C read to fetch the required data
// 5) I2C STOP
Wire.beginTransmission(lidarliteAddress);
Wire.write(regAddr);
if(!Wire.endTransmission()){
Wire.requestFrom
(
lidarliteAddress, // Slave address
numBytes, // number of consecutive bytes to read
//regAddr, // address of first register to read
//1, // number of bytes in regAddr
true // true = set STOP condition following I2C read
);

	uint8_t  numHere = Wire.available();
	uint8_t  i       = 0;
	while (i < numHere)
	{
		dataBytes[i] = Wire.read();
		i++;
	}
	delayMicroseconds(100); // 100 us delay for robustness with successive reads and writes
}else{
	Serial.println("> nack");
}

} /* LIDARLite_v3HP::read */`

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