RAK12018 WisBlock Code Scanner Module Quick Star
Prerequisite
- Assemble the RAK12018 with a WisBlock Base and WisBlock Core by following the RAK12018 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)
Software Configuration and Example
NOTE
- 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.
- You need to select first the WisBlock Core you have.
Figure 1: Selecting RAK4631 as WisBlock Core- 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.
Figure 1: Selecting the correct serial port
Figure 1: Uploading the sample code- 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.
Figure 1: Scanning QR code by pressing scan button- If you try to scan the QR code, you should have
Hello WisBlockas the output in the serial monitor.
Figure 1: QR code for test
Figure 1: Serial monitor showing the code read by the sensor