Author Topic: Getting values from BLE  (Read 125 times)

davidgs

  • RFduino Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Getting values from BLE
« on: January 18, 2018, 01:32:47 PM »
I've been playing with this for a while, and I can't seem to find the right solution.

I have a SenseAir k30 CO2 sensor hooked to my RFDuino, and it does a reasonable job of handling that. I get correct readings on the RFDuino Console.

The problem comes when I try to send those values to a connected device.

Code: [Select]
float co2Value = readCO2();
  if (co2Value > 0)
  {
    Serial.print("CO2 Value: ");
    Serial.println(co2Value);
    RFduinoBLE.sendFloat(co2Value);   
  }

Works fine, and if I connect to the RFDuino using the RFDuino Temperature iPhone app -- I modified it and rebuilt it to just display the value received -- it gets the right data.

Here's the thing though. I need to get the values from a Linux box.

Code: [Select]
root@pine64:~# gatttool -b C1:C4:E4:05:14:95 -t random --char-read  --handle=0x000e
Characteristic value/descriptor: 00 80 ee 43
root@pine64:~#

so that's
Code: [Select]
[0, 128, 238, 67]
But the actual reading is 487. Simply adding up the numbers gets me 433, so I'm missing something about how to handle this output. 

martin7743

  • RFduino Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Getting values from BLE
« Reply #1 on: January 20, 2018, 10:51:58 AM »
I do not know the tool you are using, but if you are awaiting a 4 byte float value, your 4 byte hex values "00 80 ee 43" with the most promising endian variant gives me a decimal value of 477.
It's not your mentioned 487, but take a hex to float converter and check again if that's the miracle behind your problem.

Best regards,
Martin