Author Topic: Temperature Conversion  (Read 1935 times)

Jengil

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Temperature Conversion
« on: May 13, 2015, 11:00:05 AM »
Hello,

I'm just getting started working with RFDuino and was trying to send the temperature to my android device's android test app via BLE.  I read the previous post about temperature conversion, and would like a little more elaboration as I can't seem to get accurate readings. 

I am working in room temperature (~70 degrees F).  When I program the RFDuino to send a float with the temperature in Celsius, I receive a "00 00 FFFFFFF4 41", which yields 244 / 8 = 30.5 C - it seems extremely warm. 

Code: [Select]
float tempC = RFduino_temperature(CELSIUS);
RFduinoBLE.sendFloat(tempC);

When I set a float with the temperature in Fahrenheit and send over BLE, my received output on the Android test app alternates between the two of these "FFFFFFCD FFFFFFCC FFFFFFAD 42" and "FFFFFFCD 4C FFFFFFA9 42"  which respectively gives 173/8 = 21.625, and 169/8 = 21.125 F

Code: [Select]
float temp = RFduino_temperature(FAHRENHEIT);
RFduinoBLE.sendFloat(temp);

These last two (Fahrenheit) values are what I had expected to see in the Celsius measurements, but I am not sure.  Either way I don't understand the conversion convention and where the temperature data is within the received packets.  I have proceeded to serial print the temperatures before I send them - it reads ~30.5 C and ~87 F, which seems reasonable for a chip's temperature in a room temperature of ~70F.  What I don't seem to understand is how to read the Fahrenheit values apparently on the receiving/Android end. 

Any more elaboration would be great!

Thanks!

Jengil

MattG

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Temperature Conversion
« Reply #1 on: September 03, 2015, 11:13:54 AM »
What if you debug this by sending a constant floating point number?

bsiever

  • RFduino Full Member
  • ***
  • Posts: 89
  • Karma: +4/-0
    • View Profile
Re: Temperature Conversion
« Reply #2 on: September 03, 2015, 02:09:19 PM »
In addition to MattG's suggestion, a few more thoughts/questions:
  • Have you tried using Serial.println() and the Console in the Arduino IDE  to print the floating point value that RFduino_temperature() returns?
  • I'm not sure what data you're showing.  Do you mean that the 4-byte values, like FFFFFFA9, are the floating point number you receive on the Anrdoid device?
  • The temperature from RFduino_temperature() is the processor die temperature.  A few notes about it:
    • Its precision is 0.25°C. And it may vary based on processor/die heat.
    • I don't think the RFduino has been pre-calibrated, so you may need an offset calibration to improve accuracy. Try to take an initial measurement and figure out how far off it is. Add that correction factor to all future measurements.
    There are some notes on the Nordic developer forums about this. Here's one example: https://devzone.nordicsemi.com/question/31661/nrf51822-temp-internal-temperature-sensor-characteristic/