test MAX31850
Diff: main.cpp
- Revision:
- 1:a5b2695069e5
- Parent:
- 0:55f2866e9c0c
- Child:
- 2:8e35ddc26023
--- a/main.cpp Tue May 27 15:01:13 2014 +0000
+++ b/main.cpp Wed May 28 10:43:37 2014 +0000
@@ -112,8 +112,8 @@
int num_sensor=0;
uint64_t uint64_owID;
uint64_owID = uint64_id(&gSensorIDs[n][num_sensor][0]);
- MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
- wait(0.5);
+
+
uint8_t sp[MAX31850_SP_SIZE];
for (uint8_t i=0 ; i< MAX31850_SP_SIZE; i++ )
sp[i]=0;
@@ -121,7 +121,7 @@
float temp;
int err = MAX31850_Temp_TC(sp,&temp);
if(err) {
- pc.printf( "-1\r ");
+ pc.printf( "-1.0\r ");
} else {
float temp_CJ;
double temp_true;
@@ -132,29 +132,47 @@
}
-
+ MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
}
break;
case 'A':
case 'a':
- if (shtpresent==true) {
- float sht_temp,sht_rh;
- sht_writefile(sht,&sht_temp,&sht_rh);
+ if (owpresent) {
+
+ // read sensor
+
+ int n=0;
+ int num_sensor=1;
+ uint64_t uint64_owID;
+ uint64_owID = uint64_id(&gSensorIDs[n][num_sensor][0]);
+
- //console
- pc.printf("%f", sht_temp);
- pc.printf("%f\r", sht_rh);
+ uint8_t sp[MAX31850_SP_SIZE];
+ for (uint8_t i=0 ; i< MAX31850_SP_SIZE; i++ )
+ sp[i]=0;
+ MAX31850_Read_Scratch(gSensorIDs[n][num_sensor],sp,n) ;
+ float temp;
+ int err = MAX31850_Temp_TC(sp,&temp);
+ if(err) {
+ pc.printf( "-1.0\r ");
+ } else {
+ float temp_CJ;
+ double temp_true;
+ MAX31850_Temp_CJ(sp,&temp_CJ);
+ MAX31850_Temp_TRUE(sp,&temp_true);
+ temp_true=temp_true-mMax31850[uint64_owID]->Get_offset();
+ pc.printf( "%1.3f\r",temp_true);
- } else {
- pc.printf("-1");
- pc.printf("-1\r");
+ }
+ MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
+
}
break;
case '*':
-
- pc.printf("Mbed Temp SHT\r");
+
+ pc.printf("Mbed Temp SHT\r");
break;
frederic blanc