No reading from SHT30 - AB02S

Hello there, hopping to get some help!

I saw @andyt1968 could communicate with the sensot but it seems he has been offline for a while.
I am trying to communicate with the SHT30 using the I2C1. I am using VDD and the sensor is supposed to have pullup resistors.

The sensor library can be found at

I was able to retrieve the sensor address using this code:

#include “Arduino.h”
#include “Wire.h”
#include <SHT3x.h>

void setup()
{
Serial.begin(115200);
Wire1.begin();
delay(5000);
Sensor.Begin();
}

void loop()

{
byte error, address;
int nDevices;
Serial.println(“Scanning…”);
nDevices = 0;
for(address = 1; address < 127; address++ )
{
Wire1.beginTransmission(address);
error = Wire1.endTransmission();
if (error == 0)
{
Serial.print(“I2C device found at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print(“Unknown error at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println(“No I2C devices found\n”);
else
Serial.println(“done\n”);
delay(5000);
}


So I supoose wiring is ok…

Now I am tring to get some data from it with no sucess, I am using the code below getting 0 reading for both variables:

#include “Arduino.h”
#include “Wire.h”
#include <SHT3x.h>
SHT3x Sensor;

void setup()
{
Serial.begin(115200);
Sensor.Begin();
Wire1.begin();
delay(3000);
}

void loop()

{
Sensor.UpdateData();
Serial.print(“Temperature: “);
Serial.print(Sensor.GetTemperature());
Serial.write(”\xC2\xB0”); //The Degree symbol
Serial.println(“C”);
Serial.print(“Humidity: “);
Serial.print(Sensor.GetRelHumidity());
Serial.println(”%”);
}

Thanks in advance!

Two things:

  1. You should probably be initialising the I2C bus before you try to use it (i.e. before you initialise the sensor);

  2. Looking quickly at the SHT3x.h file I see:

     void Begin( int SDA = 0,
                 int SCL = 0);
    

which seems to suggest that you should be providing the SDA/SCL PIN numbers in the method call (otherwise they’ll be set to 0).

@UniquePete thanks again for you quick response…

  1. This way it doesn’t work neither:
    Serial.begin(115200);
    Wire1.begin();
    Sensor.Begin();
    delay(3000);

  2. I also saw what you mean… I also saw in the .cpp file (https://github.com/Risele/SHT3x/blob/master/SHT3x.cpp) the following:

void SHT3x::Begin(int SDA, int SCL)
{
if (SDA==0) Wire.begin();
else Wire1.begin(SDA, SCL);
_OperationEnabled = true;
}

So I supposed this is related to recognize the bus the sensor is connected to… What other way can be used to know the bus the sensor is connected to?
Since the sensor address was retrieved intiating the sensor the same way (only Sensor.Begin():wink: I just leave it like that… Does it have any sense?
I don’t unsderstan completely the code… In the previus portion of the .cpp file seems to be initiating the bus, so why do we have to use wire1.begin(); in our source?

Anyway I gave it a try using Sensor.Begin(37, 38) (in case it required the micro pins) and Sensor.Begin(09, 08) (in case it required GPIO numbers) and no result…

Any other idea?

Thanks in advance for your help

Yes, I’d agree (but Sensor.Begin(9,8) is the form you’d want if you were specifying SDA/SCL in the call).

If you can see the sensor with your original setup code, then try using exactly that before you try to read the sensor:

You may need that delay between initialising the bus and reading the sensor.

Noting that I use SDA0/SCL0 for both the OLED display and my I2C sensors, you could also try using the primary bus and see what that does.

The only other suggestion I have is to try another, or a different I2C sensor. That might tell you if you have a dud sensor, or if there’s a problem with the initialisation process you are using for that sensor (i.e. try a sensor that doesn’t use the SHT3x library).

Hi @UniquePete I did what you say, but no results. But then I realized the following:
If I do click on “Go to definition (F12)” to a fuction from wire library in the code, for example Rigth CLick on Wire1.begin() and then “Go to definition (F12)”: the Arduino IDE opens the file, in this case Wire.cpp so I can see the function declaration… Tha is good
But if I do the same in a function of the SHT3x.h library, for instance Rigth CLick on Sensor.Begin() and then “Go to definition (F12)” the IDE shows me this message “No definition found for Begin”
That give me the idea that the library is not being identifyed by the program… If I do the same “Go to definition” in the Wire.h library for example it Opern the file but in the SHT3x.h it does not open it
I imported the SHT3x.h library from this page

downloading a Zip file and following the Zip File library importing procedure.

The Library appear in the IDE Sketch/Include Lybrary Menu… It appear like this #include <SHT3x.h>, whereas the others appears like this #include “Wire.h”

I searched for the diference and the arduno documentation says is definey wher the IDE will find the libraries.

The workig lybraries are in
C:\Users\Ibrahim\AppData\Local\Arduino15\packages\CubeCell\hardware\CubeCell\1.5.0\cores\asr6601\peripheral

And the not working one is in the User document folder
D:\Users\Ibrahim Colmenares\Documents\Arduino\libraries\SHT3x-master

How can I be sure that the IDE is going to read the lybrary in the rigth addess.

Aditionally, from the program identifying the sensor number I removed the Sensor.Begin(): and it worked just fine… So definetively this line was not used by the program… It seems the prgram is not using the SHT3x.h lybrary

Thanks in advance again for your help!!!

Definetively something happens with the library… I found this code which only use the wire.h lybrary and is working…

I would appreciate if some one would help to find out what could be happening whith the library!!

Thank you all!!!

For those interested, the library that worked for me was

It worked good and have many functions. I only had to change in the *.ino files and in the *.cpp file the wire by wire1 to refer to the second !2C bus. It is working just fine!

Thank you all.

Sorry for being late to this conversation. Been working on other things.
indent preformatted text by 4 spaces
void SHT30() {

// Vext ON

digitalWrite(Vext, LOW);

delay(500);

Sensor.UpdateData();

if (Humid==0){ // error reading so try again

Sensor.UpdateData();

}

if (Humid==0){ // error reading third time lucky

Sensor.UpdateData();

}

Temp=Sensor.GetTemperature();

if (debug==true){

Serial.print("Temperature: ");

Serial.print(Temp);

Serial.write("\xC2\xB0"); //The Degree symbol

Serial.println("C");

}

Humid=Sensor.GetRelHumidity();

if (debug==true){

Serial.print("Humidity   : ");

Serial.print(Humid);

Serial.println("%");

}

 Wire.end();

 delay(50);

// Vext OFF

digitalWrite(Vext, HIGH);

}