HI,
Im trysint to read from two SHT31 sensors, but keep getting errors using this library, can anyone please advise?
Im trysint to read from two SHT31 sensors, but keep getting errors using this library, can anyone please advise?
Code:
#include <i2c_t3.h>
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
#include <SPI.h>
#include <SoftwareSerial.h>
SoftwareSerial lcd = SoftwareSerial(0, 7); //lcd tx pin = 7
//#include <i2c_t3.h>
Adafruit_SHT31 sht31a = Adafruit_SHT31();
Adafruit_SHT31 sht31b = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
Wire.begin(I2C_MASTER, 0x44, 33, 34);
Wire1.begin(I2C_MASTER, 0x45, 37, 38);
SPI.begin(); // Init SPI bus
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("SHT31 test");
if (! sht31a.begin(0x44)) { // first sensor with default address
Serial.println("Couldn't find SHT31 #1");
while (1) delay(1);
}
if (! sht31b.begin(0x45)) { // second sensor with secondary address
Serial.println("Couldn't find SHT31 #2");
while (1) delay(1);
}
lcd.begin(9600); //initializes lcd
lcd.write(0xFE); //screen size
lcd.write(0xD1);
lcd.write(16);
lcd.write(2);
}
void loop() {
float t = sht31a.readTemperature();
float h = sht31a.readHumidity();
float t2 = sht31b.readTemperature();
float h2 = sht31b.readHumidity();
if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.println(t);
} else {
Serial.println("Failed to read temperature");
}
delay (100);
if (! isnan(t2)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.println(t2);
} else {
Serial.println("Failed to read temperature");
}
if (! isnan(h)) { // check if 'is not a number'
Serial.print("Hum. % = "); Serial.println(h);
lcd.write(0xFE);
lcd.write(0x58);
lcd.print("Hum. % = "); lcd.println(h);
} else {
Serial.println("Failed to read humidity");
}
delay (100);
if (! isnan(h2)) { // check if 'is not a number'
Serial.print("Hum. % = "); Serial.println(h2);
lcd.write(0xFE);
lcd.write(0x58);
lcd.print("Hum. % = "); lcd.println(h2);
} else {
Serial.println("Failed to read humidity");
Serial.println();
delay(1000);
}
}
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/Wire.h:26:0,
from C:\Users\kedar\Dropbox\code\SHT31test_teensy\SHT31test_teensy.ino:16:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:215:16: error: conflicting declaration 'TwoWire Wire'
extern TwoWire Wire;
^
In file included from C:\Users\kedar\Dropbox\code\SHT31test_teensy\SHT31test_teensy.ino:1:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3-master/i2c_t3.h:989:15: note: previous declaration as 'i2c_t3 Wire'
extern i2c_t3 Wire;
^
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/Wire.h:26:0,
from C:\Users\kedar\Dropbox\code\SHT31test_teensy\SHT31test_teensy.ino:16:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:218:16: error: conflicting declaration 'TwoWire Wire1'
extern TwoWire Wire1;
^
In file included from C:\Users\kedar\Dropbox\code\SHT31test_teensy\SHT31test_teensy.ino:1:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3-master/i2c_t3.h:991:19: note: previous declaration as 'i2c_t3 Wire1'
extern i2c_t3 Wire1;
^
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/Wire.h:26:0,
from C:\Users\kedar\Dropbox\code\SHT31test_teensy\SHT31test_teensy.ino:16:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:221:16: error: conflicting declaration 'TwoWire Wire2'
extern TwoWire Wire2;
^
In file included from C:\Users\kedar\Dropbox\code\SHT31test_teensy\SHT31test_teensy.ino:1:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3-master/i2c_t3.h:994:19: note: previous declaration as 'i2c_t3 Wire2'
extern i2c_t3 Wire2;
^
Error compiling for board Teensy 3.5.