Hi guys,
I am communicating with the Sensirion EKH5 with Sensor SHT2x but I don't know what values I have to write in order to get the proper values of temperature and humidity from the sensor.
These values from a SHT75 that I found in this forum:
 //Init I2C mode
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0x00;
//Init SHT75 measurement
report[0] = 0x02;
report[1] = 0xC2;
report[2] = 0x50;
//Report Data
report[0] = 0x03;
report[1] = 0x03;
report[1] = 0x03;
Does anybody know what values are the correct ones for the sensor SHT2x?
Also, if I get the correct values what is the correct formula for the calculation of the Temperature and humidity?
Thanks a lot for your help! I appreciate.
Regards,
Andreu
			
			
									
						
										
						Interface with Sensirion EKH5 with Sensor SHT2x
Moderator: Guido Körber
- Christoph Jung
 - Posts: 673
 - Joined: Sun Oct 08, 2006 3:43 pm
 - Location: Germany / Berlin
 - Contact:
 
Re: Interface with Sensirion EKH5 with Sensor SHT2x
Have you take a look into the datasheet about the SHT2x sensor?
On page 7-9 shows the values to send and read from the device.
I have no SHT2x and can't test or send you sample code, sorry.
Untested sample:
The default address if the i2c should be 0x80 for write and 0x81 for read.
to start a measurement the command is 0xE3 for "Temperature", 0xE5 for "Humidity", and "Softreset" 0xFE.
The basic transaction:
The formula for the SHT7x sensor to get the °C and %RH:
Maybe the formula will work for the SHT2x
			
			
									
						
							On page 7-9 shows the values to send and read from the device.
I have no SHT2x and can't test or send you sample code, sorry.
Untested sample:
The default address if the i2c should be 0x80 for write and 0x81 for read.
to start a measurement the command is 0xE3 for "Temperature", 0xE5 for "Humidity", and "Softreset" 0xFE.
The basic transaction:
Code: Select all
report.ID = 0x02;
report.Bytes[0] = 0xC2;
report.Bytes[1] = 0x80;
report.Bytes[2] = 0xE5; //humidity
IowKitWrite()....
IowKitRead()... //ACK
report.ID = 0x03;
report.Bytes[0] = 0x03;
report.Bytes[1] = 0x81;
IowKitWrite()....
IowKitRead()... // Measurement MSB, LSB and Checksum
double value = (double)((report[2] << 8) | report[3]);
Code: Select all
        //Calc temperature and humidity 
        public void CalcTRH(double temp, double humi)
        {
            const double C1 = -4.0;         // for 12 Bit
            const double C2 = +0.0405;      // for 12 Bit
            const double C3 = -0.0000028;   // for 12 Bit
            const double T1 = +0.01;        // for 14 Bit @ 5V
            const double T2 = +0.00008;     // for 14 Bit @ 5V
            double rh = humi;				// rh:      Humidity [Ticks] 12 Bit 
            double t = temp;			    // t:       Temperature [Ticks] 14 Bit
            double rh_lin;					// rh_lin:  Humidity linear
            double rh_true;					// rh_true: Temperature compensated humidity
            double t_C;						// t_C   :  Temperature [°C]
            t_C = t * 0.01 - 40;						        //calc. temperature from ticks to [°C]
            rh_lin = C3 * rh * rh + C2 * rh + C1;		    	//calc. humidity from ticks to [%RH]
            rh_true = (t_C - 25) * (T1 + T2 * rh) + rh_lin;	    //calc. temperature compensated humidity [%RH]
            if (rh_true > 100) rh_true = 100;		//cut if the value is outside of
            if (rh_true < 0.1) rh_true = 0.1;		//the physical possible range
            m_Humidity = rh_true;   //return humidity[%RH] into member-var
            m_Temperature = t_C;      //return temperature [°C] into member-var
        }
Software developer
			
						Re: Interface with Sensirion EKH5 with Sensor SHT2x
Hi,
yes I took a look at the data sheet. The problem is that writing address 0x80 (128), the iowkit write function gives back 0 bytes written...
this is what I do:
//Soft reset
report[0] = 0x80; //I2c address + write
report[1] = 0xFE; // Soft reset
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
the value returned is ret= 0.
On the other hand, if I write:
//Soft reset
report[0] = 0x01;
report[1] = 0xFE;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
the value returned is ret=8. That means that the bytes were written on the USB, right?
What I do not understand is why 0x01!! It should be 0x80 according to the datasheet.
Trying to read temperature I also have the problem:
report[0] = 0x80; //I2c address + write
report[1] = 0xE3; // T measurement HM
report[2] = 0x81; // I2c address + read
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
the value returned is ret= 0 again!
obviously I can't even send a read:
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
because it won't read any data
report is an array of bytes[8]
Anybody knows where the problem could be?
Thanks!
Andreu
			
			
									
						
										
						yes I took a look at the data sheet. The problem is that writing address 0x80 (128), the iowkit write function gives back 0 bytes written...
this is what I do:
//Soft reset
report[0] = 0x80; //I2c address + write
report[1] = 0xFE; // Soft reset
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
the value returned is ret= 0.
On the other hand, if I write:
//Soft reset
report[0] = 0x01;
report[1] = 0xFE;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
the value returned is ret=8. That means that the bytes were written on the USB, right?
What I do not understand is why 0x01!! It should be 0x80 according to the datasheet.
Trying to read temperature I also have the problem:
report[0] = 0x80; //I2c address + write
report[1] = 0xE3; // T measurement HM
report[2] = 0x81; // I2c address + read
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
the value returned is ret= 0 again!
obviously I can't even send a read:
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
because it won't read any data
report is an array of bytes[8]
Anybody knows where the problem could be?
Thanks!
Andreu
- Christoph Jung
 - Posts: 673
 - Joined: Sun Oct 08, 2006 3:43 pm
 - Location: Germany / Berlin
 - Contact:
 
Re: Interface with Sensirion EKH5 with Sensor SHT2x
You have forgotten the report.ID, the flags and the number of data.
And you have to initiate the I2C-Mode once
Init I2C:
Write:
Read:
For read from the I2C you have to set the device address to read-mode ->  0x80 + 0x01
			
			
									
						
							And you have to initiate the I2C-Mode once
Init I2C:
Code: Select all
report[0] = 0x01;
report[1] = 0x01; //enable
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
Code: Select all
report[0] = 0x02; //I2C write mode
report[1] = 0xC2; //startbit, stopbit and 2 data to send
report[2] = 0x80; //I2C device address (from datasheet)
report[3] = 0xFE; //command
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
IOWarrior.Functions.IowKitRead(Handle, 1, report, 8); //swallow the ACK message and free the buffer
Code: Select all
report[0] = 0x03; //I2C read mode
report[1] = 0x03; //3 Bytes to read
report[2] = 0x81; //Address 0x80 + 0x01
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8); //write to the IO-Warrior, that we will read 3 Bytes of data
IOWarrior.Functions.IowKitRead(Handle, 1, report, 8); //read the 3 Bytes
Software developer
			
						Re: Interface with Sensirion EKH5 with Sensor SHT2x
Hi,
thanks I tried that, but I always get following result back:
1st read:
report[0] = 2
report[1] = 128
2nd read:
report[0] = 3
report[1] = 128
and so on... (being the rest of the values 0).
which does not seem to me any temperature reading...
I have also tried to add the Read Temperature command HM (0xE3) in report[3] in the write function and I get the same result as above...
According to the commands of SHT25 datasheet I would only need to do following:
"Read Temperature with hold master":
I2C address + write: 0x80; --> in report[0]?
Command: 0xE3; (read temp) --> in report[1]?
I2C address + read: 0x81; --> in report[2]?
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
Thread.Sleep(100);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
but I only get always as a result:
report[0] = 2;
report[1] = 128;
This makes me think that maybe there is something wrong with the iowkit.dll and their functions? maybe not the right version?
Since I am using the EKH5 evaluation sensor (USB dongle), I am not sure if I have to do anything else or send any other commando to get it work...
I did not find any I2C write mode (0x02) and read mode (0x03) in the datasheet of SHT25. Do they belong to another sensor maybe?
Thanks for your support!
andreu
			
			
									
						
										
						thanks I tried that, but I always get following result back:
1st read:
report[0] = 2
report[1] = 128
2nd read:
report[0] = 3
report[1] = 128
and so on... (being the rest of the values 0).
which does not seem to me any temperature reading...
I have also tried to add the Read Temperature command HM (0xE3) in report[3] in the write function and I get the same result as above...
According to the commands of SHT25 datasheet I would only need to do following:
"Read Temperature with hold master":
I2C address + write: 0x80; --> in report[0]?
Command: 0xE3; (read temp) --> in report[1]?
I2C address + read: 0x81; --> in report[2]?
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
Thread.Sleep(100);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
but I only get always as a result:
report[0] = 2;
report[1] = 128;
This makes me think that maybe there is something wrong with the iowkit.dll and their functions? maybe not the right version?
Since I am using the EKH5 evaluation sensor (USB dongle), I am not sure if I have to do anything else or send any other commando to get it work...
I did not find any I2C write mode (0x02) and read mode (0x03) in the datasheet of SHT25. Do they belong to another sensor maybe?
Thanks for your support!
andreu
Re: Interface with Sensirion EKH5 with Sensor SHT2x
Hi there,
I already found where the problem was. Now I get the temperature without problem.
At the end of the SHT2x datasheet it states that you can use the same protocol as in SHT7 so I did that based on this entry:
viewtopic.php?f=1&t=1694
//sensor first time setup
//I2C enable, pull up disabled
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
//Setup to get temperature and humidity
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
//Generate start, data count=1 byte
report[0] = 0x02;
report[1] = 0x82;
report[2] = 0x06;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
//Inside the loop to read temp
//Measure temperature, read off 3 bytes
report[0] = 0x03;
report[1] = 0x03;
report[2] = 0x03;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
The formula to calculate temperature for SHT2x is:
First get value from 3 bytes:
value = report[2] * 255 + report[3] + report[4] / 255;
temp = value/2^14 * 175.72 - 46.85;
Now works perfect.
Thanks for your support!
Andreu
			
			
									
						
										
						I already found where the problem was. Now I get the temperature without problem.
At the end of the SHT2x datasheet it states that you can use the same protocol as in SHT7 so I did that based on this entry:
viewtopic.php?f=1&t=1694
//sensor first time setup
//I2C enable, pull up disabled
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
//Setup to get temperature and humidity
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
//Generate start, data count=1 byte
report[0] = 0x02;
report[1] = 0x82;
report[2] = 0x06;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
//Inside the loop to read temp
//Measure temperature, read off 3 bytes
report[0] = 0x03;
report[1] = 0x03;
report[2] = 0x03;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
The formula to calculate temperature for SHT2x is:
First get value from 3 bytes:
value = report[2] * 255 + report[3] + report[4] / 255;
temp = value/2^14 * 175.72 - 46.85;
Now works perfect.
Thanks for your support!
Andreu
Re: Interface with Sensirion EKH5 with Sensor SHT2x
Hi Andreu,
I am trying to use your example to access the SHT25 using Agilent VEE. The equivalent of your example code runs fine up to the point marked below:
//sensor first time setup
//I2C enable, pull up disabled
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
Up to here everything is as expected the return value of ret is 8 as I expect it. But now:
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
Here the value of ret is 0 and it should be 8, correct?
Any Idea whichcould cause the read not to work?
Thanks,
Uli
			
			
									
						
										
						I am trying to use your example to access the SHT25 using Agilent VEE. The equivalent of your example code runs fine up to the point marked below:
//sensor first time setup
//I2C enable, pull up disabled
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
Up to here everything is as expected the return value of ret is 8 as I expect it. But now:
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
Here the value of ret is 0 and it should be 8, correct?
Any Idea whichcould cause the read not to work?
Thanks,
Uli
Re: Interface with Sensirion EKH5 with Sensor SHT2x
Hi everybody,
I solved the problem, for those interested I could pass the VEE code.
Uli
			
			
									
						
										
						I solved the problem, for those interested I could pass the VEE code.
Uli
UKrieger wrote:Hi Andreu,
I am trying to use your example to access the SHT25 using Agilent VEE. The equivalent of your example code runs fine up to the point marked below:
//sensor first time setup
//I2C enable, pull up disabled
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
report[0] = 0x01;
report[1] = 0x01;
report[2] = 0xC1;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
//Read status register
report[0] = 0x03;
report[1] = 0x02;
report[2] = 0x07;
ret = IOWarrior.Functions.IowKitWrite(Handle, 1, report, 8);
Up to here everything is as expected the return value of ret is 8 as I expect it. But now:
ret = IOWarrior.Functions.IowKitRead(Handle, 1, report, 8);
Here the value of ret is 0 and it should be 8, correct?
Any Idea whichcould cause the read not to work?
Thanks,
Uli