Industry White Paper
Detecting Human Motion: Configuring a Digital PIR Sensor on the FPB-RA0E1
Learn how to connect a digital PIR motion sensor to the Renesas FPB-RA0E1, configure the GPIO pin in e² studio, and watch a motion flag update in real time.
You have just powered on a new microcontroller board, and you need it to react to a person's presence. Getting a board to sense when someone walks into a room sounds like a simple hardware task. However, you quickly realize the interface requires precise software pin configurations to ensure the microcontroller reads the high and low logic signals accurately.
This article demonstrates how to interface a digital passive infrared (PIR) sensor with the Renesas FPB-RA0E1 Fast Prototyping Board. Using the e² studio IDE and the Flexible Software Package (FSP), you will configure a specific GPIO pin to disable its internal pull-up resistor. You will also write a C application to continuously read the pin state and update a software flag when movement from a human is detected. In the real world, this exact detection strategy allows embedded systems to automate lighting, trigger security alerts, and wake up display panels.
Project Specs
| Target Board | FPB-RA0E1 |
| MCU Family | Renesas RA0 Series |
| Peripheral Covered | I/O Port (P103) |
| IDE/Toolchain | e² studio + FSP |
| Interface Used | Base Shield for Arduino interface |
| Baud Rate | N/A |
| Skill Level | Beginner |
| Build Time | 15 minutes |
| Prerequisites | e² studio installed, board initialized, hardware connected |
Why Motion Detection Matters
Motion detection is a key requirement in smart lighting, security systems, and automated HVAC controls. By directly reading a digital PIR sensor, your embedded device can instantly react to human presence. The PIR sensor outputs a digital high signal when movement occurs. By properly configuring the microcontroller's GPIO pin to read this signal without interference from internal pull-up resistors, you ensure accurate and reliable detection. Mastering this digital input strategy is the first step toward building interactive environments and complex sensor networks on the Renesas RA0 Series.
What You'll Need
Hardware
- Renesas FPB-RA0E1 Fast Prototyping Board
- Base Shield for Arduino interface
- Digital PIR Sensor
- USB cable
Software
The Concept in 60 Seconds
A digital PIR sensor monitors changes in infrared radiation. When a human moves within its range, the sensor generates a high digital signal. To read this signal, you must connect the sensor to a specific pin on the microcontroller. By reading its state in a continuous software loop, the microcontroller can determine whether movement is currently happening. However, the complexity lies in ensuring the pin's internal pull-up resistor is disabled so it doesn't interfere with the sensor's high signal output.
Step-by-Step: Building the Project
Step 1: Connect the Hardware
- Attach the Base Shield to the Arduino interface on the FPB-RA0E1 board.
- Connect the digital PIR sensor to the D7 slot of the Base Shield.

Figure 1. The digital PIR sensor connected to the Base Shield on the FPB-RA0E1. Image used courtesy of Renesas
Step 2: Create the Project
- Open e² studio and create a new Renesas C/C++ project named Digital_pir_sensor.
- Select the FPB-RA0E1 board, choose Executable and No RTOS, and select the Bare Metal - Minimal template.

Figure 2. Selecting the FPB-RA0E1 board in the e² studio project setup. Image used courtesy of Renesas
Setting the exact board part number ensures the FSP generates the correct pin mappings and clock trees for your hardware.
Step 3: Disable the Input Pull-Up Mode
- Open the FSP Configuration file and click the Pins tab.
- Expand P1, click on P103, and change the Input pull-up/down setting to None.
- Click Generate Project Content.

Figure 3. Setting the P103 input pull-up to None in the Pins tab. Image used courtesy of Renesas
According to the quick start guide, the D7 slot of the Arduino interface is connected to P103. Disabling the pull-up is necessary because the sensor generates its own high signal when human movement is detected.
Step 4: Define the Variables
- In the Project Explorer tab, expand the src folder and open the hal_entry.c file.
- Declare a uint8_t flag variable named movement_detected, setting its value to 0.
- Inside the hal_entry function, declare an fsp_err_t variable named status and a bsp_io_level_t variable named pin_state.
These variables provide the memory space necessary to store the function execution status and the current logic level of the hardware pin.
Step 5: Read the Pin State
- Create a while(1) loop.
- Open the Developer Assistance tab, expand the IO Port, and drag and drop the IOPORT_PinRead API call into the loop.
- For the pin argument, provide BSP_IO_PORT_01_PIN_03, and for the pin state argument, provide the address of your pin_state variable.

Figure 4. Adding the R_IOPORT_PinRead call inside the while loop. Image used courtesy of Renesas
Dragging and dropping from the Developer Assistance tool guarantees you are using the correct API call format to interface with the HAL drivers.
Step 6: Add the Assertion Check
- Directly under the read function, add an assert function call.
- Set the condition to check if the status value is equal to FSP_SUCCESS.
This step ensures the microcontroller successfully reads the hardware pin state before attempting to process the motion data.
Step 7: Implement the Detection Logic
- Check the value of the pin_state variable with an if condition.
- If it is equal to BSP_IO_LEVEL_HIGH, set the movement_detected flag to 1.
- In the else condition, set the movement_detected flag to 0.

Figure 5. The if condition sets the movement_detected flag when the pin reads high. Image used courtesy of Renesas
This simple logic translates the raw electrical logic levels of the physical pin into a clear software flag indicating human movement.
Step 8: Monitor the Live Variable
- Right-click your project name, build the project using the hammer icon, and launch a Renesas GDB Hardware Debugging session.
- Switch to the Debug perspective. Click on Window, then click on Show View, and select Expressions.
- In the Expressions window, click "Add new expression" and type movement_detected. Right-click it and select Enable Real-time Refresh.

Figure 6. Enabling Real-time Refresh on the movement_detected expression. Image used courtesy of Renesas
Real-time refresh allows the IDE to continuously monitor the variable's value over the debug interface without pausing code execution.
Code Snippet
// Continuously read the pin state of P103
status = R_IOPORT_PinRead(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03, &pin_state);
assert(FSP_SUCCESS == status);
// Update the flag variable based on the sensor's signal
if (pin_state == BSP_IO_LEVEL_HIGH)
{
movement_detected = 1;
}
else
{
movement_detected = 0;
}
What You Should See
After adding the variable to the Expressions window and enabling Real-time Refresh, click the resume button twice to start code execution. If you sit still, the movement_detected flag remains at 0. When you move your hand or give a gesture to the sensor, the movement_detected flag should change to 1 in the Expressions window.

Figure 7. The movement_detected flag updating in the Expressions window as the sensor detects motion. Image used courtesy of Renesas
Troubleshooting
The Expressions Window Does Not Update
Ensure you have right-clicked the expression and selected "Enable Real-time Refresh." Also, confirm you have clicked the Resume button twice in the debug toolbar to actually start execution.
The Pin State Does Not Change When There Is Movement
Verify that the sensor is plugged firmly into the D7 slot on the Base Shield. The D7 slot corresponds to the P103 pin you configured in the FSP software.
The Sensor Output Is Erratic
Check your FSP configuration on the Pins tab to confirm the Input pull-up setting for P103 is explicitly set to None. Leaving it enabled can interfere with the high signal generated by the sensor.
Where to Take It Next
Now that you can accurately detect motion using the Expressions window, the next logical step is to make the hardware react physically. Try adding the R_IOPORT_PinWrite API call to your if statement to illuminate the board's onboard LED whenever the flag reads high.
For a more efficient software architecture, consider moving away from continuously polling the pin in a while(1) loop. Instead, configure the P103 pin as an external interrupt request (IRQ). This approach frees up the CPU and allows you to transition the FPB-RA0E1 into a low-power sleep state, using the sensor's signal to wake the board only when someone enters the room.
Frequently Asked Questions
Why Is the Pull-Up Resistor Disabled?
The sensor generates its own high signal when human movement is detected. According to the example project provided by the sensor manufacturer, disabling the input pull-up mode is necessary when reading this high signal.
How Do I Know Which Pin to Configure for the D7 Slot?
According to the quick start guide document, the D7 slot of the Arduino interface is connected to pin P103. This requires the input pull-up setting to be disabled in the FSP Configuration file.
How Do I Monitor Variables Without Printing to a Terminal?
The e² studio IDE includes an Expressions window in the Debug perspective. By adding a variable to this window and enabling Real-time Refresh, you can view the variable's value updating continuously as the microcontroller runs.
What Is the Base Shield Used For?
The Base Shield attaches directly to the Arduino interface on the FPB board. It offers plug-and-play slots for easily connecting external hardware modules like the digital PIR sensor.