For the complete documentation index, see llms.txt. This page is also available as Markdown.

🚶‍♂️PIR Motion Sensor

Function introduction

This sensor allows you to detect animals' movement, usually humans' movement within its detection range. Just connect it to the NyBoard and program it, and when anyone moves within its detection range, the sensor will output a high potential on its SIG pin.

BiBoard

Hardware setup

BiBoard V1 for Bittle X V2 / Bittle X+Arm / Nybble Q

BiBoard V0 for Bittle X

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth or attached to the top of Nybble's head). Of course, you can also use your creativity to meet your needs.

Software setup

There are two methods to upload the firmware :

  • Using the Petoi Desktop App

  • Using the Arduino IDE

Petoi Desktop App

  • You can use the Firmware Uploader within the Petoi Desktop App. Please select the correct Product type, Borard version, and Serial port. The mode should be Standard, so press the Upgrade the Firmware button. for example, Bittle, BiBoard_V0_2, COM5 as follows:

Arduino IDE

  • You can use Arduino IDE to upload the sketch(OpenCatEsp32.ino). Use the latest OpenCatESP32 code to finish the setup. For example, to modify the code for Bittle as shown below:

After uploading, there are two methods to activate/deactivate the PIR mode:

  • Serial Monitor

    • Open the serial monitor and use the serial command "XI" to activate the PIR mode.

    • Open the serial monitor and use the serial command "Xi" to deactivate the PIR mode.

  • Mobile App

    • Create a mobile app command called "Activate PIR" and use the code: X73

    • Create a mobile app command called "Deactivate PIR" and use the code: X105

NyBoard for Bittle / Nybble

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture:

Software setup

Petoi Desktop App

Arduino IDE

  • You can use Arduino IDE to upload and modify the source code.

The code using this sensor has been integrated into the OpenCat project. Uncomment the line #define PIR in the OpenCat.ino, as shown in the figure below, and use the Arduino IDE to upload the sketch to the robot main board, which can reproduce the example function of integrating the robot action.

Prepare the Arduino UNO development environment.

With NyBoard V1_*, you can choose Arduino Uno.

Modify the code in the OpenCat.ino

Testing code

If you want to test a PIR motion sensor's function alone or learn more about its principles. You can use the Arduino IDE to upload the demo sketch(test_Touch_Reflection_PIR.ino):

This demo sketch implements real-time printing of sensor detection results in the serial monitor - when anyone moves within its detection range, print 1; otherwise, print 0.

Last updated