RAK12013 Quick Start Guide
Prerequisite
- Assemble the RAK12013 with a WisBlock Base and WisBlock Core by following the RAK12013 Installation Guide.
- Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Initial Test of the RAK12013 WisBlock Module
- This guide uses the RAK4631 WisBlock Core to demonstrate the configuration process. You can also use the RAK11200 or RAK11310 as the WisBlock Core.
- When using the RAK11200, configure the BOOT0 pin correctly before uploading the source code. Otherwise, the upload may fail. For detailed instructions, refer to 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 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.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the RAK12013 example code- When you successfully uploaded the example sketch, open the serial monitor of the Arduino IDE to see the sensor's reading logs. 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.
Figure 1: RAK12013 Radar Sensor readings