Parse the textual response from a UrSense board

class UrSenseParser(obfuscation_distance_km: float = 2)#

Parse the textual response from a UrSense board

Some of the returned results may be sensitive information, such as the GPS location. Functionality is provided to provide a quantised version of the GPS position so exact position cannot be determined. It is the user’s responsibility not to publish raw sensor data that may lead to leakage of sensitive information.


obfuscation_distance_km (float) – Dimension of squares for quantising GPS location

parse(data: str) Union[Dict[str, Reading], Type[None]]#

Parse the serial results output by a urSense 1.28 board as specified in the user documentation v1.21.

The methodology is to start with a list of fields. Then process the first element of the list to figure out what type of reading it is and how many fields to consume. Format this appropriately and return it as a Reading. Repeat the process with the processed fields removed from the front of the list. Once the list reaches a length of zero, precessing the line is complete. For each Reading an attribute – specified by the ursense_map – of the final SensorLog is set.


data (str) – The serial data output from the urSense board


The current data as a SensorLog or None if the input could not be parsed.

Return type:

Union[SensorLog, Type[None]]