Proximity Sensor

Proximity sensors detect the presence of objects without physically touching them. They are often used as a touch-less switch, automatically turning on faucets and opening doors to name a few examples.

MetaDetector boards are outfitted with the TSL2671 proximity detector, a photoelectric style detector that refelcts an infrared signal off the target object to measure distance. This sensor is accessed with the IProximityTsl2671 interface.

using MbientLab.MetaWear.Sensor;

IProximityTsl2671 proximity = metawear.GetModule<IProximityTsl2671>();

Configuration

The TSL2671 device has 4 configurable parameters that control the sensitivity and distance at which the detector can measure proximity. These parameters are set with the interface’s Configure method.

Parameter Description
Integration Time How long the internal ADC converts analog input into digital counts
Pulse Count Number of IR pulses emitted for distance measuring
Receiver Diode Which photodiode to use for measure incoming light
Transmitter Current Amount of current driving the IR transmitter
using MbientLab.MetaWear.Sensor.ProximityTsl2671;

// set integration time to 5.44ms
// use both photodiodes for proximity detection
// use default pulse count of 1,
// set drive current to 25mA
proximity.Configure(ReceiverDiode.Both, TransmitterDriveCurrent._25mA, 5.44f);

Proximity Data

Proximity data is an ADC value represented as an unsigned short; the higher the adc value, the closeer the distance to the object.

await proximity.Adc.AddRouteAsync(source =>
    source.Stream(data => Console.WriteLine("Proximity ADC = " + data.Value<ushort>()))
);