Skip to main content

RAK12010 WisBlock Ambient Light Sensor Module Quick Start Guide

Prerequisite

What Do You Need?

Before going through each and every step on using the RAK12010 WisBlock module, make sure to prepare the necessary items listed below:

Hardware

Software

  • Download and install ArduinoIDE.
  • To add the RAKwireless Core boards on your Arduino board, install the RAKwireless Arduino BSP. Follow the steps in the Github repo.

Product Configuration

Hardware Setup

WisBlock can integrate this module which makes it easy to build up an ambient light data acquisition system.

For more information about RAK12010, refer to the Datasheet.

The RAK1210 module gives information about:

  • Ambient Light

RAK12010 module can be connected to the sensor's slot of WisBlock Base to communicate with the WisBlock Core, as shown in Figure 1. It will work on SLOT A to F. Also, always secure the connection of the WisBlock module by using compatible screws.

Figure 2377: RAK12010 connection to WisBlock Base

Assembling and Disassembling of WisBlock Modules

Assembling

As shown in Figure 2, the location for Slot A, B, C, and D 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.

Figure 2378: RAK12010 connection to WisBlock Base
Disassembling

The procedure in disassembling any type of WisBlock modules is the same.

  1. First, remove the screws.
Figure 2379: Removing screws from the WisBlock module
  1. Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
Figure 2380: Detaching silkscreen on the WisBlock module
  1. Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the baseboard.
Figure 2381: Applying even forces on the proper location of a WisBlock module
NOTE

If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin Mapper tool for possible conflicts. RAK12010 uses I2C communication lines, and it 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.

warning
  • 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 RAK12010 WisBlock Module

  1. 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.

  2. You need to select first the WisBlock Core you have, as shown in Figure 6 to Figure 8.

RAK4631 Board

Figure 2382: Selecting RAK4631 as WisBlock Core

RAK11200 Board

Figure 2383: Selecting RAK11200 as WisBlock Core

RAK11310 Board

Figure 2384: Selecting RAK11310 as WisBlock Core
  1. Next, copy the following sample code into your Arduino IDE:
Click to view the example
/**
@file RAK12010_VEML7700_Light.ino
@author rakwireless.com
@brief Measure ambient light.
@version 0.1
@date 2021-7-15
@copyright Copyright (c) 2021
**/
#include "Light_VEML7700.h" ////http://librarymanager/All#Light_veml7700

Light_VEML7700 VMEL = Light_VEML7700();

void setup()
{
// Initialize Serial for debug output

pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
delay(300);
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
if (!VMEL.begin())
{
Serial.println("Sensor not found");
while (1);
}

VMEL.setGain(VEML7700_GAIN_1);
VMEL.setIntegrationTime(VEML7700_IT_800MS);

Serial.print(F("Gain: "));
switch (VMEL.getGain())
{
case VEML7700_GAIN_1: Serial.println("1"); break;
case VEML7700_GAIN_2: Serial.println("2"); break;
case VEML7700_GAIN_1_4: Serial.println("1/4"); break;
case VEML7700_GAIN_1_8: Serial.println("1/8"); break;
}

Serial.print(F("Integration Time (ms): "));
switch (VMEL.getIntegrationTime())
{
case VEML7700_IT_25MS: Serial.println("25"); break;
case VEML7700_IT_50MS: Serial.println("50"); break;
case VEML7700_IT_100MS: Serial.println("100"); break;
case VEML7700_IT_200MS: Serial.println("200"); break;
case VEML7700_IT_400MS: Serial.println("400"); break;
case VEML7700_IT_800MS: Serial.println("800"); break;
}

//veml.powerSaveEnable(true);
//veml.setPowerSaveMode(VEML7700_POWERSAVE_MODE4);

VMEL.setLowThreshold(10000);
VMEL.setHighThreshold(20000);
VMEL.interruptEnable(true);
}

void loop()
{
Serial.print("Lux: ");
Serial.println(VMEL.readLux());
Serial.print("White: ");
Serial.println(VMEL.readWhite());
Serial.print("Raw ALS: ");
Serial.println(VMEL.readALS());
uint16_t irq = VMEL.interruptStatus();
if (irq & VEML7700_INTERRUPT_LOW)
{
Serial.println("Low threshold");
}
if (irq & VEML7700_INTERRUPT_HIGH)
{
Serial.println("High threshold");
}
delay(500);
}

NOTE

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 RAK12010 WisBlock Example Code Repository. This sample code in Github will work on all WisBlock Core.

  1. Once the example code is open, install the RAKWireless VEML7700 library by clicking the yellow highlighted link, as shown in Figure 9 and Figure 10.
Figure 2385: Accessing the library used for RAK12010 Module
Figure 2386: Installing the compatible library for RAK12010 Module
  1. 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.
NOTE

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.

Figure 2387: Selecting the correct Serial Port
Figure 2388: Uploading the RAK12010 example code
  1. When you 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 RAK12010 is properly communicating to the WisBlock core. The values changes depending on the brightness/illuminance level of the ambient light.
Figure 2389: RAK12010 Ambient Light data logs