Python to access the Ping raw data on Raspberry PI

Going back a few posts here - How do you convert the raw profile data into normal measurements? I think there is another recent post effectively asking the same question?

Hi Andrew,

The profile message contains the following fields:

Type Name Description Units
u32 distance The current return distance determined for the most recent acoustic measurement. mm
u16 confidence Confidence in the most recent range measurement. %
u16 transmit_duration The acoustic pulse length during acoustic transmission/activation. us
u32 ping_number The pulse/measurement count since boot.
u32 scan_start The beginning of the scan region in mm from the transducer. mm
u32 scan_length The length of the scan region. mm
u32 gain_setting The current gain setting. 0: 0.6, 1: 1.8, 2: 5.5, 3: 12.9, 4: 30.2, 5: 66.1, 6: 144
u16 profile_data_length The length of the proceeding vector field
u8[] profile_data An array of return strength measurements taken at regular intervals across the scan region.

As you can check here: ping1d - Ping Protocol

The distance will provide the measurements that you are looking for.
The confidence provides how likely is this distance to be correct using the sensor algorithms.
scan_start and scan_length points where the profile_data was taken with a scan_length resolution inside this range.
If you want to calculate the distance based in the raw profile_data, you’ll need to figure out your own algorithm.