DF ROBOT SEN0545 User manual

User Manual
Intelligent Rain Detection
Module User Manual

User Manual
1. Introduction
This intelligent rain detection module is mainly intended for automatic wiper control
of security cameras. When installed inside a camera windshield, the module is capable
of sensing precise rainfall status on glass surface of the windshield and feeds back
information(no rain, light rain, moderate rain, or heavy rain) to a host by UART, then
the host can control the wiper get rid of the raindrops on the windshield to ensure a
clear view for the camera in rainy conditions. It features as follows:
⚫Based on optical sensing system, accurately detects rainfall status on glass and
sends information to host via UART;
⚫HALIOS®-SD measurement method, high robustness against strong sunlight;
⚫Less environmental interference and longer service life since the product is
used inside windshields without direct exposure to external natural environment;
⚫Tiny body with a diameter of 12.5±0.15mm, suitable for cameras of all kinds;
⚫CRC-8 check for improving anti-interference ability in communication;
⚫Partial parameters setup can be changed by UART configuration;
⚫Error self-diagnostic, actively sends error status to host via UART;
⚫Optical system self-calibration;
⚫Ambient light detection, providing cameras with more auxiliary parameters;
⚫On-board temperature detection, excellent temperature linearity to ensure
accurate measurements;
⚫Supporting optical sleep mode to extend the service life of the optic
components.
1.1 Product Figure
The product figure is shown in Figure 1.1
Figure 1.1 Product Figure

User Manual
1.2 Detailed Functions
The module communicates with the camera host via UART, and the camera host
uses all the functions of the module through UART commands. For example, the
module sends the rainfall status to the camera host via UART; the camera host
configures the module's rain detection sensitivity and other parameters via UART.
Each function will be described in detail below. For convenience, the "slave" refers
to the rain detection module, and the "host" refers to the camera host hereafter.
1.2.1 UART Communication
The UART configuration is shown in Table 1.1.
Table 1.1 UART Configuration
Baud Rate
115200
Data Bit
8bit
Stop Bit
1bit
Check Bit
NONE
Each UART command includes 5 Bytes of data and the frame format is as shown in
Table 1.2. The frame header is fixed 0x3A, as shown in Table 1.3; the frame flag
and frame data represent a frame data, as shown in Table 1.4. FCS represents the
CRC-8 checksum value of the frame flag and the frame data, as shown in Table 1.5.
Table 1.2 UARTFrame Format
Frame Header
Frame Flag
Frame Data
FCS CRC-8
1Byte
1Byte
2Byte
1Byte
Table 1.3 Frame Definition
Frame
Header[7:0]
Frame Header Definition
0x3A
Each frame of 5 Byte data must start with 0x3A (colon character":”in ASCII)

User Manual
Table 1.4 Definition of Frame Flag & Frame Data
Frame Flag[7]:
Data Read &
Write Property
Frame Flag[6:0]: Data Number
Frame
Data
[15:0]:
Data
Value
Description
0 (Read)
1 (Write)
0 (Firmware Version)
X
Frame Data [15:8] major version
number,
Frame data [7:0] backup version
number
1 (Rainfall Status)
0
No rain
1
Light rain
2
Moderate rain
3
Heavy rain
2 (System Status)
0
System normal
1
RS200 Internal communication
error
2
LEDA damaged
3
LEDB damaged
4
Optical system calibration not
good
5
Parameter configuration failure
6
Serial communication error
(serial port check error)
7
Low voltage warning (low
voltage threshold 2.8V)
3 (Optical System)
0
Perform optical system
calibration
1
Send optical system calibration
value
4 (Enter Real-time Rainfall Mode)
0
Exit real-time rainfall mode
1
Enter real-time rainfall mode

User Manual
Continued
Frame Flag[7]:
Data Read &
Write Property
Frame Flag[6:0]:
Data Number
Data
[15:0]:
Data
Value
Description
0 (Read)
1 (Write)
5 (Rainfall status output
frequency or
enable/disable)
0~9
Rainfall status output frequency, the
default is 1, representing 50ms; it can be
changed. Increasing or reducing 1
represents an increase or decrease of
50ms (output is disabled when it's 0)
6 (No-rain/light-rain
threshold V1)
0~65535
No-rain/light-rain threshold V1
7 (Light-rain/moderate-
rain threshold V2)
0~65535
Light-rain/moderate-rain threshold V2
8 (Moderate-rain/heavy-
rain threshold V3)
0~65535
Moderate-rain/heavy-rain threshold V3
9 (No-rain/light-rain
threshold S1)
0~65535
No-rain/light-rain threshold S1
10 (Light-rain/moderate-
rain threshold S2)
0~65535
Light-rain/moderate-rain threshold S2
11 (Moderate-
rain/heavy-rain threshold
S3)
0~65535
Moderate-rain/heavy-rain threshold S3
12 (Threshold of the number
of times determined to be
heavy rain in 10
measurements N1)
1~10
Threshold of the number of times
determined to be heavy rain in 10
measurements N1
13 (Threshold of the number
of times determined to be
moderate rain in 10
measurements N2)
1~10
Threshold of the number of times
determined to be moderate rain in 10
measurements N2
14 (Threshold of the number
of times determined to be
light rain in 10
measurements N3)
1~10
Threshold of the number of times
determined to be light rain in 10
measurements N3
15 (Ambient light
detection mode)
0
Exit ambient light detection mode
1
Enter ambient light detection mode
16 (Host reads module
temperature)
0
Host reads module temperature once
17 (Module optical sleep
0
Exit sleep mode and enter rainfall detection
1
Enter sleep mode

User Manual
mode)
Table 1.5 FCS Definition
FCS[7:0]
Polynomial (HEX)
Data
Reverse
Initial Value
(HEX)
XOR Value (HEX)
CRC-8
x8+x5+x4+1 (0x31)
MSB First
0xFF
0x00
The module or the host has to go through a CRC-8 check when transmitting and
receiving a frame of data. The function source code is as shown in the program list
1.1, and this function can be ported to the source code of the host.
When the module or the host sends a command, the 3Byte data of the frame flag and
frame data will be used as an input parameter of function xCal_crc( ), and the check
value will be calculated and filled into frame checksum to form one frame data.
When the module or host receives a frame of data, it needs to check the received
data to ensure its correctness. The 4Byte data of frame flag, frame data and frame
check will be used as input parameter of function xCal_crc( ), and the check value will
be calculated. If the calculated check value is 0, then the received data is correct; if it
is not 0, then the received data is incorrect.

User Manual
Program List 1.1 CRC-8 Check Function Source Code
The module uses an MCU with ARM Cortex-M0 core and adopts little-endian
scheme by default, so during UART communication, the 8 low bits of the frame data
[15:0] come first leading up to the high 8-bits. For example, if the value of frame
data [15:0] is 5 in decimal, it is represented in the UART data stream as: 0x05, 0x00.
The module can not only send data to the host but also receive and execute
commands from the host. To detect whether the UART communication line
between the module and the host works normally, the host commands the module
to send rainfall status or system status, and if it receives a reply from the module, it
means that the communication works normally, otherwise there is something wrong
with communication line.
Each command sent by the host must be continuous 5Byte data. If the idle time
between any two bytes in the 5Byte data exceeds the transmission time of 10bit
data, it will be judged as inter-byte timeout, and the previously received data will be
invalidated and the receiver will receive data from the first byte of the command
/*******************************************************************************************
** Function name: xCal_crc
** Descriptions: CRC-8 Check. Polynomial: 0x31; Data Reverse: MSB First;Initial Value: 0xFF; XOR Value:
0x00
** input parameters: ptr:pointer to the data to be checked
** len:byte number of the data to be checked
** Returned value: CRC-8 Check Value
*******************************************************************************************/
uint8_t xCal_crc(uint8_t *ptr, uint32_t len)
{
uint8_t crc;
uint8_t i;
crc = 0xFF;
while(len--) {
crc ^= *ptr++;
for(i = 0; i < 8; i++)
{
if (crc & 0x80)
{
crc = (crc << 1) ^ 0x0131;
} else {
crc = (crc << 1);
}
}
}
return crc;
}

User Manual
again.
1.2.2 Firmware Version Query Function
Query the firmware version of the module. For the specific commands see Table 1.6.
Table 1.6 Firmware Version Command Query
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 00 00 00 4B
The host queries the firmware version of the
module.
Host←Slave
3A 80 xx xx xx
The module sends firmware version to the host.
Note: "Host→Slave" means the UART data is "sent by the host and received by the slave"; "Host
←Slave" means the UART data is "sent by the slave and received by the master"; the value of "xx"
is determined by the actual data, below is the same.

User Manual
1.2.3 Rainfall Detection Function
When the module detects the rain and the rainfall status output is enabled, it will feed
back the rain status immediately, and it sends nothing for no rain; when the rainfall
status output is disabled, the rainfall status can only be obtained by sending
commands from host, and the module will send it to the host. The specific commands
are as shown in Table 1.7.
Table 1.7 Commands Related to Rainfall States
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 01 00 00 0D
The host queries the detected rainfall state
from the module
Host←Slave
3A 81 00 00 D8
The module sends rainfall state to the host: no
rain
Host←Slave
3A 81 01 00 2C
The module sends rainfall state to the host:
light rain
Host←Slave
3A 81 02 00 01
The module sends rainfall state to the host:
moderate rain
Host←Slave
3A 81 03 00 F5
The module sends rainfall state to the host:
heavy rain
1.2.4 System State Detection Function
The module will automatically monitor its system status during operation, and if
there is any abnormality in the system, the module will send the error status to the
host. When the host queries the system status by commands, the module will report
the current system status to the host and clear the last system error status.
Table 1.8 Commands Related to System Status
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 02 00 00 C7
The host queries the module system status and
clear system error status
Host←Slave
3A 82 00 00 12
The module sends system status to the host:
normal
Host←Slave
3A 82 01 00 E6
The module sends system status to the host:
normal: SPI communication error
Host←Slave
3A 82 02 00 CB
The module sends system status to the host:
LEDA damaged
Host←Slave
3A 82 03 00 3F
The module sends system status to the host:
LEDB damaged
Host←Slave
3A 82 04 00 91
The module sends system status to the host:
optical system calibration not good

User Manual
Host←Slave
3A 82 05 00 65
The module sends system status to the host:
optical system parameter writing failure
Host←Slave
3A 82 06 00 48
The module sends system status to the host:
received serial data check error
Host←Slave
3A 82 07 00 BC
The module sends system status to the host:
the current voltage is too low
1.2.5 Optical System Calibration Function
Due to the optical path asymmetry of the system caused by processing, installation, etc.,
the module requires optical system calibration before use when installed to ensure the
accuracy of rainfall detection. For detailed commands, refer to Table 1.9.
When the optical calibration is not good, please check whether there is anything wrong
with the installation, after correcting it, clear the system error states first and then re-
perform the optical calibration.
Note: Parameters V, S, N, frequency and calibration will be saved to internal Flash during configuration,
so it is necessary to ensure a stable power supply.

User Manual
Table 1.9 Optical System Calibration Commands
1.2.6 Set Rainfall Status Output Frequency
When it's rainy, the module will output the corresponding rainfall status after it
detects rain status, and the shortest interval of the feedback on the rain status is 50ms
(in the case of N1=N2=N3=2. The interval will vary with the set N value). If the
function is disabled, the module will not automatically output the rain status, instead,
the host needs to read it actively. When the rainfall output frequency is set to be out
of the range of 0~9, the module will return the error of parameter writing failure. For
detailed commands refer to Table 1.10.
Note: Parameters V, S, N, frequency and calibration will be saved to internal Flash during
configuration, so it is necessary to ensure a stable power supply.
Table 1.10 Rainfall Status Output Frequency Commands
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 85 01 00 05
The host sets the rainfall status output
frequency of the module to 1
Host→Slave
3A 85 00 00 F1
The host sets the rainfall status output of the
module to be disabled
Host→Slave
3A 05 00 00 24
The host reads the rainfall status output
frequency from the module
Host←Slave
3A 85 xx xx xx
The module sends the rainfall status output
frequency to the host
Host→Slave
3A 85 0A 00 1F
The host sets the rainfall status output
frequency of the module to 10
Host←Slave
3A 82 05 00 65
The module sends the error of parameter
writing failure to the host
1.2.7 Set Rainfall Detection Sensitivity
The sensitivity of the rainfall detection is adjustable and all adjustable parameters are
as shown in Table 1.11. By changing the parameters, the obtained rainfall status can
be different under the same rainfall conditions. For example, under the same rainfall
conditions, after increasing sensitivity, the module may output a rainfall status of
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 83 00 00 54
The host commands module to perform
optical system calibration
Host→Slave
3A 03 00 00 81
The host reads the optical system calibration
value from the module
Host←Slave
3A 83 xx xx xx
The module sends the optical system
calibration value to the host

User Manual
heavy rain, while by decreasing it, the output may change to light rain .
Note: Parameters V, S, N, frequency and calibration will be saved to internal Flash during
configuration, so it is necessary to ensure a stable power supply.
Table 1.11 Commands Related to Rain Detection Sensitivity Parameter
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 86 xx xx xx
The host sets no-rain/light-rain threshold V1 of
the module
Host→Slave
3A 86 xx xx xx
The host reads no-rain/light-rain threshold V1
from module
Host←Slave
3A 06 00 00 EE
The module sends no-rain/light-rain threshold
V1 to the host
Host→Slave
3A 86 xx xx xx
The host sets light-rain/moderate-rain
threshold V2 of the module
Host→Slave
3A 87 xx xx xx
The host reads light-rain/moderate-rain
threshold V2 from module
Host←Slave
3A 07 00 00 A8
The module sends light-rain/moderate-rain
threshold V2 to the host
Host→Slave
3A 87 xx xx xx
The host sets moderate-rain/heavy-rain
threshold V3 of the module
Host→Slave
3A 88 xx xx xx
The host reads moderate-rain/heavy-rain
threshold V3 from module
Host←Slave
3A 08 00 00 19
The module sends moderate-rain/heavy-rain
threshold V3 to the host
Host→Slave
3A 88 xx xx xx
The host sets no-rain/light-rain threshold S1 of
the module
Host→Slave
3A 89 xx xx xx
The host reads no-rain/light-rain threshold S1
from module
Host←Slave
3A 09 00 00 5F
The module sends no-rain/light-rain threshold
S1 to the host
.

User Manual
续上表
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 8A xx xx xx
The host sets light-rain/moderate-rain
threshold S2 of the module
Host→Slave
3A 0A 00 00 95
The host reads light-rain/moderate-rain
threshold S2 from module
Host←Slave
3A 8A xx xx xx
The module sends light-rain/moderate-rain
threshold S2 to the host
Host→Slave
3A 8B xx xx xx
The host sets moderate-rain/heavy-rain
threshold S3 of the module
Host→Slave
3A 0B 00 00 D3
The host reads moderate-rain/heavy-rain
threshold S3 from module
Host←Slave
3A 8B xx xx xx
The module sends moderate-rain/heavy-rain
threshold S3 to the host
Host→Slave
3A 8C xx xx xx
The host sets the module threshold N1 for
the number of times of heavy rain in 10
measurements
Host→Slave
3A 0C 00 00 30
The host reads from module the threshold
N1 for the number of times of heavy rain in
10 measurements
Host←Slave
3A 8C xx xx xx
The module sends to the host the threshold
N1 for the number of times of heavy rain in
10 measurements
Host→Slave
3A 8D xx xx xx
The host sets the module threshold N2 for
the number of times of moderate rain in 10
measurements
Host→Slave
3A 0D 00 00 76
The host reads from module the threshold
N2 for the number of times of moderate rain
in 10 measurements
Host←Slave
3A 8D xx xx xx
The module sends to the host the threshold
N2 for the number of times of moderate rain
in 10 measurements
Host→Slave
3A 8E xx xx xx
The host sets the module threshold N3 for
the number of times of light rain in 10
measurements
Host→Slave
3A 0E 00 00 BC
The host reads from module the threshold
N3 for the number of times of light rain in 10
measurements
Host←Slave
3A 8E xx xx xx
The module sends to the host the threshold
N3 for the number of times of light rain in 10
measurements
The software algorithm of the module measures rainfall through three parameters: V, S
and N. Each parameter corresponds to thresholds for three rainfall states. Change the

User Manual
threshold to adjust the rainfall detection sensitivity.
Parameter V: the active degree of the dynamic raindrop flowing on the glass surface, the
faster the raindrop flow, the larger the parameter V.
Parameter S: the "unevenness" of the static raindrop distributed on the glass surface, the
higher the unevenness degree, the larger the parameter S.
Parameter N: The module will obtain the real-time rainfall status first according to the
parameter V and S, and then determine the rainfall status as light rain, moderate rain, or
heavy rain in 10 measurements, and finally output the rainfall status with most times
through UART.
The thresholds for light, medium and heavy rain under different scenarios can be set as
per actual requirements. For example, if you use a watering can to simulate rain
detection, it is recommended to use initial parameter values of: V1=30, V2=1000,
V3=2000; S1=100, S2=800, S3=1200; N1=2, N2=2, N3=2. When adjusting the
parameters, it is required that V, S, and N conform to the following logical relationships.
●V1<V2<V3;
●S1<S2<S3;
●N3>=N1;
●N3>=N2
If you want to improve the sensitivity, reduce these parameters appropriately; if you
want to reduce it, increase parameters appropriately. It is recommended to simulate
raining conditions while debugging.
1.2.8 Real-time Rainfall Mode
The module supports the output of raw rainfall values and the related commands and
operations are as shown in Table 1.12. At this time rainfall status cannot be sent.

User Manual
Table 1.12 Real-time Rainfall Mode Commands
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 84 01 00 43
The host commands the module to enter real-
time rainfall mode
Host→Slave
3A 84 00 00 B7
The host commands the module to exit real-
time rainfall mode
Host←Slave
3A 84 xx xx xx
The module sends raw rainfall values to the
host
1.3
Ambient Light Detection Function
The module supports ambient light (white light) detection, which can be used with
rainfall detection function. The operation commands are as shown in Table 1.13.
Control the module to enter ambient light detection function, when the function is
enabled, the ambient light value will be output at a fixed frequency. The ambient
light feedback value range(decimal) is 0 ~ 1024. And the higher the light intensity,
the lower the feedback value, or vice versa. Currently, there is no correlation curve
for light intensity-vs.-feedback value.
Table 1.13 Ambient Light Mode Commands
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 8F 01 00 DB
The host commands the module to enter
ambient light detection mode
Host→Slave
3A 8F 00 00 2F
The host commands the module to exit
ambient light detection mode
Host←Slave
3A 83 xx xx xx
The module sends ambient light value to the
host
1.4
Temperature Detection Function
The module supports ambient temperature detection function, which is
implemented by the integrated on-chip temperature sensor. As shown in Figure 1.2,
the measured ambient temperatures range from -40°C to 85°C with a stepping of 5°
C and they have good linearity. In the calculation formula, y represents the
temperature value from RS200 feedback(it's hexadecimal in RS200 feedback, and
decimal in the calculation formula); x represents the ambient temperature. The
commands and descriptions are as shown in Table 1.14.

User Manual
Figure 1.2 Temperature Detection Linearity Analysis
Table 1.14 Temperature Detection Commands
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 10 00 00 EF
The host reads chip temperature from the
module
Host←Slave
3A 90 xx xx xx
The module sends chip temperature to the host
1.5
Sleep Function
The module supports low-power sleep mode. When the module enters the low-
power mode, it will disable all rain detection functions and will only respond to
specific wake-up frame. The relevant commands and descriptions are as shown in
Table 1.15.
Table 1.15 Sleep Function Commands
Command
Direction
Command Content (HEX)
Command Description
Host→Slave
3A 91 00 00 7C
The host commands module to enter sleep
mode
Host→Slave
3A 91 01 00 88
The host commands module to exit sleep
mode
Host←Slave
3A 12 00 00 63
3A 80 00 02 FC
The module sends Boot command and
firmware version command to host

User Manual
2. Operation Description
2.1
Interface Description
The module uses a 0.8mm wire-to-board socket to lead out the power supply and
communication pins for easy use, as shown in Figure 2.1. The communication pins
are 2-wire serial ports that can communicate with the host directly and send rainfall
status data, and the pin definition is shown in Table 2.1.
Figure 2.1 Wire-to-Board Socket
Table 2.1 Pin Definition
NO.
Signal Name
Function
Remarks
1
VCC
3.3V Power Supply
-
2
UART_TX
UART Receiving
Connect to the pin TX of the host
UART
3
UART_RX
UART Transmitting
Connect to the pin RX of the host
UART
4
GND
Ground
-
2.2
Use Guide
2.2.1 Installation
The mechanical dimensions of the RS200 are shown in Figure 2.2. There is a ring with
a width of 0.5 mm (no components inside the ring) on the outermost circle of the
PCB to help the host mechanic structure fix the RS200 module.

User Manual
Figure 2.2 Dimensions on the Front Side
First, fix the module on the host mechanic structure with the front side (the side with
the IR emitter) facing the glass; then, place the flexible transparent optical material on
the front side of the module; finally, put the glass lid on and the installation is done.

There are two requirements during installation:
1. The flexible transparent optical material needs to wrap tight the "IR emitter",
"photoelectric receiver", and be pressed against the "inner surface of the glass". Give
appropriate pressure to eliminate air to avoid air bubbles.
2. The typical distance from the module "PCB surface" to the "glass outer surface" is
4.0mm (adjustable), and the thickness of the glass and the flexible transparent optical
material can be adjusted appropriately. For example, if the glass thickness is 1.5 mm,
the thickness of the filled flexible transparent optical material should be 2.5 mm; if the
glass thickness is 2.0 mm, the thickness of the filled flexible transparent optical material
should be 2.0 mm. The distance is limited by the host structure because the flexible
transparent optical material is highly susceptible to deformation.
Figure 2.3 Side View of Module Installation Layers
Figure 2.4 Final Installation Effect
2.2.2 Wire Connection
Connect the module to the camera host controller through the dedicated wire, power the
module with 3.3V power supply, and connect UART.

2.2.3 Perform Optical Calibration
After the first installation, it is required to perform optical system calibration for the
module to ensure the accuracy of rain detection. Calibration steps:
1. Ensure the external surface of the glass is clean, dry and free from foreign matters, and
it is recommended to calibrate in a dark room to keep the calibration free from
interference of light.
2. According to the commands listed in Table 1.9, the host sends to the module an
automatic calibration command: "3A 83 00 00 54". After the module receives it, it will
automatically perform optical system calibration and send the calibration result to the
host. The result will be written into Flash so there is no need to calibrate again after
power on. If the host receives the command "3A 82 04 00 91" for unsatisfactory optical
system calibration, it means that the optical path asymmetry of the optical system is
beyond the adjustable range due to the mechanical structure and installation accuracy,
which reduces the module’s ability to resist sunlight interference, thus leading to
misjudgment.
During use, if the optical system changes, perform the optical system calibration again as
per needs.
2.2.4 Initialize Module to Read Rainfall Status & Control Wiper
After the first calibration, the module can be used without initialization if there is no
special requirements. The host can control the wiper according to the rainfall status
automatically reported by the module. If you have special needs, you can adjust the
rainfall status output frequency according to Table 1.10, adjust the rain detection
sensitivity according to Table 1.11, etc. The adjustable parameters such as calibration
value, V, S, N and frequency are saved when powered off, so there is no need to
reconfigure them every time you power on.
Table of contents