6,15 → 6,6 |
|
#CASE // Case sensitive compiler |
|
/*#define LCD_ENABLE_PIN PIN_E0 //// |
#define LCD_RS_PIN PIN_E1 //// |
#define LCD_RW_PIN PIN_E2 //// |
#define LCD_DATA4 PIN_D4 //// |
#define LCD_DATA5 PIN_D5 //// |
#define LCD_DATA6 PIN_D6 //// |
#define LCD_DATA7 PIN_D7 |
#include <lcd.c> |
*/ |
#define SEND_DELAY 50 // Time between two characters on RS232 |
|
char VER[4]=VERSION; // Buffer for concatenate of a version string |
22,8 → 13,12 |
#define ONE_WIRE_PIN PIN_C7 |
#include "..\ds1820.c" |
|
#define sht_data_pin PIN_D0 |
#define sht_clk_pin PIN_D1 |
#include "..\SHT.c" |
|
#define CSN_SPI PIN_C2 |
#include "..\MPL115A1.c" |
|
void welcome(void) // Welcome message |
{ |
50,7 → 45,6 |
|
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
setup_adc(ADC_CLOCK_DIV_2); |
setup_spi(SPI_SS_DISABLED); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
setup_timer_1(T1_DISABLED); |
setup_timer_2(T2_DISABLED,0,1); |
57,8 → 51,10 |
setup_ccp1(CCP_OFF); |
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
setup_oscillator(OSC_8MHZ); |
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); |
output_high(CSN_SPI); |
delay_ms(100); |
|
|
printf("Simple Thermomether\r\n",); |
printf("(c) Kaklik 2013\r\n"); |
printf("www.mlab.cz\r\n"); |
65,14 → 61,8 |
|
welcome(); |
|
/* lcd_init(); |
lcd_putc("(c) Kaklik 2013"); |
lcd_gotoxy(3,2); |
lcd_putc("www.mlab.cz"); |
Delay_ms(2000); |
*/ |
|
sht_init(); |
MPL_init(); // get correction coefficients from the sensor |
|
while (TRUE) |
{ |
80,16 → 70,17 |
int8 j; // String pointer |
int8 check=0; // Checksum is calculated between '$' and '*' |
float SHT_temp,SHT_hum; |
float local_temp; |
float barometer_temperature, barometer_pressure; |
|
|
// lcd_gotoxy(1,2); |
// printf(lcd_putc,"T: %f K ",ds1820_read()+273.15); |
|
// printf("$T1.0 %f \r\n",ds1820_read()+273.15); |
delay_ms(100); |
{ // printf |
|
sht_rd(SHT_temp,SHT_hum); |
local_temp = ds1820_read()+273.15; |
SHT_temp += 273.15; |
barometer_temperature = MPL_get_temperature() + 273.15; |
barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals |
|
delay_us(SEND_DELAY); |
putc('$'); |
98,12 → 89,16 |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"%Lu \0", seq); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"%f \0", ds1820_read()+273.15); |
sprintf(output,"%f \0", local_temp ); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"%f \0", SHT_temp + 273.15); |
sprintf(output,"%f \0", SHT_temp); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"%f \0", SHT_hum); |
sprintf(output,"%3.1f \0", SHT_hum); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"%f \0", barometer_temperature); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"%5.1f \0", barometer_pressure); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } |
sprintf(output,"*%X\r\n\0", check); |
j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j++]); } |
delay_us(SEND_DELAY); |
112,9 → 107,7 |
//---WDT |
restart_wdt(); |
seq++; // Increment the number of measurement |
|
} |
|
} |
|
//#include "dbloader.c" // Space reservation for the BootLoader |