RAK12018 WisBlock Code Scanner Module Quick Start Guide
Prerequisite
What Do You Need?
Before going through each and every step on using the RAK12018 WisBlock Code Scanner Module, make sure to prepare the necessary items listed below:
Hardware
- RAK12018 WisBlock Code Scanner 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 Arduino IDE.
- To add the RAKwireless Core boards to your Arduino Boards Manager, install the RAKwireless Arduino BSP.
Product Configuration
Hardware Setup
The RAK12018 is a code scanner module that is compatible with various 1D and 2D codes like the common barcodes and QR codes. This module includes the optical sensor LV3296 scanner from RAKINDA. The LV3296 has UART output and communicates the scanned code readings to the WisBlock Core. For more information about RAK12018, refer to the Datasheet.
This scanner module can be mounted on the IO slot of the WisBlock Base board, as shown in Figure 1. Also, always secure the connection of the WisBlock module by using compatible screws.
Assembling and Disassembling of WisBlock Modules
Assembling
As shown in Figure 3, the location for the IO slot is properly marked by silkscreen. Follow carefully the procedure defined in WisBlock Base 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 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 RAK5005-O board. Not all batteries have the same wiring.
Software Configuration and Example
In this example, you will be scanning a generic QR code and the reading will be displayed on the Arduino serial monitor.
- You need to select first the WisBlock Core you have, as shown in Figure 7 to Figure 9.
- Copy the example code below and paste it into the Arduino IDE:
Click to view the code
/**
@file RAK12018_CodeReader_LV3296.ino
@author rakwireless.com
@brief Get 1D or 2D code
@version 0.1
@date 2021-8-28
@copyright Copyright (c) 2020
**/
#include <Wire.h>
void setup()
{
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
time_t serial_timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - serial_timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("RAK12018 Barcodes Scanner!");
Serial1.begin(9600);
}
void loop()
{
int timeout = 1000;
String rsp = "";
while (timeout--)
{
if (Serial1.available() > 0)
{
rsp += char(Serial1.read());
}
delay(1);
}
if (rsp.length() > 0)
{
Serial.println(rsp);
}
rsp = "";
}
If you experience any error in compiling the example sketch, check the updated code for the RAK12018 WisBlock Code Scanner Module that can be found on the RAK12018 WisBlock Example Code Repository.
- Select the right serial port and upload the code, as shown in Figure 10 and Figure 11.
If you are using RAK11200 WisBlock Core, it requires the BOOT0 pin to be configured properly 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, open up your Arduino serial monitor and try to scan any barcode or QR code. Align the front of the sensor to the QR code and press the button, as shown in Figure 12.
- If you try to scan the QR code in Figure 13, you should have
Hello WisBlock
as the output in the serial monitor shown in Figure 14.