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
- RAK12014 WisBlock ToF Sensor Module
- Your choice of WisBlock Base
- Your choice of WisBlock Core
- USB Cable
- RAK19005 WisBlock Sensor Extension Cable (optional)
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
- Download and install the Arduino IDE.
- To add the RAKwireless Core boards to your Arduino Boards Manager, install the RAKwireless Arduino BSP.
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.
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.
Disassembling
The procedure in disassembling any type of WisBlock module 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 5, 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
In this example, you will be able to measure distance via Serial Monitor.
-
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, as shown in Figure 6 to Figure 8.
RAK4631 Board
RAK11200 Board
RAK11310 Board
- 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);
}
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.
- Install the required library, as shown in Figure 9 and Figure 10.
- Select the right serial port and upload the code, as shown in Figure 11 and Figure 12.
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.
- 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.