RAK12029 WisBlock Inductive Sensor Module Quick Start Guide
Prerequisite
-
Assemble the RAK12029 with a WisBlock Base and WisBlock Core by following the RAK12029 Installation Guide.
-
Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
-
USB Cable
Initial Test of the RAK12029 WisBlock Inductive Sensor Module
-
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.
-
Install the RAKwireless Arduino BSP for WisBlock by using the
package_rakwireless_index.jsonboard installation package. The WisBlock Core should now be available on the Arduino IDE. -
You need to select first the WisBlock Core you have.
Figure 1: Selecting RAK4631 as WisBlock Core- Copy the example code below:
Click to view the code
/**
@file Single_channel_detection.ino
@author rakwireless.com
@brief Metallic object detected
@version 1.0
@date 2021-11-17
@copyright Copyright (c) 2021
**/
#include "RAK12029_LDC1614.h" // Click to install library: http://librarymanager/All#RAK12029_LDC1614
#define INDUCTANCE 13.000
#define CAPATANCE 100.0
#define GETCHANNEL LDC1614_CHANNEL_0 //LDC1614_CHANNEL_(0~3)
RAK12029_LDC1614_Inductive ldc;
void setup()
{
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, LOW);
//Sensor power switch
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
delay(300);
//control chip switch
pinMode(WB_IO5, OUTPUT);
digitalWrite(WB_IO5, LOW);
// Initialize Serial for debug output
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("RAK12029 TEST");
delay(1000);
ldc.LDC1614_init();
/*single channel use case configuration.*/
if (ldc.LDC1614_single_channel_config(GETCHANNEL, INDUCTANCE, CAPATANCE))
{
Serial.println("can't detect sensor!");
while (1) delay(100);
}
}
void loop()
{
u16 value = 0;
ldc.IIC_read_16bit(LDC1614_READ_DEVICE_ID, &value);
if (value == 0x3055)
{
u32 ChannelData = 0;
/*Get channel 0 result and parse it.*/
delay(100);
if (ldc.LDC1614_get_channel_result(GETCHANNEL, &ChannelData) == 0)
{
/*sensor result value.you can make a lot of application according to its changes.*/
if (0 != ChannelData)
{
Serial.printf("The result channel%d is:%d\r\n", 4 - GETCHANNEL, ChannelData);
digitalWrite(LED_BLUE, HIGH);
}
delay(1000);
digitalWrite(LED_BLUE, LOW);
}
}
else
{
Serial.println("The IIC communication fails,please reset the sensor!");
delay(500);
}
}
If you experience any error in compiling the example sketch, check the updated code for your WisBlock Core Module that can be found on the RAK12029 WisBlock Example Code Repository and this sample code in Github will work on all WisBlock Core.
- Install the RAKwireless Inductive Sensor Module Librarylibrary by clicking the red-highlighted link then click install.
Figure 1: Getting the library of RAK12029
Figure 1: Installing the library of RAK12029- Then 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, place any metal or coin in the sensor. Then, you can open up your serial monitor to get the sensor readings.
Figure 1: Testing the RAK12029 Inductive Sensor Module
Figure 1: RAK12029 Inductive Sensor Module readings in the serial monitor