Jump to content
  • 0

Pmod HYGRO sensor error


YOAV1013

Question

Hello dear

We are students whom are working on an IoT project. 
We want to use the Pmod Hygro to get the temperature and humidity.
We also use the Artik530 by Samsung platform, with the Arm processor which supports the I2C protocol.
 

When we try to use the example code given by the resource center of this sensor, we get the error which can be seen in the added file .
in addition, we also get a temperature and humidity reading ,but the values are not making sense nor changing as the temperature and humidity are changing.

Can you please help us finding what's the problem? or where is the function that prints this error.

 

Thanks in advance, Yoav.

 

Capture.JPG

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

@D@n I attached the code ("HYGROI2CDemo") and its source files.

This code was taken from your site: http://store.digilentinc.com/pmod-hygro-digital-humidity-and-temperature-sensor/ at resource center, I only commented the line:

"Serial.begin(9600); // start the serial port connection at 9600 baud"

since I am not running it from Arduino IDE, but directly running its binary (.elf file) on my Atrik 530 core (using Putty). 

Moreover, My artik 530 even recognize it when running "bash:& i2cdetect -y 1" and it is seen at adress 0x40 (pic.jpg).

We are trying to fix this problem for nearly a month, it would be great if you or someone could help us figure out what's wrong.

Thanks in advance, Yoav.

 

HYGROI2C.h

HYGROI2C.cpp

HYGROI2CDemo.cpp

pic.jpg

Link to comment
Share on other sites

@jpeyron Yes, we already checked the VDD with a probe and it's 3.3V.

The data we get is like in the attached picture. The temperature reading is not changing at all (eventhough the sesnor's temperature is), nor making sense.

It only changes on different runnings, but varies between 82-83 Celsius and remains constant during the all run.

Thanks in advance.

error (1).JPG

Link to comment
Share on other sites

Hi @YOAV1013,

Unfortunately we have no experience with using the Artix 530 platform. If you are not wanting to use Aduino IDE then you will need to make you own library using ours as a reference for what to do. Here is an example of how to use I2C with a sensor. Our library is made to work with the Arduino IDE and Libraries like the wire and serial libraries. Here is documentation on using the Arduino IDE with the Artik boards. 

cheers,

Jon

Link to comment
Share on other sites

@YOAV1013,

So I asked to see your code in order to check it against any beginner mistakes.

I'm not seeing the beginner mistake I thought I might see.  I am, however, seeing one whereby you aren't checking the return result of your read command to see if the I2C device was actually read.  So, in your case, you might not be reading the device at all, and the zeros you are getting back at the device are the result of your error correction code not setting any values.

Are you getting the two bytes read that you are asking to have read?

Dan

Link to comment
Share on other sites

Hey @D@n, I think you're right.

I tried debugging the code and noticed that in the function "readRegI2C": 

******************************************************************************

    n = Wire.requestFrom(HYGROI2C_I2C_ADDR, 2);
    if (n != 2) {
        for (i=0; i<n; i++)
            Wire.read(); // ensure any bad bytes aren't left in the buffer
        return false;
    }

*****************************************************************************

In the first stage n gets a value different than "2" and the 'if' statement is true, which means the function returns "false" even without reading any bytes (which are being read in the next lines). I have no idea why n doesn't get the wanted value by "requestFrom".

I tried commenting the if statement but didn't notice any change. "requestFrom" working properly is maybe necessary for reading.

The library "wire.h" is very long and not so clear, I couldn't find out what's the problem with this method ("requestFrom").

I am asking for your further help and thanking you in advacne for being responsive and kind. 

Yoav.

 

Link to comment
Share on other sites

@YOAV1013,

The next steps of your problem are quite straightforward, but they aren't steps I can do for you:

  • You need to examine that "n" value returned from readRegI2C, and do so regularly.  Is it always returning a failed read (n=0)?  Is it ever returning an (n>2) value?  etc.
  • One cause for design failure is an incorrect I2C device address.  Another possible reason for failure is an invalid register address within the device.  It is possible that the register you are attempting to write to or read from is outside of the HYGRO's register map.  You should double check the register you are attempting to read is the right register.
  • If neither of the above ideas yields any fruit, I'd want to take an FPGA or digital scope of some type to find out what truly is going on within that port.  Are you actually requesting valid registers?  Is the device properly responding?  As an example, here is a post describing how a wishbone controlled scope could be used to find a broken I2C system.  (And to think ... it was my own code that was broken at the time ... it's been fixed since.  Were you using an FPGA, I'd offer you a link to it ...)

Sorry I can't offer you much more ... (I don't have your hardware ...),

Dan

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...