Interfacing With The HDPM01 Barometer

I recently received a Barometer/Magnetometer purchased from Dealextreme.
Here is a link to the product on Dealextreme: Recommendations For You - DealeXtreme.
I have searched the model and have come up with this http://datasheet.eeworld.com.cn/pdf/HOPERF/336666_HDPM01.pdf datasheet.
Datasheets from other sources have identical content (Only differences are in the layouts and company logos).
I have gathered that the manufacturer stores calibration data on its EEPROM which address is 0xA1.
Just trying to read the data off the EEPROM has proved difficult. I have looked on the Arduino site for any tutourials or other helpful information, as well as Dealextreme and even Adafruit for information on this or similar sensors. The page I found Arduino Playground - HomePage seemed to look good to me, I was able to understand how to code was meant to function. The datasheet specifies that the EEPROM is read only, and in any case i wish to preserve the valuable calibration data, so I removed the parts of the code that (I believed) wrote over the EEPROM memory. The result was a constant "y" in serial monitor, which persisted to be generated when I removed the connection to the sensor.

I am aware that to communicate over I2C, addresses must be sent or written to the sensor/device and also to specify the parts of the EEPROM to read/write to.

I would like advice on how to get some data coming from the sensor, eventually calibration and sensor data. Also the datasheet provides very vague information on how to read the Magnetometer. I assume it most come out of the ADC somehow.
Thanks, Chris

Edit: I used the I2C scanner, which yeilded the following result:

I2C Scanner
Scanning...
I2C device found at address 0x30 !
I2C device found at address 0x50 !
done

Scanning...
I2C device found at address 0x30 !
I2C device found at address 0x50 !
I2C device found at address 0x77 !
done

After a couple more run throughs, the 0x77 disapprered?
Sorry for asking so many questions, but why does it intermittently identify a device at address 0x77?

If you buy something from Sparkfun or Adafruit, you will have the full schematic and an example program, and they have a forum you can ask for information.

Is a full schematic available ? I don't know if the I2C-bus has pull-up resistors. Looking at the photo I can't see them. Perhaps R1 and R2 are for pull-up, but they are not on the sensor board.
Try adding 4k7 pull-up resistors from the SDA and SCL to the 3.3V.

Do you know the type of sensor and ADC ?
I think the EEPROM is located in the ADC, but If you don't know the type, you might have to write your own I2C code.
Even many 'normal' I2C EEPROM chips differ in I2C communication.

What makes you think that the calibration data is in that EEPROM ? I hope it is, but you can't be sure.

If you read the datasheet and look at the section where it talks of coefficients (C1, C2 and so on) it says something about factory stored offsets and how to calculate temp and altitude. Just looking at the sensor i can see that there is no component between the R1 and R2 contacts, just blobs of solder. You can see that

As for writing my own code, that is what i am doing, or looking at other code that will help with I2C EEPROM. More info on I2C EEPROMs would be appreciated.
After looking back at some basic I2C stuff I managed to get the value 127 from address 0x50 continually with no variation, 0 from 0x30 and noting at all from 0x77. Not even crazy y characters. I found these addresses with the I2C address scanner, as above. Do not know which is which, and why one is intermittent.

Since the sensor board doesn't seem to have pull-up resistors for the I2C-bus, can you try 4k7 pull-up resistors from SDA and SCL to 3.3V ?
That would perhaps remove the false hit for 0x77.

Thanks for the photo, but the photo at deal-extreme is better.
The compass seems to be something like "MEMS G2120M", but I can't find a component like that.
The baromic sensor (with ADC and perhaps the EEPROM inside) doesn't even have a number on it.

This is the page for the HDPM01 at the manufacturer site: http://www.hoperf.com/sensor/app/HDPM01.htm
The "datasheet" and the "compass module programming guide" together provide enough information to write your own code.

It seems that ready-to-use example code for the Arduino is not yet available.
I found this : http://jeelabs.com/products/heading-board and with a link to code. But that code seems to be for the compass.
Someone wrote this code : CCS :: View topic - Help to interface with HDPM01 compass module!

What about tossing this sensor away, and buying a decent sensor board ?

The datasheet seems clear enough to me. You read the calibration constants from the chip
using the I2C interface when your process commences, and then you use the
complicated formula to calculate the actual pressure from the measured pressure and
temperature on each calculation cycle.
It looks very similar to the process for the other 3 pressure chips in common use.

Ok I added the resistors, which removed the 0x77, but I cannot read the values from the eeprom. I cant understand why its not retreiving the values. i am sending MSB as byte 16, and lsb as a byte 17. I am getting 0 in return. I don't understand how a most significant bit can be sent as a byte value. 16 would be one byte, being less than 255. Also the datasheet specifies that the pin XCLR should be pulled low in one instance, and set low in another, which means different things so far as I can tell. Should I be putting a resistor between XCLR and GND to pull the current low, or connecting it directly to ground? One more confusing thing is that the value of C1 is between 256 -- 65535, which is two bytes, not just one like is returned by the eeprom. Can anyone explain?

Can you post the sketch of what you have so far.
Place the code between code tags (use the '#' sign button).

Hey guys I just recieved the same sensor and I'm not familiar with arduino that well. So I'm hoping someone will find out how to access data from the module. In the meantime could anyone provide me with a link to some good tutorial about I2C data reading? :slight_smile: Thank you in advance :slight_smile:

Here is the code:

#include <Wire.h>

int hdpm01Address = 0x50;

void setup(){
Serial.begin(9600);

Wire.begin();
}

void loop(){
while(Serial.available() == 0){
delay(1);
}
Wire.beginTransmission(hdpm01Address);
Wire.write(byte(16));
Wire.write(byte(17));
Wire.endTransmission(false);
Serial.println(Wire.requestFrom(hdpm01Address, 1));
Wire.endTransmission();
delay(500);

}

Hey Appros. I did some searching yesterday and I have found out that this sensor is the same as hdp03. So I found a library for using that sensor and with the help of posts on forum changed it to work with newer versions of Arduino.

Here are the .cpp,.h files and the main program.
https://www.dropbox.com/s/e452iposqa85qc5/hp03.zip

If you write a new message, you see many smileys and buttons above the text field.
One of those buttons is with a '#'. If you use that button, the code tag is inserted.
The code tag is for a box like this:

Hello

In your sketch you don't read the value after requestFrom().

That library darkknight11 found looks promising !

I can confirm that the library is working on Arduino UNO.

Oops, no wonder Im getting noting...
Now that I read the value, i get 17 from 16:17
Will look into reading the whole thing.

With that library, I connected it all up to I2c and the XCLR pin to 19 (on mega) as specified on the cpp file, and get this:

Temp nan Pressure inf   Altitude: Meters = 6146817, Feet  = 20166726 smoothed = 20166726, deviation = 5083363
30154
Temp nan Pressure inf   Altitude: Meters = 6146817, Feet  = 20166726 smoothed = 20166726, deviation = 5083363
30154

and the values were not changing so I am now looking for documentation on this library. If the library is reading calibration data from the EEPROM, then it may be reading from the wrong address. Datasheets I have seen say that it is manufacturer programmed, so even with identical parts, the data is likely stored in different places on the EEPROM.