RAK14008 WisBlock Gesture Sensor Module Quick Start Guide
Prerequisite
- Prepare a WisBlock Base with a sensor slot, a compatible WisBlock Core, and the RAK14008 module. For assembly instructions, refer to the RAK14008 Installation Guide.
- Install the Arduino IDE and the RAKwireless Arduino BSP for your WisBlock Core.
- USB cable
- RAK19008 WisBlock IO Extension Cable (optional)
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Initial Test of the RAK14008 WisBlock Module
-
This guide uses the RAK4631 WisBlock Core for the configuration example. You can also use the RAK11200 or RAK11300 WisBlock Core.
-
If you're using the RAK11200 as your WisBlock Core, the RAK11200 requires the Boot0 pin to be configured properly first before uploading. If not done properly, uploading the source code to RAK11200 will fail. Check the full details on the RAK11200 Quick Start Guide) .
-
Install the RAKwireless Arduino BSP for WisBlock by using the
package_rakwireless_index.jsonboard installation package. The WisBlock Core should now be available on the Arduino IDE. -
You need to select first the WisBlock Core you have.
Figure 1: Selecting RAK4631 as WisBlock Core- Next, copy the following sample code into your Arduino IDE:
Click to view the code
/**
@file RAK14008_Gesture_Recognize_PAJ7620.ino
@author rakwireless.com
@brief This example can recognize 9 gestures and output the result,
including move up, move down, move left, move right, move forward,
move backward, circle-clockwise, circle-counter clockwise, and wave.
@version 0.1
@date 2021-9-28
@copyright Copyright (c) 2021
**/
#include "RevEng_PAJ7620.h" //Click here to get the library: http://librarymanager/All#Gesture_PAJ7620
RevEng_PAJ7620 sensor = RevEng_PAJ7620(); // Create gesture sensor Object.
void setup()
{
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
// Initialize Serial for debug output
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("RAK14008 PAJ7620 Test example.");
Serial.println("PAJ7620 sensor demo: Recognizing all 9 gestures.");
if( !sensor.begin() ) // Returns 0 if sensor connect fail
{
Serial.print("PAJ7620 I2C error - halting");
while(1)
{
delay(10);
}
}
Serial.println("PAJ7620 Init OK.");
Serial.println("Please input your gestures:");
}
void loop()
{
Gesture gesture; // Gesture is an enum type from RevEng_PAJ7620.h
gesture = sensor.readGesture(); // Read back current gesture (if any) of type Gesture
switch (gesture)
{
case GES_FORWARD:
{
Serial.print("GES_FORWARD");
break;
}
case GES_BACKWARD:
{
Serial.print("GES_BACKWARD");
break;
}
case GES_LEFT:
{
Serial.print("GES_LEFT");
break;
}
case GES_RIGHT:
{
Serial.print("GES_RIGHT");
break;
}
case GES_UP:
{
Serial.print("GES_UP");
break;
}
case GES_DOWN:
{
Serial.print("GES_DOWN");
break;
}
case GES_CLOCKWISE:
{
Serial.print("GES_CLOCKWISE");
break;
}
case GES_ANTICLOCKWISE:
{
Serial.print("GES_ANTICLOCKWISE");
break;
}
case GES_WAVE:
{
Serial.print("GES_WAVE");
break;
}
case GES_NONE:
{
break;
}
}
if(gesture != GES_NONE)
{
Serial.print(", Code: ");
Serial.println(gesture);
}
delay(100);
}
If you experience any error in compiling the example sketch, check the updated code for your WisBlock Core Module that can be found on the RAK14008 WisBlock Example Code Repository and this sample code in Github will work on all WisBlock Core.
- Once the example code is open, install the PAJ7620 library by clicking the yellow highlighted link.
Figure 1: Accessing the library used for RAK14008 Module
Figure 1: Installing the compatible library for RAK14008 Module- After the successful installation of the library, you can now select the right serial port and upload the code.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the RAK14008 example code- When you successfully uploaded the example sketch, open the Serial Monitor of the Arduino IDE, set the baud rate correctly, and once you have made a gesture or movement in front of the RAK14008 sensor, you'll be able to see the sensor's output. Therefore, your RAK14008 is properly communicating to the WisBlock core.
Figure 1: RAK14008 Gesture Sensor Serial Readings