Rev Author Line No. Line
960 jacho 1 void SHT25_soft_reset()
2 {
3 i2c_start(); // Start condition
4 i2c_write(0x80); // Device address
5 i2c_write(0xFE); // Device command
6 i2c_stop(); // Stop condition
7 }
8  
9 unsigned int8 SHT25_setup(unsigned int8 setup_reg ) // writes to status register and returns its value
10 {
11 unsigned int8 reg;
12  
13 i2c_start(); // Start condition
14 i2c_write(SHT25_ADDR); // Device address
15 i2c_write(0xE7); // Device command
16  
17 i2c_start(); // Start condition
18 i2c_write(SHT25_ADDR+1); // Device address
19 reg=i2c_read(0); // Read status actual status register
20  
21 reg = (reg & 0x3A) | setup_reg;
22  
23 i2c_start(); // Start condition
24 i2c_write(SHT25_ADDR); // Device address
25 i2c_write(0xE6); // Write to status register
26 i2c_write(reg); // Device command
27 i2c_stop(); // Stop condition
28  
29 delay_ms(10);
30  
31 i2c_start(); // Start condition
32 i2c_write(SHT25_ADDR); // Device address
33 i2c_write(0xE7); // Device command
34  
35 i2c_start(); // Start condition
36 i2c_write(SHT25_ADDR+1); // Device address
37 reg=i2c_read(0); // Read status actual status register
38  
39 return (reg);
40 }
41  
42  
43 float SHT25_get_temp()
44 {
45 unsigned int8 MSB, LSB, Check;
46 unsigned int16 data;
47  
48 i2c_start();
49 I2C_Write(SHT25_ADDR);
50 I2C_write(0xE3);
51 i2c_stop();
52  
53 delay_ms(100);
54  
55 i2c_start();
56 I2C_Write(SHT25_ADDR+1);
57 MSB=i2c_read(1);
58 LSB=i2c_read(1);
59 Check=i2c_read(0);
60 i2c_stop();
61  
62 LSB = LSB >> 2; // trow out status bits
63  
64 data = (((unsigned int16) MSB << 8) + (LSB << 4));
65 return(-46.85 + 175.72*((float)data/0xFFFF));
66 }
67  
68 float SHT25_get_hum()
69 {
70 unsigned int8 MSB, LSB, Check;
71 unsigned int16 data;
72  
73 i2c_start(); //RH
74 I2C_Write(SHT25_ADDR);
75 I2C_write(0xE5);
76  
77 delay_ms(100);
78  
79 i2c_start();
80 I2C_Write(SHT25_ADDR+1);
81 MSB=i2c_read(1);
82 LSB=i2c_read(1);
83 Check=i2c_read(0);
84 i2c_stop();
85  
86 LSB = LSB >> 2; // trow out status bits
87  
88 data = (((unsigned int16) MSB << 8) + (LSB << 4) );
89 return( -6.0 + 125.0*((float)data/0xFFFF));
90 }
91