Hi,
Is it possible to use two SHT31 with a Teensy 3.5. I know the description says there are just two pins 19 and 18 for SDA and SCL. Please advise. Below is the code I used for a single sensor.
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
#include <SPI.h>
#include <SoftwareSerial.h>
#if defined(ARDUINO_ARCH_SAMD) || defined(__SAM3X8E__)
#define lcd Serial1
#else
#include <SoftwareSerial.h>
SoftwareSerial lcd = SoftwareSerial(0, 7); //lcd tx pin = 7
#endif
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.setSDA(A15);// A15 SCL
Wire.setSCL(A14);//A14 SDA
SPI.begin(); // Init SPI bus
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("SHT31 test");
if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr
Serial.println("Couldn't find SHT31");
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 = sht31.readTemperature();
float h = sht31.readHumidity();
if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.println(t);
} 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");
}
Serial.println();
delay(1000);
}
Is it possible to use two SHT31 with a Teensy 3.5. I know the description says there are just two pins 19 and 18 for SDA and SCL. Please advise. Below is the code I used for a single sensor.
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
#include <SPI.h>
#include <SoftwareSerial.h>
#if defined(ARDUINO_ARCH_SAMD) || defined(__SAM3X8E__)
#define lcd Serial1
#else
#include <SoftwareSerial.h>
SoftwareSerial lcd = SoftwareSerial(0, 7); //lcd tx pin = 7
#endif
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.setSDA(A15);// A15 SCL
Wire.setSCL(A14);//A14 SDA
SPI.begin(); // Init SPI bus
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("SHT31 test");
if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr
Serial.println("Couldn't find SHT31");
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 = sht31.readTemperature();
float h = sht31.readHumidity();
if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.println(t);
} 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");
}
Serial.println();
delay(1000);
}