Sensor SHT 75 and Arduino UNO

Discussion in 'Embedded Systems and Microcontrollers' started by denis1990, Sep 26, 2015.

  1. denis1990

    Thread Starter New Member

    Sep 26, 2015
    4
    0
    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.
     
  2. ISB123

    Well-Known Member

    May 21, 2014
    1,239
    527
    Do you have a pull up resistor on data?
     
  3. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    784
    Have you tried connecting it to the SCL and SDA pins?
     
  4. Cyberduke

    Active Member

    Mar 5, 2011
    33
    1
    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.
     
    djsfantasi likes this.
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    Serial.print(temperature);
    ^ here you are calling a variable called temperature.
    But you never declared it.
     
  6. Cyberduke

    Active Member

    Mar 5, 2011
    33
    1
    I'm quite sure there right above void.setup() all 3 the variables are declared as floats.
     
  7. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    784
    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. :)
     
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    You are right, they did them as global variables.
     
  9. denis1990

    Thread Starter New Member

    Sep 26, 2015
    4
    0
    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.
     
  10. denis1990

    Thread Starter New Member

    Sep 26, 2015
    4
    0
    ok, tomorrow I'll go to the laboratory and I'll send a picture or a diagram.
     
  11. denis1990

    Thread Starter New Member

    Sep 26, 2015
    4
    0
    I think yes but I'll check it.
     
  12. Cyberduke

    Active Member

    Mar 5, 2011
    33
    1
    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.
     
  13. Cyberduke

    Active Member

    Mar 5, 2011
    33
    1
    I would have liked some feedback...
     
Loading...