Infineon/arduino-xensiv-dps3xx

Multiple i2c device resets MCU

Zia0815 opened this issue · 2 comments

Using the HDC302X along with DPS310 with the i2c bus

I have a board with the sensors HDC302X and DPS310 integrated, and they both run on the i2c bus. There is no hardware related issue. For the HDC302X I have used the HDC302x library by Sander Schinkelshoek. If I run on the i2c example of the DPS310, the device runs fines and shows the pressure properly. When I run the HDC302x example, the device runs fine showing the temperature and humidity. When I try to integrate the two sets of code, the device shows the temperature and humidity but restarts immediately when it tries to read the pressure. I recreated the code with the Adafruit_DPS310 library. With this there were no issues. The device worked fine. Shows all the results of temperature, pressure and humidity. It seems to me that there some issue with this library on terminating the i2c communication.

Here is the code which I used to test the device -

  #include "Arduino.h"
  #include "HDC302x.h" 
  #include <Dps3xx.h>
  
  // Dps310 Opject
  Dps3xx Dps3xxPressureSensor = Dps3xx();
  
  HDC302x hdc = HDC302x(); // Preselected I2C Address
  
  void setup()
  {
    pinMode(8, OUTPUT);
    digitalWrite(8, HIGH);

    Serial.begin(115200);                  // Init the serial device
    Serial.println("Ola! Feeling chill?"); // Welcome message

    if (!hdc.Initialize(HDC302X_ADDRESS1)) // Did the initialization fail?
    {
        Serial.println("Sorry, cannot find sensor with the selected address");
    }
    Dps3xxPressureSensor.begin(Wire);
  }
  
  void loop()
  {   // Dps310PressureSensor.end();

    // hdc.Initialize(HDC302X_ADDRESS1);

    HDC302xDataResult result = hdc.ReadData(); // Calculate the temperature

    Serial.print("Temperature is ");  // Begin printing output
    Serial.print(result.Temperature); // Print the Temperature
    Serial.print(" C, Humidity is "); // Print the degrees plus a newline
    Serial.println(result.Humidity);  // Print the Temperature

    delay(1000); // Wait 5 seconds

    result = hdc.ReadData(); // Calculate the temperature

    Serial.print("2nd Temperature is "); // Begin printing output
    Serial.print(result.Temperature);    // Print the Temperature
    Serial.print(" C, Humidity is ");    // Print the degrees plus a newline
    Serial.println(result.Humidity);     // Print the Temperature

    Serial.println();
    Serial.println();

    delay(5);
    // Wire.endTransmission();
    // Dps310PressureSensor.begin(Wire);

    delay(10);
    float temperature;
    float pressure;
    uint8_t oversampling = 7;
    int16_t ret;
    Serial.println(__LINE__);

    ret = Dps3xxPressureSensor.measurePressureOnce(pressure, oversampling);

    Serial.print("Pressure is "); // Begin printing output
    Serial.println(pressure);     // Print

    Serial.println();
    Serial.println();


    delay(1000); // Wait 5 seconds
 }

This issue is stale because it has been open for 6 weeks with no activity. Please comment to this issue if it's still relevant.

This issue was closed because it has been stalled for 1 week with no activity.