Line 6... |
Line 6... |
6 |
#include "SHT25.h" |
6 |
#include "SHT25.h" |
7 |
|
7 |
|
8 |
void main() |
8 |
void main() |
9 |
{ |
9 |
{ |
10 |
unsigned int8 i=0, sht_config; |
10 |
unsigned int8 i=0, sht_config; |
- |
|
11 |
float temperature, humidity; |
11 |
|
12 |
|
12 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
13 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
13 |
setup_adc(ADC_CLOCK_DIV_2); |
14 |
setup_adc(ADC_CLOCK_DIV_2); |
14 |
setup_spi(SPI_SS_DISABLED); |
15 |
setup_spi(SPI_SS_DISABLED); |
15 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
16 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
Line 18... |
Line 19... |
18 |
setup_ccp1(CCP_OFF); |
19 |
setup_ccp1(CCP_OFF); |
19 |
setup_comparator(NC_NC_NC_NC); |
20 |
setup_comparator(NC_NC_NC_NC); |
20 |
|
21 |
|
21 |
SHT25_soft_reset(); |
22 |
SHT25_soft_reset(); |
22 |
printf("SHT25 humidity and temperature sensor example \r\n",); |
23 |
printf("SHT25 humidity and temperature sensor example \r\n",); |
- |
|
24 |
printf("Temperature Humidity[%%] \r\n"); |
23 |
delay_ms (500); |
25 |
delay_ms (500); |
24 |
|
26 |
|
- |
|
27 |
|
25 |
while(TRUE) |
28 |
while(TRUE) |
26 |
{ |
29 |
{ |
27 |
if (i<10) sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; // loop alters on chip heater on and off to check correct function |
30 |
if (i<100) sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; // loop alters on chip heater on and off to check correct function |
28 |
else |
31 |
else |
29 |
{ |
32 |
{ |
30 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_ON; |
33 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_ON; |
31 |
if (i > 20) i = 0; |
34 |
if (i > 120) i = 0; |
32 |
} |
35 |
} |
- |
|
36 |
|
33 |
printf("setup: %X %X \r\n",SHT25_setup(sht_config),sht_config); |
37 |
temperature = SHT25_get_temp(); |
34 |
delay_ms (500); |
38 |
humidity = SHT25_get_hum(); |
- |
|
39 |
|
35 |
printf("Temp: %f \r\n",SHT25_get_temp()); |
40 |
printf("%f %f %X %X \r\n",temperature, humidity, SHT25_setup(sht_config),sht_config); |
36 |
delay_ms (500); |
41 |
i++; |
37 |
printf("Hum: %f \r\n",SHT25_get_hum()); |
- |
|
38 |
delay_ms (1000); |
42 |
delay_ms(1000); |
39 |
i++; |
- |
|
40 |
} |
43 |
} |
41 |
} |
44 |
} |
42 |
|
45 |
|