RAK12005 WisBlock Rain Sensor Module Quick Start Guide
Prerequisite
- Assemble the RAK12005 with a WisBlock Base and WisBlock Core by following the RAK12005 Installation Guide.
- Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
- USB Cable
- RAK19008 WisBlock IO Extension Cable (optional)
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Initial Test of the RAK12005 WisBlock Module
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.
-
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- Next, copy the following sample code into your Arduino IDE.
Click to view the code
/**
* @file RAK12005_WaterDetector.ino
* @author rakwireless.com
* @brief use RAK12005 water detector module to detect rain
* @version 0.1
* @date 2021-05-24
* @copyright Copyright (c) 2021
*/
#define SENSOR_PIN WB_IO6 // Attach Water sensor to Arduino Digital Pin WB_IO6
void setup()
{
pinMode(SENSOR_PIN, INPUT); // The Water Sensor is an Input
pinMode(LED_GREEN, OUTPUT); // The LED is an Output
pinMode(LED_BLUE, OUTPUT); // The LED is an Output
}
void loop()
{
/* The water sensor will switch HIGH when water is detected.
when water is detected turn LED on, and switch off when no water is present */
if( digitalRead(SENSOR_PIN) == HIGH)
{
digitalWrite(LED_GREEN,HIGH); //turn on
digitalWrite(LED_BLUE,HIGH);
}else
{
digitalWrite(LED_GREEN,LOW);
digitalWrite(LED_BLUE,LOW);
}
}
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 RAK12005 WisBlock Example Code Repository. This sample code in Github will work on all WisBlock Core.
- Then you can now select the right port and upload the code.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the RAK12005 Sample code- When you successfully uploaded the example sketch, you'll now be able to test the RAK12005 Rain Sensor module. Try pouring water on the copper traces of the RAK12030 and you'll be able to see that the blue and green LED of the WisBlock solution lights up when there is a presence of water, and then switched off when there is no presence of water or dry.
