Nanosensors operate based on various principles such as optical, electrical, and mechanical changes in response to specific biological or chemical interactions. These changes are then converted into measurable signals. For example, an optical nanosensor might detect the presence of a virus by the change in light emission when the virus binds to a receptor.