Reading binary data sent from OBD-II

Inquiry and support for Freematics products
Post Reply
rosbel
Posts: 2
Joined: Fri Oct 17, 2014 4:08 pm

Reading binary data sent from OBD-II

Post by rosbel »

Hey first, of all thanks for all the great work. Just received my OBD-II Adapter with GPS, and BLE. I downloaded your iOS app, and worked pretty well!
I was trying to create my own iOS app for a school project based on the output that you already send with the OBD-II adapter through SerialBLE.
I am able to retreive information, but haven't been able to make a sense of it. This has taken me the whole day to get to this point, I believe I am pretty close, but would love it if you could help me out a bit.

As far as I understand, you use a struct as the following on your OBD Arduino header.
You cast the information as a (uint8_t*) and send either 12 or 20 based off if you use the float array or just one value.
The code below works perfectly, but I keep on receiving some random values.

Me and my team would greatly appreciate it if you could point us in the right direction.

And keep up the good work!
Been loving this OBD-II adapter, might get myself one for my own purposes after this senior design project!

Image

Code: Select all

       struct BLE_DATA{
      uint32_t time;
      uint16_t pid;
      uint8_t flags;
      uint8_t checksum;
      float value[3];
   };

-(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
   for(CBCharacteristic *characteristic in service.characteristics)
   {
      [peripheral setNotifyValue:YES forCharacteristic:characteristic];
      [self.OBDAdapter readValueForCharacteristic:characteristic];
   }
}


-(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
   struct BLE_DATA myData;
   [characteristic.value getBytes:&myData length:sizeof(myData)];
   NSLog(@"time: %x - pid: %x",myData.time,myData.pid);
   NSLog(@"val[0]: %f - val[1]: %f - val[2]: %f",myData.value[0],myData.value[1],myData.value[2]);
   if(error)
   {
                NSLog(@"Received Error: ",error);
        }
}

Keafer EDV
Posts: 4
Joined: Tue Nov 11, 2014 10:32 pm

Re: Reading binary data sent from OBD-II

Post by Keafer EDV »

Hello rosbel.

I'm at this point to. But in my case the values are not that what I expact. For today I will try to decode the values.
Do you have some new infomations for me? I will tell you later whta I found!

Thanks and happy coding ;)
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Reading binary data sent from OBD-II

Post by stanley »

Take a look at datalogger.h. You will see how data is transmitted.
Post Reply