Sensor SHT 75 and Arduino UNO

Thread Starter

denis1990

Joined Sep 26, 2015
4
Hi I have some problems with the connection between arduino and the sensor SHT 75. I've used this code:

#include <Sensirion.h>

const uint8_t dataPin = 2; //Declaracion patillas arduino
const uint8_t clockPin = 3;
float temperature; //Declaracion variables
float humidity;
float dewpoint;
Sensirion tempSensor = Sensirion(dataPin, clockPin); //Declaracion objeto sensor

void setup()
{
Serial.begin(9600); //Declaracion puerto serie
}

void loop() {
tempSensor.measure(&temperature, &humidity, &dewpoint); //Llamada sensor
Serial.print("Temperature: "); //Escribe texto para acompañar al valor
Serial.print(temperature); //Escribe valor en la misma linea
Serial.print(" C, Humidity: "); //Escribe texto para acompañar al valor
Serial.print(humidity); //Escribe valor en la misma linea
Serial.print(" %, Dewpoint: "); //Escribe texto para acompañar al valor
Serial.print(dewpoint); // Escribe valor en la misma linea
Serial.println(" C");
delay(5000); //Tiempo de espera para la siguiente ejecucion
}

But which is the problem? the problem is that when I go to the monitor serie in order to see the measures I just get this:

temperature: 0.0 humidity: 0.0 % dewpoint: 0.0
temperature: 0.0 humidity: 0.0 % dewpoint: 0.0
temperature: 0.0 humidity: 0.0 % dewpoint: 0.0
...

So I don't know what is the problem may be the connections, the code, it could be that I can't connect directly 5V from arduino with sensor SHT 75 because it needs just 3.5 V ??

Some idea ? Any aid will be welcome.

Thanks a lot.
 

Cyberduke

Joined Mar 5, 2011
50
Have you checked the datasheet at
http://www.sensirion.com/fileadmin/...ity/Sensirion_Humidity_SHT7x_Datasheet_V5.pdf

Like ISB123 said you need a resistor between data and VDD.
It would help if you can show me how you connected the sensor to your arduino.

I've spotted one potential error in your code. It can be very fiddly due to my knowledge passing a non pointer variable by reference. Ie the (&temperature, &humidity, &dewpoint). I just quickly coded an example like that and it didn't even compile. Try passing them just "normally". Usually when you want to indicate that you want to change a parameters value the "&" sign is inserted in the function prototype/definition. Not when passing a parameter.
 

nerdegutta

Joined Dec 15, 2009
2,684
Have you read section 2.2 and 2.3 in the above datasheet? And connected it like fig 5?

I also suggest that you post a schematic diagram over you circuit, and perhaps a high res picture. :)
 

Thread Starter

denis1990

Joined Sep 26, 2015
4
Have you read section 2.2 and 2.3 in the above datasheet? And connected it like fig 5?

I also suggest that you post a schematic diagram over you circuit, and perhaps a high res picture. :)
ok, tomorrow I'll go to the laboratory and I'll send a picture or a diagram.
 

Cyberduke

Joined Mar 5, 2011
50
so, do you think that I have to change from float to another ? or what do you think ? tomorrow I am going to the laboratory and I'll try to change the code.
No, Floats should work just fine. I usually work with double or int. But i am not sure of the difference between floats and double. (probably just the size) so they might probably not be the issue. Its still as a last resort worth trying double or even int. But what I would change that might make a difference, is instead of tempSensor.measure(&temperature, &humidity, &dewpoint); I will have tempSensor.measure(temperature, humidity, dewpoint); My knowledge on the exact theoretical wording is a bit rusty but ill try my best to explain why I say that.

So if we look at a void function that want to change the values of its parameters we will declare it like this. ill use double in this example.
class tempSensor
{
void mesaure(double &temperature, double &humidity, double &dewpoint)
{
temperature = 5;
humidity = 6;...etc
}
}
ok lets create our 3 varibles just like you did:
double temperature = 0; (Its always a good idea to initialize your variables to some value)
double humidity = 0; ...etc
if you then call said function it will look like this:
tempSensor.measure(temperature, humidity, dewpoint);
the result will be temperature that has the value of 5 humidity of 6 etc.
If I try to call it like you did ie:
tempSensor.mesaure(double &temperature, double &humidity, double &dewpoint)
I cant even get it compiling if I pass the variables by reference like you did. I hope this helps.

NOTE: I have based this post on my knowledge of c programming and I have not tried it on the arduino IDE for the reason that I don't have an arduino available or the software installed.
 
Top