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