Nxt ultasonic sensor return -1

Why sometimes the ultrasonic sensor returns -1 value ?

Read lines 77-91 in BrickPi.py

It explains a fix.

Hi @bonnaudet.eric,

This is usually observed when the Ultrasonic sensor returns junk values or when it goes unrecognised. This happens when the Ultrasonic Read is done continuously without a delay. This error can be minimized by adding delays.

-Shoban