Temperature and Humidity Sensor *HELP*

Hey, guys I’m a physics student who’s in a bit of a bind. I can’t figure out this code for the following project. I’ve tried to compile it and I just get the error “Wire1 was not declared in this scope”. Any ideas???
Thanks!
#include <CommunicationProtocol.h>

#include <SHTSensorDue.h>

#include <Wire.h>
CommunicationProtocol protocol(4, 5, 10000);

SHTSensor sht(2, 0x44);

void setup() {
// put your setup code here, to run once:
Wire.begin();
Wire1.begin();
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
if (sht.init()) {
Serial.print(“init(): success\n”);
} else {
Serial.print(“init(): failed\n”);
}
sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x

if (sht.readSample()) {
Serial.print(“SHT:\n”);
Serial.print(" RH: “);
Serial.print(sht.getHumidity(), 2);
Serial.print(”\n");
Serial.print(" T: “);
Serial.print(sht.getTemperature(), 2);
Serial.print(”\n");
} else {
Serial.print(“Error in readSample()\n”);
}

delay(1000);

}

test_i2C.ino (859 Bytes)

use code tags, “</>” button, and post the contents of your sketch between the tags so readers don’t have to download your sketch and open Arduino just to read it.

Why are you trying to initialize 2 instances of wire? isn’t I2C a party line?

Wire.begin();
Wire1.begin();

Please, tell us about the type of the Temp/Humidity Sensor that you are using. The commonly used sensors are: DHT11 (1-Wire), DHT22 (1-Wire), BME280 (I2C), SHT1x (?), and HSM-20G (analog).

I’m using an SHT31-DIS-B sensor. @Perema I’m not sure what you mean. I’m a very early programmer and was given this code as well as the Leonardo itself.
#include <CommunicationProtocol.h>

#include <SHTSensorDue.h>

#include <Wire.h>
CommunicationProtocol protocol(4, 5, 10000);

SHTSensor sht(2, 0x44);

void setup() {
// put your setup code here, to run once:
Wire.begin();
Wire1.begin();
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
if (sht.init()) {
Serial.print(“init(): success\n”);
} else {
Serial.print(“init(): failed\n”);
}
sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x

if (sht.readSample()) {
Serial.print(“SHT:\n”);
Serial.print(" RH: “);
Serial.print(sht.getHumidity(), 2);
Serial.print(”\n");
Serial.print(" T: “);
Serial.print(sht.getTemperature(), 2);
Serial.print(”\n");
} else {
Serial.print(“Error in readSample()\n”);
}

delay(1000);

}

Try the following example (taken from IDE ) on UNO with this Library.

/*
 * Processes in Nature (not the journal) does not takes _relative_ humidity into account.
 * They takes into account _absolute_ humidity (water vapor pressure).
 * So, that library supports vapor pressure calculation.
 * All pressure scales I found in Wikipedia are available:  
 *    mmHg, Torr,
      Pa,   Bar,
      At    (Techical atmosphere),
      Atm   (Standart atmosphere),
      mH2O, //O is the letter, not zero
      psi,
 * (check SHT3x.h, "enum AbsHumidityScale").
 * The absolute humidity tolerance could be recieved in same scales too.
 */


#include <SHT3x.h>
SHT3x Sensor;
void setup() {
  
  Serial.begin(19200);
  Sensor.Begin();
}

void loop() {
  Sensor.UpdateData();
  
  Serial.print(Sensor.GetTemperature()); //Celsius
  Serial.write("\xC2\xB0"); //The Degree symbol
  Serial.print("C");
  Serial.print(" | ");
  
  Serial.print(Sensor.GetRelHumidity());
  Serial.print("%");
  Serial.print(" | ");

  Serial.print(Sensor.GetAbsHumidity()); //Torr by default
  Serial.print(" Torr");
  Serial.print(" | ");

  Serial.print(Sensor.GetAbsHumidity(SHT3x::psi)); //Torr by default
  Serial.print(" psi");
  Serial.print(" | ");

  Serial.print(Sensor.GetAbsHumidity(SHT3x::Pa)); //Torr by default
  Serial.print(" Pa");

  //And other...

  Serial.print(" Tolerance: ±");
  Serial.print(Sensor.GetAbsHumTolerance(SHT3x::mH2O));
  Serial.print(" mH2O");
  

  Serial.println();
  delay(333);
}

rtyu670:
I'm using an SHT31-DIS-B sensor. @Perema I'm not sure what you mean. I'm a very early programmer and was given this code as well as the Leonardo itself.

Leonardo? Why are you using code probably written for a Due?