Listing the available sensors using RAD Studio XE3 and FireMonkey 2

Posted by on in Blogs
RAD Studio XE3 includes new classes for identifying, managing and using any sensors that are available on your target Windows and Mac computers. In this blog post I show you how to list all of the sensors that are available on a computer (you can do this using Delphi and C++Builder). Delphi XE3 and C++Builder XE3 include the new the new System.Sensors unit.

From the unit, the categories of sensors (TSensorCategory) are:

  • Location

  • Environmental

  • Motion

  • Orientation

  • Mechanical

  • Electrical

  • Biometric

  • Light

  • Scanner

For each sensor category the unit defines (currently) the following possible sensor types:
  TLocationSensorType = (GPS, Static, Lookup, Triangulation, Broadcast, DeadReckoning, Other);
TEnvironmentalSensorType = (Temperature, AtmosphericPressure, Humidity, WindSpeed, WindDirection);
TMotionSensorType = (Accelerometer1D, Accelerometer2D, Accelerometer3D, MotionDetector, Gyrometer1D, Gyrometer2D, Gyrometer3D, Speedometer);
TOrientationSensorType = (Compass1D, Compass2D, Compass3D, Inclinometer1D, Inclinometer2D, Inclinometer3D, Distance1D, Distance2D, Distance3D);
TElectricalSensorType = (Voltage, Current, Capacitance, Resistance, Inductance, ElectricalPower, Potentiometer);
TMechanicalSensorType = (BooleanSwitch, BooleanSwitchArray, MultiValueSwitch, Force, Scale, Pressure, Strain);
TBiometricSensorType = (HumanPresence, HumanProximity, Touch);
TLightSensorType = (AmbientLight);
TScannerSensorType = (RFID, Barcode);

The following code will get the number of sensors on a computer (you first have to activate the sensors) and displays the names of the sensors and their category:
System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Layouts,
FMX.Memo, FMX.Media, System.Sensors;

TForm3 = class(TForm)
Button2: TButton;
Label2: TLabel;
Memo2: TMemo;
procedure Button2Click(Sender: TObject);
{ Private declarations }
NumberOfSensors : integer;
{ Public declarations }

Form3: TForm3;


{$R *.fmx}
uses System.TypInfo;

procedure TForm3.Button2Click(Sender: TObject);
i : integer;
// get list of found sensors - if any
TSensorManager.Current.Active := true;
NumberofSensors := TSensorManager.Current.Count;
Label2.Text := 'Sensors: '+IntToStr(NumberOfSensors);
for i := 0 to NumberOfSensors-1 do begin
+ ': '
+ TSensorManager.Current.Sensors[i].Name
+ '", Category: '
+ GetEnumName(System.TypeInfo(TSensorCategory),
TSensorManager.Current.Active := false;

On my Samsung Slate 7 computer running Windows 8 Professional, the Delphi XE3 code will find several hardware and software based sensors including the following:

FireMonkey 2 also includes two new non-visual components, TLocationSensor and TMotionSensor, that you can drag and drop onto your forms. With these components and sensor-based code you can build FireMonkey 2 applications that take advantage of hardware in currently available notebooks/slates and have your applications ready for future FireMonkey mobile device support  (see the RAD Studio Mobile Roadmap at

Gold User, Rank: 1, Points: 2466
David Intersimone (known to many as David I.) is a passionate and innovative software industry veteran-often referred to as a developer icon-who extols and educates the world on Embarcadero developer tools. He shares his visions as an active member of the industry speaking circuit and is tapped as an expert source by the media. He is a long-standing champion of architects, developers and database professionals and works to ensure that their needs are folded into Embarcadero's strategic product plans. David holds a bachelor's degree in computer science from California Polytechnic State University at San Luis Obispo, California.


  • Guest
    normnet Thursday, 27 September 2012

    Are these sensors typically USB?
    Would the sensor manufacturer's proprietary drivers also be required?
    Is their an example of communication with one of these devices?

  • Guest
    pascalbbs Thursday, 27 September 2012


  • Guest
    Phil Grainger Sunday, 30 September 2012

    Although it is not surprising given the direction RAD Studio is heading, towards support of the mobile market that is, it is none the less a very interesting extension. Add device control and you could almost be entering an embedded market.

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: