Reference

This article offers a comprehensive reference on brightness data and communication protocols, focusing on the Modbus-RTU protocol used in sensor operations, highlighting key parameters, data frame formats, and register functions.

Brightness data reference:

At night: 0.001-0.02 lx;

Moonlit night: 0.02-0.3 lx;

Cloudy indoor: 5-50 lx;

Cloudy outdoor: 50-500 lx;

Sunny indoor: 100-1000 lx;

Summer noon light: about 10^6 lx;

Illumination when reading books: 50-60 lx;

Standard illumination for home video: 1400 lx;

Communication Protocol Description

1. Basic communication parameters

Interface Encoding Data bits Parity bits Stop bits Error checking Baud rate
RS485 8-bit binary 8 None 1 CRC 1200、2400、4800、9600、19200、38400、57600 bit/s configurable, default 9600bit/s

2. Data frame format definition

Using Modbus-RTU communication protocol, the format is as follows:

Initial structure ≥4 bytes of time

Address code = 1 byte

Function code = 1 byte

Data area = N bytes

Error check = 16-bit CRC code

End structure ≥4 bytes of time

Address code: The address of the sensor, which is unique in the communication network (factory default 0x01).

Function code: The function indication of the command sent by the host. This sensor reads the register function code 0x03 and writes the register function code 0x06

Data area: The data area is the specific communication data. Note that the high byte of 16-bit data is in front!

CRC code: A two-byte check code.

Register address

Register address Content Operation Range and definition
0002H High 16-bit data of illumination value Read-only Two bytes
0003H Low 16-bit data of illumination value Read-only Two bytes
0046H Illumination acquisition rate Read-write Level 1-20
0047H Illumination calibration enable bit Read-write 01 Enable illumination calibration function, 00 Disable illumination calibration function
0048H Illumination calibration compensation value Read-write This value is written with the actual value enlarged by 100 times; for example, if compensation of 1.4 is required, the written value needs to be enlarged by 100 times, that is, 140; Calculation method: (collected illumination value ÷ ambient illumination value) × 100 = compensation value For example: the collected illumination value is 221, the actual ambient illumination is 260, and the calculated compensation value = (221 ÷ 260) × 100 = 85
0064H 16-bit device address Read and write Range is (1-254), 255 is the general control command address
0065H 16-bit baud rate selection Read and write 0-1200, 1-2400, 2-4800, 3-9600, 4-19200, 5-38400, 6-57600
0066H Parity bit Read and write 00 no parity, 01 odd parity, 02 even parity
0067H Version information Read only Level 1-20
00E0H Device soft reset write command Write only Level 1-20
00F0H Device factory reset write command Write only Level 1-20

3. Communication protocol example and explanation

3.1、Read multiple register illumination data instruction

Inquiry frame:

Address code Function code Register start address Register length Check code low bit Check code high bit
0x01 0x03 0x00 0x02 0x00 0x02 0x65 0xCB

Response frame:

Address code Function code Return valid bytes Illumination data high 16 bits Illumination data low 16 bits Check code low bit Check code high bit
0x01 0x03 0x04 0x00 0x0C 0xF4 0x73 0x3D 0x15

Light value:

00 0C F4 73 (hexadecimal) =849011/1000 =>Light value = 849.011Lux

3.2, Modify the current address

Inquiry frame: (Modify the current address to 0x02)

Address code Function code Register address Modify value Check code low bit Check code high bit
0x01 0x06 0x00 0x64 0x00 0x02 0x49 0xD4

Response frame:

Address code Function code Register address Modify value Checksum low bit Checksum high bit
0x01 0x06 0x00 0x64 0x00 0x02 0x49 0xD4

3.3, Modify address, baud rate

Inquiry frame: (Modify address to 0x01, baud rate to 9600)

After modifying the address or baud rate, the sensor needs to be powered off and reconnected

Address code Function code Register start address Register length Modify address Modify baud rate Parity check Checksum low bit Checksum high bit
0x01 0x10 0x00 0x64 0x00 0x03 0x00 0x01 0x00 0x03 0x00 0x00 0xA9 0x03

Response frame:

Address code Function code Register start address Register length Modify address Modify baud rate Checksum low bit Checksum high bit
0x01 0x10 0x00 0x64 0x00 0x03 0x00 0x01 0x00 0x03 0x9C 0x05

3.4, query current address, baud rate

Inquiry frame:

Address code Function code Register start address Data length Check code low bit Check code high bit
0xFF 0x03 0x00 0x64 0x00 0x02 0x90 0x0A

Response frame:

Address code Function code Return valid bytes Device address Baud rate Check code low bit Check code high bit
0x01 0x03 0x04 0x00 0x01 0x00 0x03 0xEB 0xF2

The real address of the device read is 01, and the baud rate is 0x03, which is 9600.

3.5, Device factory reset command

Inquiry frame:

Address code Function code Register address Modify data Check code low Check code high
0xFF 0x06 0x00 0xF0 0x00 0x00 0x9C 0x27

Response frame:

Address code Function code Register address Modify data Check code low Check code high
0xFF 0x06 0x00 0xF0 0x00 0x00 0x9C 0x27

Was this article helpful?

TOP