RAK12032 WisBlock 3-Axis Accelerometer Sensor Quick Start Guide
Prerequisite
Package Inclusions
Before going through each and every step on using the RAK12032 WisBlock Module, make sure to prepare the necessary items listed below:
Hardware
- RAK12032 WisBlock 3-Axis Accelerometer 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 Arduino IDE.
- To add the RAKwireless Core boards to your Arduino Boards Manager, install the RAKwireless Arduino BSP.
Product Configuration
Hardware Setup
WisBlock can integrate this module to extend the WisBlock system with an accelerometer sensor.
For more information about RAK12032, refer to the Datasheet.
RAK12032 module can be connected to the sensor's slot of WisBlock Base to communicate with the WisBlock Core, as shown in Figure 2. It will work on SLOT C to F. Also, always secure the connection of the WisBlock module by using compatible screws.
-
RAK12032 has two digital output lines for interrupt signal, so two input GPIOs from WisBlock Core are needed to capture these interrupts. Slots A and B use WB_IO2 which is dedicated to switching the power supply (3V3_S) to Sensor Slots. It can't be used as input.
-
Slots C, D, E & F are possible to be used if the size of the module fits in and if the slot is available, which depends on the specific type of WisBlock Base board.
Assembling and Disassembling of WisBlock Modules
Assembling
As shown in Figure 2, the locations for Slot C, D, E, and F are 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 one or more pieces of M1.2 x 3 mm screws depending on the module.
This chip is highly sensitive, and the tightness of the mounting screws will affect its zero offset. Therefore, it is advised that once the RAK12032 is installed, do not repeatedly loosen or tighten the screws. The zero offset must need to be calibrated again every time loosening or tightening the screw the screws. Recommended screw torque range: 0.032–0.054 N-m.
Disassembling
The procedure for disassembling any type of WisBlock module is the same.
- To begin disassembling, remove the screws.
- After removing the screws, check the silkscreen of the module to find the correct location where force can be applied.
- Detach the module from the base board by applying forcer to the module at the position of the connector, as shown in Figure 5.
- If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin Mapper. This tool finds possible pin conflicts.
- RAK12032 uses I2C communication lines and two IO pins for interrupt signals, which can cause possible conflict, especially on some IO modules.
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
Initial Test of the RAK12032 WisBlock Module
-
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. -
After that, you need to select the WisBlock Core you have.
RAK4631 WisBlock Core
RAK11200 WisBlock Core
RAK11310 WisBlock Core
- Next, copy the following sample code into your Arduino IDE:
Click to view the code
/**
@file RAK12032_3_Axis_Read_ADXL313.ino
@author rakwireless.com
@brief Read 3-axis acceleration data and print it out through the serial port.
@version 0.1
@date 2021-12-25
@copyright Copyright (c) 2021
**/
#include <Wire.h>
#include <SparkFunADXL313.h> //Click here to get the library: http://librarymanager/All#SparkFun_ADXL313
ADXL313 myAdxl;
void setup()
{
// Initialize Serial for debug output
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("Reading values from ADXL313");
Wire.begin();
if (myAdxl.begin() == false) //Begin communication over I2C
{
Serial.println("The sensor did not respond. Please check wiring.");
while(1)
{
delay(10);
}
}
Serial.println("Sensor is connected properly.");
myAdxl.measureModeOn(); // Wakes up the sensor from standby and puts it into measurement mode
}
void loop()
{
float xAxis,yAxis,zAxis;
if(myAdxl.dataReady()) // Check data ready interrupt, note, this clears all other int bits in INT_SOURCE reg
{
myAdxl.readAccel(); // Read all 3 axis, they are stored in class variables: myAdxl.x, myAdxl.y and myAdxl.z
/*
* ±0.5 g : 1024 LSB/g
* ±1 g : 512 LSB/g
* ±2 g : 256 LSB/g
* ±4 g : 128 LSB/g
*/
xAxis = (float)myAdxl.x / 1024;
yAxis = (float)myAdxl.y / 1024;
zAxis = (float)myAdxl.z / 1024;
Serial.print(" x: ");
Serial.print(xAxis);
Serial.print("[g] y: ");
Serial.print(yAxis);
Serial.print("[g] z: ");
Serial.print(zAxis);
Serial.println("[g]");
}
else
{
Serial.println("Waiting for dataReady.");
}
delay(50);
}
If you experience any error in compiling the example sketch, check the updated code for your WisBlock Core Module. You can find it on the RAK12032 WisBlock Example Code Repository. The sample code on GitHub will work on all WisBlock Core.
- Once the example code is open, install the SparkFun_ADXL313_Arduino_Library library. Click the highlighted link, as shown in Figure 9.
It is important to install version 1.0.0, as shown in Figure 10, since it is the stable version of the library. The latest version still has compatibility issues that need to be resolved.
- After successful installation of the library, you can now select the right serial port and upload the code, as shown in Figure 11 and Figure 12.
If you're 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 example sketch, open the serial monitor of the Arduino IDE to see the sensor's reading logs. If you see the logs, as shown in Figure 13, then your RAK12032 is communicating with the WisBlock core properly. The polarity of the axis depends on the sensor slot where you connected the module.