mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-31 19:05:44 +00:00
Further (non-working) progress in SEN5X
This commit is contained in:
parent
d7bb0f7cdf
commit
f43fbe0068
@ -522,12 +522,12 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
case ICM20948_ADDR_ALT: // same as MPU6050_ADDR
|
||||
// ICM20948 Register check
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1);
|
||||
prod = readSEN5xProductName(i2cBus, addr.address);
|
||||
if (registerValue == 0xEA) {
|
||||
type = ICM20948;
|
||||
logFoundDevice("ICM20948", (uint8_t)addr.address);
|
||||
break;
|
||||
} else {
|
||||
prod = readSEN5xProductName(i2cBus, addr.address);
|
||||
if (prod.startsWith("SEN55")) {
|
||||
type = SEN5X;
|
||||
logFoundDevice("Sensirion SEN55", addr.address);
|
||||
|
@ -101,6 +101,7 @@ bool SEN5XSensor::sendCommand(uint16_t command, uint8_t* buffer, uint8_t byteNum
|
||||
}
|
||||
|
||||
// Transmit the data
|
||||
LOG_INFO("Beginning connection to SEN5X: 0x%x", address);
|
||||
bus->beginTransmission(address);
|
||||
size_t writtenBytes = bus->write(toSend, bufferSize);
|
||||
uint8_t i2c_error = bus->endTransmission();
|
||||
@ -164,17 +165,33 @@ uint8_t SEN5XSensor::CRC(uint8_t* buffer)
|
||||
return crc;
|
||||
}
|
||||
|
||||
bool SEN5XSensor::I2Cdetect(TwoWire *_Wire, uint8_t address)
|
||||
{
|
||||
_Wire->beginTransmission(address);
|
||||
byte error = _Wire->endTransmission();
|
||||
|
||||
if (error == 0) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
int32_t SEN5XSensor::runOnce()
|
||||
{
|
||||
state = SEN5X_NOT_DETECTED;
|
||||
LOG_INFO("Init sensor: %s", sensorName);
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
bus = nodeTelemetrySensorsMap[sensorType].second;
|
||||
address = (uint8_t)nodeTelemetrySensorsMap[sensorType].first;
|
||||
// sen5x.begin(*bus);
|
||||
|
||||
delay(50); // without this there is an error on the deviceReset function
|
||||
if (!I2Cdetect(bus, address)) {
|
||||
LOG_INFO("SEN5X ERROR no device found on adress");
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
delay(25);
|
||||
|
||||
if (!sendCommand(SEN5X_RESET)) {
|
||||
LOG_ERROR("SEN5X: Error reseting device");
|
||||
|
@ -49,6 +49,7 @@ class SEN5XSensor : public TelemetrySensor
|
||||
bool sendCommand(uint16_t wichCommand, uint8_t* buffer, uint8_t byteNumber=0);
|
||||
uint8_t readBuffer(uint8_t* buffer, uint8_t byteNumber); // Return number of bytes received
|
||||
uint8_t CRC(uint8_t* buffer);
|
||||
bool I2Cdetect(TwoWire *_Wire, uint8_t address);
|
||||
|
||||
protected:
|
||||
virtual void setup() override;
|
||||
|
Loading…
Reference in New Issue
Block a user