Skip to main content

RAK12014 WisBlock ToF Sensor Module Quick Start Guide

Prerequisite

What Do You Need?

Before going through each and every step on using the RAK12014 WisBlock ToF Sensor Module, make sure to prepare the necessary items listed below:

Hardware

Software

Product Configuration

Hardware Setup

The RAK12014, a part of the RAKwireless WisBlock Sensor Series, is a Time-of-Flight (ToF) module designed based on VL53L0X from STMicroelectronics. The VL53L0X is a ToF laser-ranging module, providing accurate distance measurement up to 2 m. For more information about RAK12014, refer to the Datasheet.

RAK12014 module can be connected to the sensor's slot of WisBlock Base to communicate with the WisBlock Core, as shown in Figure 1. It will work on SLOT C to F. Also, always secure the connection of the WisBlock module by using compatible screws.

Figure 2457: RAK12014 connection to WisBlock Base

Assembling and Disassembling of WisBlock Modules

Assembling

As shown in Figure 2, the location for Slot A, B, C, and D are properly marked by silkscreen. Follow carefully the procedure defined in WisBlock Base board module assembly/disassembly instructions to attach a WisBlock module. Once attached, carefully fix the module with three pieces of M1.2 x 3 mm screws.

Figure 2458: RAK12014 assembly to WisBlock Base
Disassembling

The procedure in disassembling any type of WisBlock module is the same.

  1. First, remove the screws.
Figure 2459: Removing screws from the WisBlock module
  1. Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
Figure 2460: Detaching silkscreen on the WisBlock module
  1. Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the baseboard.
Figure 2461: Applying even forces on the proper location of a WisBlock module
NOTE

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.

warning
  • 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

In this example, you will be able to measure distance via Serial Monitor.

  1. 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.

  2. You need to select first the WisBlock Core you have, as shown in Figure 6 to Figure 8.

RAK4631 Board

Figure 2462: Selecting RAK4631 as WisBlock Core

RAK11200 Board

Figure 2463: Selecting RAK11200 as WisBlock Core

RAK11310 Board

Figure 2464: Selecting RAK11300 as WisBlock Core
  1. Copy the example code below:
Click to view the code
/**
@file RAK12014_Distance_Detection.ino
@author rakwireless.com
@brief Distance detection by laser
@version 0.1
@date 2021-8-28
@copyright Copyright (c) 2020
**/



#include <Wire.h>
#include <vl53l0x_class.h> // Click to install library: http://librarymanager/All#stm32duino_vl53l0x
VL53L0X sensor_vl53l0x(&Wire, WB_IO2);

void setup() {
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
int status;

// Initialize serial for output.
Serial.begin(115200);

// Initialize I2C bus.
Wire.begin();

// Configure VL53L0X component.
sensor_vl53l0x.begin();

// Switch off VL53L0X component.
sensor_vl53l0x.VL53L0X_Off();

// Initialize VL53L0X component.
status = sensor_vl53l0x.InitSensor(0x52);
if(status)
{
Serial.println("Init sensor_vl53l0x failed...");
}
}

void loop() {
// Read Range.
uint32_t distance;
int status;
status = sensor_vl53l0x.GetDistance(&distance);

if (status == VL53L0X_ERROR_NONE)
{
// Output data.
char report[64];
snprintf(report, sizeof(report), "| Distance [mm]: %ld |", distance);
Serial.println(report);
}
delay(300);
}
NOTE

If you experience any error in compiling the example sketch, check the updated code for the RAK12014 WisBlock ToF Sensor Module that can be found on the RAK12014 WisBlock Example Code Repository.

  1. Install the required library, as shown in Figure 9 and Figure 10.
Figure 2465: Getting the library link
Figure 2466: Installing the library
  1. Select the right serial port and upload the code, as shown in Figure 11 and Figure 12.
NOTE

If you are 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.

Figure 2467: Selecting the correct serial port
Figure 2468: Uploading the sample code
  1. When you have successfully uploaded the sample code, you may open up your serial monitor as shown in Figure 13. You can try to experiment with the data by moving the sensor away from the detected surface.
Figure 2469: Serial monitor reading