Table of Contents:

1. Introduction

This article provide the examples for RS485-LN to connect to different type of RS485 sensors.

1.1 Example 1: Connect to Leak relay and VFD

This instruction is provided by Xavier Florensa Berenguer from NORIA GRUPO DE COMPRAS. It is to show how to use RS485-LN to connect to Relay and VFD and communicate with Mobile. The structure is like below:

image-20220527091852-1.png

Connection

image-20220527091942-2.png 

Connection

Related documents:

  • Explanation on how to integrate to Node-red and to the Mobile Phone, and with link to the Github code:  Configure Manual 

1.2 Example 2: Connect to Pulse Counter

This instruction is provided by Xavier Florensa Berenguer from NORIA GRUPO DE COMPRAS. It is to show how to use RS485-LN to connect to Pulse Counter and communicate with Mobile. This example and example 2 compose the structure for a farm IoT solution. The structure is like below:

image-20220527092058-3.png

Connection

image-20220527092146-4.png

Connection

Related documents:

1.3 Example 3: Use RS485-LN with energy meters

1.3.1 OverView

NoteThe specifications of each energy meter are different, please refer to your own energy meter specifications.

This example describes a single-phase meter.This is the connection between the RS485-LN and the energy meter.

image-20220527092419-5.png

Connection1

How to connect with Energy Meter:

 

Follow the instructions of the electric energy meter to connect the phase line and the neutral line, and then connect 485A+ and 485B- to RS485A and RA485B of RS485-LN respectively.

The RS485-LN can be powered by 7 ~ 24V DC power source. Connection as below

Power Source VIN to RS485-LN VIN+

Power Source GND to RS485-LN VIN-

Once there is power, the RS485-LN will be on.

image-20220527092514-6.png

Connection2

image-20220527092555-7.png

Connection3

1.3.2 How to use the parameters of the energy meter and MODBUS commands

If the user needs to read the parameters of the electric energy meter and use the modbus command,please refer to the appendix of the MODBUS communication protocol in the user manual of the energy meter.

image-20220601143257-10.png

Example:  AT+COMMAND1=01 03 00 00 00 01 84 0A

  • The first byte : slave address code (=001~247)
  • The second byte : read register value function code
  • 3rd and 4th bytes: start address of register to be read
  • 5th and 6th bytes: Number of registers to read
  • 7th and 8th bytes: CRC16 checksum from bytes 1 to 6.

 

How to parse the reading of the return command of the parameter:

Example: RETURN1:01 03 02 08 FD 7E 05

  • The first byte ARD: slave address code (=001~254)
  • The second byte: Return to read function code
  • 3rd byte: total number of bytes
  • 4th~5th bytes: register data
  • The 6th and 7th bytes: CRC16 checksum
  • 08 FD is register data. Use short integer 16 bits to convert to decimal, get 2301, then 230.1V is the voltage.

1.3.3 How to configure RS485-LN and parse output commands

RS485-LN provides two configuration methods: AT COMMAND and DOWNLINK.

1.3.3.1 via AT COMMAND

First, we can use AT+CFGDEV to get the return value, and we can also judge whether the input parameters are correct.

If the configured parameters and commands are incorrect, the return value is not obtained.

 

image-20220601143201-9.png

AT COMMAND

   AT+DATACUTx :  This command defines how to handle the return from AT+COMMANDx, max reture length is 40 bytes. AT+DATACUTx=a,b,c

a:  length for the return of AT+COMMAND

b: 1: grab valid value by byte, max 6 bytes;  2: grab valid value by bytes section, max 3 sections.

c:  define the position for valid value.

image-20220601143115-8.png

AT COMMAND

PAYLOAD is available after the valid value is intercepted.

image-20220601143046-7.png

AT COMMAND

You can get configured PAYLOAD on TTN.

image-20220601143519-1.png

AT COMMAND

 

Example:

CMD1: Read current data with MODBUS command. address: 0x03 AT+COMMAND1= 01 03 00 03 00 01,1

RETURN1: 01 03 02 00 02 39 85 00 00(return data)

AT+DATACUT1: 9,1,4+5+6+7 Take the return value 00 02 39 85 as the valid value of reading current data and used to splice payload.

 

CMD2: Read voltage data with MODBUS command. address: 0x00 AT+COMMAND2= 01 03 00 00 00 01,1

RETURN2: 01 03 02 08 DC BE 1D(return data)

AT+DATACUT2: 7,1,4+5 Take the return value 08 DC as the valid value of reading voltage data and used to splice payload.

 

CMD3: Read total active energy data with MODBUS command. address: 0x0031 AT+COMMAND3= 01 03 00 31 00 02,1

RETURN3: 01 03 04 00 00 00 44 FA 00(return data)

AT+DATACUT3: 9,1,4+5+6+7 Take the return value 00 00 00 44 as the valid value of reading total active energy data and used to splice payload.

Payload: 01 00 02 39 85 08 DC 00 00 00 44

image-20220601142936-6.png

AT COMMAND

01 is device address,00 02 is the current, 08 DC is the voltage,00 00 00 44 is the total active energy.

image-20220601143642-2.png

AT COMMAND

image-20220527093358-15.png

DOWNLINK

Type Code 0xAF

0xAF downlink command can be used to set AT+COMMANDx or AT+DATACUTx.

Note: if user use AT+COMMANDx to add a new command, he also need to send AT+DATACUTx downlink.

Format: AF MM NN LL XX XX XX XX YY

Where:

MM: the ATCOMMAND or AT+DATACUT to be set. Value from 01 ~ 0F,

NN: 0: no CRC; 1: add CRC-16/MODBUS ; 2: set the AT+DATACUT value.

LL: The length of AT+COMMAND or AT+DATACUT command

XX XX XX XX: AT+COMMAND or AT+DATACUT command

YY: If YY=0, RS485-LN will execute the downlink command without uplink; if YY=1, RS485-LN

will execute an uplink after got this command.

Example:

AF 03 01 06 0A 05 00 04 00 01 00: Same as AT+COMMAND3=0A 05 00 04 00 01,1

image-20220601144149-6.png

DOWNLINK

image-20220601143803-3.png

DOWNLINK

image-20220601144053-5.png

DOWNLINK

image-20220601143921-4.png

DOWNLINK

image-20220601142805-5.png

DOWNLINK

1.3.4 How to configure and output commands for RS485 to USB

This step is not necessary, it is just to show how to use a normal RS485 to USB adapter to connect to the meter to check the input and output. This can be used to test the connection and RS485 command of the meter without RS485-LN.

First, connect the A+ and A- of the USB to the 485 A and 485 B of the energy meter.

Open the serial port debugging, set the send and receive to HEX.

Baud rate: 9600

check digit: Even

image-20220527093708-21.png

USB

image-20220527093747-22.png

USB

The configuration command is consistent with the AT command, input the hexadecimal command directly into the serial port, and the serial port will output the command.

Example:  input:01 03 00 31 00 02 95 c4

                 output:01 03 04 00 00 00 42 7A 02 

 

image-20220527093821-23.png

USB

1.3.5 How to configure multiple devices and modify device addresses

If users need to read the parameters of multiple energy meters, they need to modify the device address, because the default device address of each energy meter is 01.

Set the device address according to the parameters in the appendix of the MODBUS communication protocol.

image-20220601142044-1.png

Example: These two meters are examples of setting parameters and device addresses.

image-20220527093950-25.png

image-20220527094028-26.png

First of all, since the default device address of the energy meter is 01, the configuration of two energy meters will conflict, so we first connect an energy meter and configure the device address.

We can use AT+CFGDEV to set the device address.

We modify the device address 01 of the first energy meter to 02.

image-20220601142354-2.png

AT+CFGDEV:01 10 00 61 00 01 02 00 02,1

  • 01: device adaress
  • 10: function code
  • 00 61:Register address
  • 00 01:Number of Registers
  • 02:Number of bytes
  • 00 02:Modified device address
  • 1:Check code

The device address setting of the energy meter is complete.

Another energy meter is a single active energy meter with a floating-point format.

Its default device address is 01, and the following are the parameters for configuring two energy meters.

image-20220601142452-3.png

image-20220601142607-4.png

PAYLOAD: 01 08 DF 43 62

  • 08 DF is the valid value of the meter with device address 02.
  • 43 62 is the valid value of the meter with device address 01.

  

1.4 Example 4: Circuit Breaker Remote Open Close

This instruction is provided by Xavier Florensa Berenguer from NORIA GRUPO DE COMPRAS. It is to show how to use RS485-LN to connect to SCHNEIDER SMART and Monitor and control your cabinet remotely with no wires and with Dragino RS485-LN LoRaWAN technology.

The structure is like below:

image-20220527094330-30.png

Connection

1.5 Example 5: SEM Three Energy Meter with RS485-BL or RS485-LN

This instruction is provided by Xavier Florensa Berenguer from NORIA GRUPO DE COMPRAS. It is to show how to use RS485-BL to connect to SEM Three Energy Meter and send the data to mobile phone for remote minitor. The structure is like below:

1.6 Example 6: CEM C31 485-T1-MID Energy Meter with RS485-LN

This instruction is provided by Xavier Florensa Berenguer from NORIA GRUPO DE COMPRAS. It is to show how to use RS485-LN to connect to CEM C31 485-T1-MID and send the data for remote minitor. The structure is like below:

1.7 Example 7: Schneider Electric PLC M221 with RS485-BL

image-20220527094556-31.png

Network Structure

1.8 Example 8: This sketch is supposed to test Dragino RS485-BL (Modbus master), using an Arduino UNO as a Modbus slave.

This sketch uses 4 registers: some of them can be set by Dragino with a command, another is used to store value from a DS18B20 temperature sensor, or a random generated number. All data is 16bit uint, but the sketch shows also how to represent booleans and negative numbers.

In the next days I will be adding more documentation, but I think it already explains users how to build their own modbus sensor to pair with Dragino RS485-BL.

This is released the code under GNU LGPL licence on Github:

https://github.com/zorbaproject/ArduinoModbusForDraginoRS485

1.9 Example 9: RS485-LN and ultrasonic flow meter transmission data

It shows how to use RS485-LN to connect to an ultrasonic flow meter and read the data from the ultrasonic flow meter.

Need to prepare RS485-LN, recharger, Electric wire

1720669739434-926.png 1720669744315-613.png

1.9.1 Setting Ultrasonic Flowmeter

Adjust the M option corresponding to the ultrasonic flowmeter as follows

M52 sets RS485 Port      M62 sets 9600, none, 1     M63 sets automatic

1720669933691-331.png1720669981767-254.png1720670003601-544.png

1.9.2 Setting Dragino RS485-LN

The RS485-LN wiring port is as shown below. Connect the power supply and RS485 A/B line according to the diagram.

1720670016539-422.png1720670019136-658.png

1.9.3 Connect the RS485-LN to Ultrasonic Flowmeter

According to the instructions of the ultrasonic flow meter, 26 and 27 are the + and - of RS485, corresponding to the A and B ports of RS485.

1720670035661-234.png1720670041974-372.png

1.9.4 Full wiring example

The yellow wire connects port 26 and port A of RS485-LN.

The green wire connects port 27 and port B of RS485-LN.

1720670079781-764.png

1.9.5 How to read ultrasonic flow meter data via RS485

1720670090204-634.png

For example, I want to read Positive

Through M02, we can see that the POS data is 54.9862

1720670103571-173.png1720670108127-723.png

Registers are 9-12, so the read command is AT+CFGDEV=01 03 00 08 00 04,1(,1 is used for automatic complement)

1720670123955-149.png

00 36 00 00 is the integer of the read value

78 79 3f 7c is a decimal, but it needs to be converted and parsed into floating point. The parsing order is CDAB, which is 3f 7c 78 79

Conversion and parsing website:http://www.speedfly.cn/tools/hexconvert/

1720670134750-980.png

 

Tags:
Created by Xiaoling on 2022/05/12 09:38
    
Copyright ©2010-2024 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0