RAK12017 WisBlock IR Detection Sensor Module Quick Start Guide
Prerequisite
What Do You Need?
Before going through each and every step on using RAK12017 WisBlock IR Detection Sensor Module, make sure to prepare the necessary items listed below:
Hardware
- RAK12017 WisBlock IR Detection Sensor Module
- Your choice of WisBlock Base with IO slot
- Your choice of WisBlock Core
- USB Cable
- RAK19008 WisBlock IO Extension Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
- Download and install ArduinoIDE.
- To add the RAKwireless Core boards on your Arduino Boards Manager, install the RAKwireless Arduino BSP.
Product Configuration
Hardware Setup
The RAK12017 is an IR detection module. This module uses ITR20001 optical switch from Everlight to detect whether the IR Signal reflects. For more information about RAK12017, refer to the Datasheet.
RAK12017 module can be connected to the IO slot of WisBlock Base to communicate with the WisBlock Core, 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 2, the location for the IO slot is properly marked by silkscreen. Follow carefully the procedure defined in WisBlock Base board 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 modules 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 see if the IR Status is sensing or not using the 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 RAK12017_Detect_Switch.ino
@author rakwireless.com
@brief Detect the objects
@version 0.1
@date 2021-8-28
@copyright Copyright (c) 2020
**/
#include <Wire.h>
void setup()
{
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, LOW);
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
pinMode(WB_IO4, INPUT);
}
void loop()
{
if (digitalRead(WB_IO4) == 0)
{
Serial.println("IR Status: Sensing");
Serial.println(" value: 1");
digitalWrite(LED_BLUE, HIGH);
}
else
{
Serial.println("IR Status: Not Sensed");
Serial.println(" value: 0");
digitalWrite(LED_BLUE, LOW);
}
delay(500);
}
If you experience any error in compiling the example sketch, check the updated code for the RAK12017 WisBlock IR Detection Sensor Module that can be found on the RAK12017 WisBlock Example Code Repository.
- Select the right Serial Port and upload the code, as shown in Figure 9 and Figure 10.
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 11.
- Try to place a finger to trigger the sensor, as shown in Figure 12. Then, check your serial monitor again while your finger is blocking the sensor, as shown in Figure 13.
- You can adjust the sensitivity by turning the potentiometer using a flat screwdriver.
You can also try other code examples of RAK12017 by visiting RAK12017 WisBlock Example Code Repository.