RAK12013 Quick Start Guide
Prerequisite
What Do You Need?
Before going through each and every step on using the RAK12013 WisBlock module, make sure to prepare the necessary items listed below:
Hardware
- RAK12013 WisBlock Radar Sensor Module
- Your choice of WisBlock Base
- Your choice of WisBlock Core
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
- Download and install the ArduinoIDE.
- To add the RAKwireless Core boards on your Arduino board, install the RAKwireless Arduino BSP. Follow the steps in the Github repo.
Product Configuration
Hardware Setup
RAK12013 is a 3.2 GHz microwave radar module based on RCWL-9196. It uses the Doppler radar effect to detect moving objects/motion using microwaves. The RCWL-9196 will transmit and receive a 3.2 GHz radar signal and compare the difference between the two signals to determine whether the object is moving or not.
For more information about RAK12013, refer to the Datasheet.
RCWL-9196 Antenna
The antenna coil of the RCWL-9196 is where part of the sensor gets the motion detected.
- The component side of the PCB module or the front is the positive sensing face, while the opposite side, which is the back, is the negative sensing face. The negative sensing face is less effective in terms of sensing.
Assembling and Disassembling of WisBlock Modules
Assembling
The RAK12013 module can be mounted on the IO slot of the WisBlock Base board, as shown in Figure 3. Also, always secure the connection of the WisBlock module by using compatible screws.
Disassembling
The procedure in disassembling any type of WisBlock modules is the same.
- First, remove the screws.
- Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
- Apply force to the module at the position of the connector, as shown in Figure 6, to detach the module from the baseboard.
If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin Mapper tool for possible conflicts.
After all this setup, you can now connect the battery (optional) and USB cable to start programming your WisBlock Core.
- Batteries can cause harm if not handled properly.
- Only 3.7-4.2 V Rechargeable LiPo batteries are supported. It is highly recommended not to use other types of batteries with the system unless you know what you are doing.
- If a non-rechargeable battery is used, it has to be unplugged first before connecting the USB cable to the USB port of the board to configure the device. Not doing so might damage the battery or cause a fire.
- Only 5 V solar panels are supported. Do not use 12 V solar panels. It will destroy the charging unit and eventually other electronic parts.
- Make sure the battery wires match the polarity on the WisBlock Base board. Not all batteries have the same wiring.
Software Configuration and Example
Initial Test of the RAK12013 WisBlock Module
-
Install the RAKwireless Arduino BSP for WisBlock by using the
package_rakwireless_index.json
board installation package. The WisBlock Core should now be available on the Arduino IDE. -
You need to select first the WisBlock Core you have.
RAK4631 Board
RAK11200 Board
RAK11310 Board
- Next, copy the following sample code into your Arduino IDE:
Click to view the code
/**
@file RAK12013_Rader_3GHZ.ino
@author rakwireless.com
@brief Rader_3GHZ example.
The RCWL-0516 is a motion detection sensor.
It can detect motion through doppler microwave technology through walls or other materials.
It will get triggered not only by people but also by other moving objects.
@version 0.1
@date 2021-10-18
@copyright Copyright (c) 2020
**/
#include <Wire.h>
#define SENSOR_OUT WB_IO3
#define SENSOR_EN WB_IO4
#define BLUE_LED LED_BLUE
#define GREEN_LED LED_GREEN
boolean g_motion_status = false;
void setup()
{
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
pinMode (SENSOR_EN, OUTPUT);
digitalWrite(SENSOR_EN, HIGH); // Sensor disable input (low = disable)
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("Rader 3GHZ example");
pinMode (SENSOR_OUT, INPUT);
pinMode (BLUE_LED, OUTPUT);
pinMode (GREEN_LED, OUTPUT);
Serial.println("Waiting for motion");
}
void loop()
{
int val; // Read Pin as input
val = digitalRead(SENSOR_OUT);
if((val > 0) && (g_motion_status == false))
{
digitalWrite(BLUE_LED, HIGH);
digitalWrite(GREEN_LED, LOW);
Serial.println("Motion Detected");
g_motion_status = true;
}
if((val == 0) && (g_motion_status == true))
{
digitalWrite(BLUE_LED, LOW);
digitalWrite(GREEN_LED, HIGH);
Serial.println("NO Motion");
g_motion_status = false;
}
}
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 RAK12013 WisBlock Example Code Repository and this sample code in Github will work on all WisBlock Core.
- Once the example code is open, you can now select the right serial port and upload the code, as shown in Figure 10 and Figure 11.
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.
- When you successfully uploaded the example sketch, open the serial monitor of the Arduino IDE to see the sensor's reading logs, as shown in Figure 12. You'll be able to see that the led from your WisBlock Base board, lights into blue whenever there is movement or motion, and lights to green whenever there is no movement or motion at all. Therefore, your RAK12013 is properly communicating to the WisBlock core.