RPi API - Infineon/radar-bgt60 GitHub Wiki

Basic API Usage

Full documentation here

Create An Object From The Bgt60Rpi Class

To create an object of the radar class you can use the following line of code, which will call the constructor of the class:

Bgt60Rpi radar;

This is creating an object of the Bgt60Rpi class with the name radar. This name is just a proposal. The instance of the class can be named how ever you want it.

Initialize The Radar

To initialize all the necessary peripherals of the shield, you can call the init-function of the class as following:

radar.init()

Now the hardware is set up and you're able to start sensing.

Detecting Motion

In order to check if the radar sensor detects motion we have the following function:

radar.getMotion(Motion_t &motion);

This function checks the actual state of the target-detect-pin and returns, depending on its state, the status of the radar, which means either a MOTION or NO_MOTION was detected. This function has to be called at the time the user wants to get the information.

Determining The Direction

In order to determine the direction of the detected motion the following function can be used:

radar.getDirection(Direction_t &direction);

This function checks the actual state of the phase-detect-pin and returns, depending on its state, the status of the radar, which means either an APPROACHING, a DEPARTING or no direction (NO_DIR) was determined. This function has to be called at the time the user wants to get the information.

Note :warning:: The determined direction is only valid if also a motion was detected. Therefore, the function getDirection() will always return NO_DIR as long as no motion was detected, even though the direction LED is on.

Attach A User Defined Callback-Function

The user has the opportunity to attach user defined callback-function. This can be done with the following function:

radar.enableInterrupt(void (*cback) (void))

In this function we attach the callback-function passed as argument to both pins, so the target- and phase-pin. In case the sensor detects motion or stops to detect motion the function will be triggered. Also a change of direction, so a change at the phase-pin will trigger the callback-function. This means you can be sure that either the motion "state" or the direction of the motion has changed and you can perform what ever you like in the callback-function. For example you can set a flag which indicates that something has changed and then depending on this flag check the state of the radar with the corresponding functions.