Open
Description
Subject of the issue
Conflict between SHT21 and SGP30 in the same I2C circuit
Your workbench
- Platform ESP8266
- Device ESP8266 WEMOS D1
- I2C Connected in SDA-SCL Line
- I2C Connected to +3V3 Volt.
##Software
- Arduino IDE 1.8.5
- SparkFun SGP30 Arduino Library V 1.0.5
- SHT21 Arduino Library (V1.0) e-radionica.com
Steps to reproduce
#include <Arduino.h>
//sensori
#include <Wire.h>
#include <Adafruit_Sensor.h>
//--- TH ---
#include <SHT21.h> // include SHT21 library
SHT21 sht;
//--- CO2 ---
#include "SparkFun_SGP30_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SGP30
SGP30 mySensor; //create an object of the SGP30 class
//--variable---
float temperature, humidity, pressure, altitude;
float co2 = 400 ;
float tvoc = 1 ;
uint16_t eco2, etvoc, errstat, raw;
//---------SETUP---------
void setup() {
Serial.begin(115200);
Serial.println("");
// Enable I2C
Wire.begin();
//----SENS TH-----
temperature = sht.getTemperature(); // get temp from SHT
humidity = sht.getHumidity(); // get temp from SHT
Serial.print("Temp: "); // print readings
Serial.print(temperature);
Serial.print("\t Humidity: ");
Serial.println(humidity);
//-----SENS CO2 -----
//Initialize sensor
mySensor.begin() ;
delay(3000);
mySensor.initAirQuality();
delay(1000);
//Serial.println( mySensor.measureTest());
}//end Setup
//----------LOOP--------------
void loop() {
temperature = sht.getTemperature(); // get temp from SHT
humidity = sht.getHumidity(); // get temp from SHT
Serial.print("Temp: "); // print readings
Serial.print(temperature);
Serial.print("\t Humidity: ");
Serial.println(humidity);
delay(85); // min delay for 14bit temp reading is 85ms
mySensor.measureAirQuality();
eco2 = mySensor.CO2 ;
etvoc = mySensor.TVOC ;
Serial.print("SGP30: ");
Serial.print("co2="); Serial.print(eco2); Serial.print(" ppm ");
Serial.print("tvoc="); Serial.print(etvoc); Serial.print(" ppb ");
Serial.println();
delay(500);
}
Expected behaviour
In a normal work i read the SHT21 and print Temp and Humid, then read The SGP30 and read CO2 and VOC
Actual behaviour
In the first read of Temp and Humid from SHT21 work perfectply, then when SGP30 begin, the SHT21 don't work
Metadata
Metadata
Assignees
Labels
No labels