Using i2c pressure sensor

Boondocker

New Member
Hello,

I’m considering purchasing the SCP1000 D11 pressure sensor, the i2c model, to measure barometric pressure with a Picaxe 18x chip. This sensor is available on a PCB mount at Digkey. http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=551-1044-ND

Will this device work simply using i2cslave, readi2c and writei2c commands to avoid “bit-banging”? Just like using the DS1307 clock chip.

I’m a novice just started studying i2c communications and uncertain about reading the data sheets properly.
http://www.vti.fi/midcom-serveattachmentguid-e9735f5baea5692c3b9753f9069511c7/scp1000_product_family_specification_rev_0.08.pdf

What I can figure, the slave address is %1001001 and the read pressure (16bit) address is %10000000.

I hope using this sensor will be as easy using the example code below.

I2slave %1001001, i2cfast, i2cword
Pause 60
Read i2c %10000000, (w1)

Thanks for your comments and advice.
 

MFB

Senior Member
There are some Basic Stamp examples around for using the SPI version of this sensor but the code seems pretty involved, with lots of set-up options. It may however be quite simple to access pressure readings once intialized.
 

westaust55

Moderator
The dig-key description is: "SENSOR I2C 30-120KPA PCB"

In the datasheet it states: "SPI and TWI (TWI is very similar to I2C bus)."

Looking at page 25 on for the TWI comms format it does look very similar to i2c in format.

While SPI CLock can be up to 1MHz TWI max speed is 400kHz, so i2cslow or i2cfast may work.

You can always give it a try.


I am about to try using a HOPERF HP03S to an 18X. HP03D woiuld be a better choice in terms of physical connection (0.1in pin spacing) not Surface mount but connection of the S variant was not difficult.
 
Last edited:

Boondocker

New Member
Westaust55,

Yes, the spec matches the 400 kHz speed. I’ve been doing some more studying on i2c communications. The question now is, does the picaxe command structure for i2cslave, readi2c, and writei2c match the sensor communication protocol (slave device address, register address, slave device address, data)?

This sensor is not cheap. Before purchasing want to know that it’s compatible and I possess the knowledge to use.
 

westaust55

Moderator
I think that 30~120kpa ABSOLUTE might be a bit of an overkill for a barometer type application, I'm looking at one of these type of sensors to play with...

http://www.futurlec.com.au/Pressure_Sensors.jsp

Perhaps the range needed only needs to be 800~1100 absolute for barometer use.
While the HP01S (the HP01D is no longer manufactured and Futurelec hold nil stock as I had a few months ago tried to order one) is tentatively more suitable, with a range of 900 to 1100 mbar/hPa it only provides a relative pressure.

The HP03S/D modules have a greater range 300 to 1100 mbar/hPa and use a number of constants (18 bytes in total) to correct for temperature and determine the actual pressure.

The HP03 series is what I am about to experiement with. Not started on the maths but it will be relatively complex.

The HP01 series are 2 to 5Vdc which would have been more suitable.
The HP03 series are 2 to 3.6Vdc rated but I am about to try a circuit to provide a simple 5V to 3.3V bi-directional i2c comms interface.
You also need a TTL level 32.xxx kHz as a clock for the HOPERF pressure modules for the ADC portion.
 
Last edited:

westaust55

Moderator
Westaust55,

Yes, the spec matches the 400 kHz speed. I’ve been doing some more studying on i2c communications. The question now is, does the picaxe command structure for i2cslave, readi2c, and writei2c match the sensor communication protocol (slave device address, register address, slave device address, data)?

This sensor is not cheap. Before purchasing want to know that it’s compatible and I possess the knowledge to use.
The SCP1000 pressure sensor that you propose has far simpler maths than the HOPERF HP03 series modules that I and megareg have mentioned.

While the SCP1000 make reference to 7bits and 16 bits,
The 7 bits are followed by another read/write bit = 8 bit (1 byte) and
the 16 bit data is transferred as two 8-bit bytes.
I do not give a 100% guarantee but compatability looks good.

The HOPERF modules however are about 20% of the cost .


Either way I think that few here have one (SCP1000 or HP03 series) connected to a PICAXE to date.
So you may come accross aspects that you will need to ask questions about.
 

jgershonw1

New Member
Just some personal experience from using the Hoperf HP03D. The batch that I received were not very accurate at all. The factory set coefficients were not even within spec on one of them! The temperature would consistently measure 2-3 degrees higher and the pressure would be off anywhere from 500 - 1000 pa. I returned them back to Hoperf for replacements, but they never received them. So, I am out a few dollars now.
 

westaust55

Moderator
Just some personal experience from using the Hoperf HP03D. The batch that I received were not very accurate at all. The factory set coefficients were not even within spec on one of them! The temperature would consistently measure 2-3 degrees higher and the pressure would be off anywhere from 500 - 1000 pa. I returned them back to Hoperf for replacements, but they never received them. So, I am out a few dollars now.
@jgershonw1,

Thanks for the information.

With respect to the constants, I presume that you had taken into account that the HOPERF modules have the most significant byte of word constants in the low byte whereas PICAXE BASIC has the most significant byte of word variables in the high byte.

Guess I will find out where I stand with my HOPERF HP03S modules in a couple of days once I have everything hooked up.
 

hippy

Ex-Staff (retired)
It looks to me that the SCP1000 is fully compatible with the I2C protocol and can be accessed using PICAXE I2C commands. Slave Address appears to be %00100010, so ...

I2cSlave %00100010, I2CSLOW, I2CWORD
I2cRead %10000000, ( b1, b0 )
SerTxd( "Raw Pressure Reading = ", #w0, CR, LF )

The only proof it will work comes with trying it. On the plus side, if it doesn't work, there is still the option of SPI and I2C or SPI bit-banged.
 

westaust55

Moderator
Not possible to swap between the two comms modes.

From the datasheet:
"Two different serial interfaces are available for SCP1000 sensor: SPI and TWI (very similar to I2C). However, only one interface per product is enabled by pre-programming in the factory."
 

mega

New Member
I shall be looking at this thread as it develops, I'm waiting for my units to arrive from Futurelec, they always seem to get my account details wrong Grrrr....

I'm not after super accurate readings, and I know that I can just buy a weather station that will connect to my computer, but, that's the easy way, this way I can stimulate my mind and have a lot of fun in doing so, this is a great forum and the regulars on here are such a great help too.

Cheers
 

westaust55

Moderator
HOPERF HP03 Pressure Sensor

@jgershonw1,

how was your HP03 installed.
Some research that I have done this evening suggests that the pressure sensor is also light sensitive and should be kept in the dark.

Obviously the HP03 can be inside the project enclosure provided the enclosure is not air tight.

EDIT:
Next tip - is to have a 47uF tantalum capacitor at the HP03 supply connections.

Hopefully all my research pays off when I put mine into operation (fingers crossed)
 
Last edited:

Boondocker

New Member
Thank you all for your insight

Last night I play around on VSM simulation with bit-banging on i2c device. Bit-banging makes it a lot more complicated. However, it forces you to really learn and understand i2c communication better. Prefer not to use the bit-banging method if possible.

Below are graphics of the read protocols for the SCP1000D11 and the DS1307 clocks. Knowing that the DS1307 is compatible with picaxe18x; compare the two protocols. The DS1307 sequence uses slave address and data is transferred , while the SCP1000D11 sequence uses slave address, register address, slave address, and data is transferred.

Does the i2c commands compensate for this sequence difference?
 

Attachments

westaust55

Moderator
If you look closely at the control sequence there is first a write and then a read sequence

The i2cSETUP command pre defines the slave address
You could then try the following basis (untested by myself as yet):
The first two bytes relate to writing to the pressure sensor to define the register.

So Writei2c, slave address ( note here that the lsb automatically set to 0), (register number)

The next bytes are a read function so:
Readi2c, slave address )(note here that the lsb automatically set to 1), (b1, b0) ; MSB first then LSB to create the word.



The DS1307 example does not indicate the register so it automatically starts at register 0.

If you wanted to for example just write to or read from the control register than you must include that register, in the location position of the READi2c or WRITEi2c commands.
 
Last edited:

Boondocker

New Member
Westaus55,

I understand what you are saying. Code the commands so they are sequence to how pressure sensor has to receive the addresses. Might have to put a pause between them, but it make sense to me.

Thanks! I'll let you know if it works.
 

hippy

Ex-Staff (retired)
@ Boondocker : The in-built PICAXE I2C commands will do all that is necessary and with the correct timing to allow an I2C compatible device to be 'plug and play'. All you need to do is issue the correct, simple PICAXE commands.

You don't need to understand the underlying protocol unless writing bit-banged code, you just use the high level commands. When looking at descriptions of the underlying protocol and sequences you need to compare like with like and understand the protocol to see what it is they are showing.

By all means do keep investigating how I2C works and aiming to understanding the protocol if you wish, but don't start worrying that it's too complicated or using PICAXE I2C requires a lot of work; in the overwhelming number of cases it's very straightforward and easy. Much like making a phone call doesn't require knowlege of the numerous, complicated protocols which make that a possibility.
 

jgershonw1

New Member
westaust55, I am sure the coeffs were being read correctly because some of them were within spec, while others were not. Only one of the sensors had reasonable coeffs, but the readings were off. I didn't have mine shielded from light, so maybe that contributed to the error. I probably just received a bad batch. It's too bad that I never got the replacements.
 

Pulsartomi

New Member
Hello all!
Is it ok with the HP03 sensor if the temperature goes up 1-2°, the pressure also changes 1-2hpa?I thought it is temperature compensated, but what about the thermal expansion?It also generates a pressure changing.
All after that the pressure seems to return to the standard value, approx. the value before.I really don't understand what's the problem.
The sensor follows the weather forecast's pressure value, but i couldn't find out why is this temperature sensitivity.
Anyway, the datasheet says the maximum error over temp. is +-2 hpa, but its in the -30...+85 interval, not in the 1-2° change.
:(
 
Last edited:

westaust55

Moderator
When the termperature rises, does the pressure go up or down?

As air heats it does become less dense. Here in Australia for the same "nominal" pressure, according to the weather dept, the pressure will rise and fall in a daily cycle by around 6hPa (from memory) due to temperature variations.

Is the temperature increase due to actual air temp increase or due to temp sensor heating as a result of frequent readings?

I found with my HP03 sample that if left alone, it gave good results,
but if I manually forced the temperature up then the pressure readings were in error.
 

Pulsartomi

New Member
Hello Westaust55!
This weird thing about pressure changing is when i give some heat to the sensor with my hands or open the window to cool down down room.
the pressure rises immediately after the temperature rises.
After several hours (I didn't measure it, but not some minutes, thats for sure) its normal again, but i don't know if response time is so long for this.Maxbe it's all right, but then it would be good to know when to measure if the temp. changes.(i followed the forecast, so it's may not the outside air pressure change)
 

BeanieBots

Moderator
The probelm with rapid air temperature changes is that any thermal mass such as a sensor cannot keep up with the change. It needs time for EVERYTHING within the sensor unit to stabilise to the same temperature.

There is probaly a lag (or lead) between the internal temperature sensor and the actual temperature of the pressure sensor when subjected to a rapid change. Keeping it out of drafts should help.
 
Top