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 2834 2013-03-15 00:32:54Z kaklik $" |
3 |
#define ID "$Id: main.c 2835 2013-03-15 15:59:31Z 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 47... |
Line 47... |
47 |
char REV[50]=ID; // Buffer for concatenate of a version string |
47 |
char REV[50]=ID; // Buffer for concatenate of a version string |
48 |
|
48 |
|
49 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
49 |
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; |
50 |
printf("\r\n\r\n# AWS01A %s (C) 2013 www.mlab.cz \r\n",VER); // Welcome message |
50 |
printf("\r\n\r\n# AWS01A %s (C) 2013 www.mlab.cz \r\n",VER); // Welcome message |
51 |
printf("#%s\r\n",&REV[4]); |
51 |
printf("#%s\r\n",&REV[4]); |
52 |
printf("# ver seq temp[K] hum_temp[K] hum[%%] "); |
52 |
printf("# ver seq temp[mK] hum_temp[mK] hum[%%] "); |
53 |
printf("bar_temp[K] pressure[hPa] check\r\n\r\n"); |
53 |
printf("bar_temp[mK] pressure[hPa] Anemo[pls/s]check\r\n\r\n"); |
54 |
|
54 |
|
55 |
restart_wdt(); //---WDT |
55 |
restart_wdt(); //---WDT |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
void main() |
58 |
void main() |
Line 89... |
Line 89... |
89 |
int8 check=0; // Checksum is calculated between '$' and '*' |
89 |
int8 check=0; // Checksum is calculated between '$' and '*' |
90 |
float SHT_temp,SHT_hum; |
90 |
float SHT_temp,SHT_hum; |
91 |
float local_temp; |
91 |
float local_temp; |
92 |
float barometer_temperature, barometer_pressure; |
92 |
float barometer_temperature, barometer_pressure; |
93 |
|
93 |
|
94 |
delay_ms(100); |
94 |
delay_ms(1000); |
95 |
{ // printf |
95 |
{ // printf |
96 |
|
96 |
|
97 |
local_temp = ds1820_read()+273.15; |
97 |
local_temp = ds1820_read()+27315; |
98 |
sht_rd(SHT_temp,SHT_hum); |
98 |
sht_rd(SHT_temp,SHT_hum); |
99 |
SHT_temp += 273.15; |
99 |
SHT_temp += 273.15; |
100 |
// barometer_temperature = MPL_get_temperature() + 273.15; |
100 |
barometer_temperature = MPL_get_temperature() + 273.15; |
101 |
// barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals |
101 |
barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals |
102 |
|
102 |
|
103 |
delay_us(SEND_DELAY); |
103 |
delay_us(SEND_DELAY); |
104 |
putc('$'); |
104 |
putc('$'); |
105 |
delay_us(SEND_DELAY); |
105 |
delay_us(SEND_DELAY); |
106 |
sprintf(output,"AWS%s \0",VER); |
106 |
sprintf(output,"AWS%s \0",VER); |
107 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
107 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
108 |
sprintf(output,"%Lu \0", seq); |
108 |
sprintf(output,"%Lu \0", seq); |
109 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
109 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
110 |
sprintf(output,"%f \0", local_temp ); |
110 |
sprintf(output,"%5.0f \0", local_temp ); |
111 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
111 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
112 |
sprintf(output,"%f \0", SHT_temp); |
112 |
sprintf(output,"%5.0f \0", SHT_temp*100); |
113 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
113 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
114 |
sprintf(output,"%3.1f \0", SHT_hum); |
114 |
sprintf(output,"%3.1f \0", SHT_hum); |
115 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
115 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
116 |
sprintf(output,"%f \0", barometer_temperature); |
116 |
sprintf(output,"%f \0", barometer_temperature); |
117 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
117 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |