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; |
2906 |
jacho |
11 |
|
2909 |
kaklik |
12 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
13 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
14 |
setup_spi(SPI_SS_DISABLED); |
|
|
15 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
16 |
setup_timer_1(T1_DISABLED); |
|
|
17 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
18 |
setup_ccp1(CCP_OFF); |
|
|
19 |
setup_comparator(NC_NC_NC_NC); |
|
|
20 |
|
2911 |
kaklik |
21 |
SHT25_soft_reset(); |
2909 |
kaklik |
22 |
printf("SHT25 humidity and temperature sensor example \r\n",); |
|
|
23 |
delay_ms (500); |
|
|
24 |
|
|
|
25 |
while(TRUE) |
|
|
26 |
{ |
2912 |
kaklik |
27 |
if (i<10) sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; // loop alters on chip heater on and off to check correct function |
2911 |
kaklik |
28 |
else |
|
|
29 |
{ |
2912 |
kaklik |
30 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_ON; |
|
|
31 |
if (i > 20) i = 0; |
2911 |
kaklik |
32 |
} |
2912 |
kaklik |
33 |
printf("setup: %X %X \r\n",SHT25_setup(sht_config),sht_config); |
2909 |
kaklik |
34 |
delay_ms (500); |
|
|
35 |
printf("Temp: %f \r\n",SHT25_get_temp()); |
|
|
36 |
delay_ms (500); |
|
|
37 |
printf("Hum: %f \r\n",SHT25_get_hum()); |
|
|
38 |
delay_ms (1000); |
2911 |
kaklik |
39 |
i++; |
2909 |
kaklik |
40 |
} |
2906 |
jacho |
41 |
} |
|
|
42 |
|