Infineon Team
Published © MIT

MyIoT Adapter - Shield2Go Adapter for Arduino

Learn how to combine Infineons "2Go" boards with Arduino Uno boards in a plug and play manner while keeping your voltage levels right

BeginnerProtip1 hour501
MyIoT Adapter - Shield2Go Adapter for Arduino

Things used in this project

Story

Read more

Schematics

My IOT Adapter Fritzing

Code

MyIoT Example with 2 Shields2Go

Arduino
#include <Dps310.h>
#include <Tlv493d.h>

// Dps310 Object
Dps310 Dps310PressureSensor = Dps310();
// Tlv493d Object
Tlv493d Tlv493dMagnetic3DSensor = Tlv493d();

void setup()
{
  Serial.begin(9600);
  while (!Serial);


  //Call begin to initialize Dps310PressureSensor
  //The parameter 0x76 is the bus address. The default address is 0x77 and does not need to be given.
  //Dps310PressureSensor.begin(Wire, 0x76);
  //Use the commented line below instead of the one above to use the default I2C address.
  //if you are using the Pressure 3 click Board, you need 0x76
  Dps310PressureSensor.begin(Wire);
  Tlv493dMagnetic3DSensor.begin();
  Serial.println("Init complete!");
}

void loop()
{
  float temperature;
  float pressure;
  uint8_t oversampling = 7;
  int16_t ret;
  Serial.println();

  //lets the Dps310 perform a Single temperature measurement with the last (or standard) configuration
  //The result will be written to the paramerter temperature
  //ret = Dps310PressureSensor.measureTempOnce(temperature);
  //the commented line below does exactly the same as the one above, but you can also config the precision
  //oversampling can be a value from 0 to 7
  //the Dps 310 will perform 2^oversampling internal temperature measurements and combine them to one result with higher precision
  //measurements with higher precision take more time, consult datasheet for more information
  ret = Dps310PressureSensor.measureTempOnce(temperature, oversampling);

  if (ret != 0)
  {
    //Something went wrong.
    //Look at the library code for more information about return codes
    Serial.print("FAIL! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.println(" degrees of Celsius");
  }

  //Pressure measurement behaves like temperature measurement
  //ret = Dps310PressureSensor.measurePressureOnce(pressure);
  ret = Dps310PressureSensor.measurePressureOnce(pressure, oversampling);
  if (ret != 0)
  {
    //Something went wrong.
    //Look at the library code for more information about return codes
    Serial.print("FAIL! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.print("Pressure: ");
    Serial.print(pressure);
    Serial.println(" Pascal");
  }

  //Wait some time
  delay(1000);

  Tlv493dMagnetic3DSensor.updateData();
  delay(100);

  Serial.print("X = ");
  Serial.print(Tlv493dMagnetic3DSensor.getX());
  Serial.print(" mT; Y = ");
  Serial.print(Tlv493dMagnetic3DSensor.getY());
  Serial.print(" mT; Z = ");
  Serial.print(Tlv493dMagnetic3DSensor.getZ());
  Serial.println(" mT");
   
  delay(1000);
 
}

Credits

Infineon Team

Infineon Team

72 projects • 113 followers

Comments