Line 1... |
Line 1... |
1 |
/**** Automatic weather station 01A ****/ |
1 |
/**** Automatic weather station 01A ****/ |
2 |
#define VERSION "0.1" |
2 |
#define VERSION "0.1" |
3 |
#define ID "$Id: main.c 2913 2013-04-14 12:36:15Z kaklik $" |
3 |
#define ID "$Id: main.c 2915 2013-04-14 14:05:52Z kaklik $" |
4 |
#include "main.h" |
4 |
#include "main.h" |
5 |
#include ".\common\dbloader.h" |
5 |
#include ".\common\dbloader.h" |
6 |
#include <string.h> |
6 |
#include <string.h> |
7 |
|
7 |
|
8 |
#CASE // Case sensitive compiler |
8 |
#CASE // Case sensitive compiler |
Line 16... |
Line 16... |
16 |
|
16 |
|
17 |
#define sht_data_pin PIN_D0 // SHT11 sensor connection |
17 |
#define sht_data_pin PIN_D0 // SHT11 sensor connection |
18 |
#define sht_clk_pin PIN_D1 |
18 |
#define sht_clk_pin PIN_D1 |
19 |
#include "..\SHT.c" |
19 |
#include "..\SHT.c" |
20 |
|
20 |
|
21 |
#use i2c(master, sda=PIN_C4, scl=PIN_C3) |
21 |
#use i2c(master, sda=PIN_D6, scl=PIN_D5) |
22 |
#include "..\SHT25.h" |
22 |
#include "..\SHT25.h" |
23 |
|
23 |
|
24 |
#define CSN_SPI PIN_C2 // preassure sensor connection |
24 |
#define CSN_SPI PIN_C2 // preassure sensor connection |
25 |
#include "..\MPL115A1.c" |
25 |
#include "..\MPL115A1.c" |
26 |
|
26 |
|
27 |
unsigned int16 timer0_overflow_count=0; |
27 |
unsigned int16 timer0_overflow_count; |
28 |
float anemo=0; |
28 |
float anemo; |
29 |
|
29 |
|
30 |
int1 barometer_present; |
30 |
int1 barometer_present; |
31 |
|
31 |
|
32 |
#int_TIMER1 |
32 |
#int_TIMER1 |
33 |
void TIMER1_isr(void) |
33 |
void TIMER1_isr(void) |
Line 89... |
Line 89... |
89 |
enable_interrupts(INT_TIMER0); |
89 |
enable_interrupts(INT_TIMER0); |
90 |
enable_interrupts(GLOBAL); |
90 |
enable_interrupts(GLOBAL); |
91 |
|
91 |
|
92 |
restart_wdt(); //---WDT |
92 |
restart_wdt(); //---WDT |
93 |
|
93 |
|
94 |
sht_init(); |
94 |
// barometer init |
95 |
barometer_present = MPL_init(); // get correction coefficients from the sensor |
95 |
barometer_present = MPL_init(); // get correction coefficients from the sensor |
96 |
|
96 |
|
- |
|
97 |
sht_init(); |
- |
|
98 |
|
97 |
SHT25_soft_reset(); |
99 |
SHT25_soft_reset(); |
98 |
|
100 |
|
- |
|
101 |
// anemometer init |
- |
|
102 |
set_timer0(0); |
- |
|
103 |
set_timer1(0); |
- |
|
104 |
timer0_overflow_count=0; |
- |
|
105 |
anemo=0; |
- |
|
106 |
|
99 |
restart_wdt(); //---WDT |
107 |
restart_wdt(); //---WDT |
100 |
|
108 |
|
101 |
while (TRUE) |
109 |
while (TRUE) |
102 |
{ |
110 |
{ |
103 |
char output[8]; // Output buffer |
111 |
char output[8]; // Output buffer |
Line 115... |
Line 123... |
115 |
sht_rd(SHT_temp1,SHT_hum1); |
123 |
sht_rd(SHT_temp1,SHT_hum1); |
116 |
SHT_temp1 = (SHT_temp1 + 273.15)*100; |
124 |
SHT_temp1 = (SHT_temp1 + 273.15)*100; |
117 |
|
125 |
|
118 |
SHT_temp2 = SHT25_get_temp(); |
126 |
SHT_temp2 = SHT25_get_temp(); |
119 |
SHT_hum2 = SHT25_get_hum(); |
127 |
SHT_hum2 = SHT25_get_hum(); |
- |
|
128 |
SHT_temp2 = (SHT_temp2 + 273.15)*100; |
120 |
|
129 |
|
121 |
if (barometer_present == TRUE) |
130 |
if (barometer_present == TRUE) |
122 |
{ |
131 |
{ |
123 |
barometer_temperature = (MPL_get_temperature() + 273.15)*100; |
132 |
barometer_temperature = (MPL_get_temperature() + 273.15)*100; |
124 |
barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals |
133 |
barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals |