Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TMP006 Temperature Sensor
12-07-2016, 12:04 PM,
#21
RE: TMP006 Temperature Sensor
An example for value = 3.14159265
float = 0.0012.8 with the format %f12.8. 
In your example it is the same 6.2 as response with %f6.2.
It means there is confusion between the format%f and the value to print. It's a BIG bug !
12-07-2016, 12:20 PM,
#22
RE: TMP006 Temperature Sensor
I don't understand very well what you told but I tried this : %6.2f
I don't know if it's correct but I just got that : 0.00 *C
But I still can't get correct data..


Attached Files Thumbnail(s)
   
12-07-2016, 12:30 PM,
#23
RE: TMP006 Temperature Sensor
Now, I made a test and I tried with that code :
Code:
void loop()
{
 int object_temp = TMP006_readObjTempC();
//  Serial.print("Object Temperature: ");
//  Serial.print(object_temp,FLOAT); Serial.println("*C");
 CDC.printf("Object Temperature: %d *C\r\n", object_temp);
 int sensor_temp = TMP006_readDieTempC();
//  Serial.print("Sensor Temperature: ");
//  Serial.print(sensor_temp,FLOAT); Serial.println("*C");
 CDC.printf("Sensor Temperature: %d *C\r\n",sensor_temp);

 delay(1000); // delay 1 second for every 4 samples per reading
}
And I got back data right data but not enough accurate.
Enclodes results in Putty for the temperatures.
So, there is a problem with float,%f I presume.


Attached Files Thumbnail(s)
   
12-07-2016, 12:39 PM,
#24
RE: TMP006 Temperature Sensor
signification for %f6.2
6characters are reserved 
the decimal part is printed on 2 characters.
Example: the temp is 21.253 the printed result will be  21.25 (preceded by a space).

I found that in the IDE version 12 the CDC lib is different for printing so I am going to install it in X.4
12-07-2016, 01:09 PM,
#25
RE: TMP006 Temperature Sensor
I also tried with "double" instead of "float" but it doesn't work.
Code:
 double object_temp = TMP006_readObjTempC();
 CDC.printf("Object Temperature: %.2f *C\r\n", object_temp);
 double sensor_temp = TMP006_readDieTempC();
 CDC.printf("Sensor Temperature: %.2f *C\r\n",sensor_temp);

 delay(1000); // delay 1 second for every 4 samples per reading
}
I tried with CDC.print but nope. It's difficult to get back data from this sensor on a Pinguino board.
12-07-2016, 08:49 PM,
#26
Big Grin  RE: TMP006 Temperature Sensor
About printing float data we can keep hope because I found the P8 printFloat function in IDE version 12 which works.
I only need  time to implement it in P32 X.4 and it is often hard to find time [Image: biggrin.gif]
See you soon
André
13-07-2016, 09:10 AM, (This post was last modified: 13-07-2016, 09:12 AM by gtcbreizh.)
#27
RE: TMP006 Temperature Sensor
I found a solution to print float data : use CDC.printFloat(value, numerOfDigits).
I tried it before but there was a bug. Now it is corrected.
Here are :
the 2 corrected sketches
TMP006.c according the corrections done on CDC_inBuffer
__cdc.c with the correction on CDCprintFloat (replacement to do in P32\include\pinguino\core)

I hope it will work for you too.


Attached Files
.pde   TMP_006.pde (Size: 1,007 bytes / Downloads: 2)
.pde   TMP_006no_buf.pde (Size: 927 bytes / Downloads: 1)
.c   TMP006.c (Size: 4.55 KB / Downloads: 1)
.c   __cdc.c (Size: 15.02 KB / Downloads: 1)
13-07-2016, 11:11 AM,
#28
RE: TMP006 Temperature Sensor
Demat,

I don't know what you exactly did/modified in _cdc.c but it works, you are a genius.
I can get back data with two numbers after the comma.
Thank you very much André.
Enclosed the results in Putty.


Attached Files Thumbnail(s)
   


Forum Jump:


Users browsing this thread: 1 Guest(s)