[go: up one dir, main page]

0% found this document useful (0 votes)
298 views90 pages

IOT Relay User Manual

The document provides a user manual for an IOT relay device. It describes the product overview, technical specifications, interfaces, web pages for Ethernet and WiFi connectivity, an IP finder tool, and appendices on how to test commands, use with Domoticz, and integrate with MQTT and CoAP protocols.

Uploaded by

Francisco Ferray
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
298 views90 pages

IOT Relay User Manual

The document provides a user manual for an IOT relay device. It describes the product overview, technical specifications, interfaces, web pages for Ethernet and WiFi connectivity, an IP finder tool, and appendices on how to test commands, use with Domoticz, and integrate with MQTT and CoAP protocols.

Uploaded by

Francisco Ferray
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 90

IOT Relay User Manual

V1.9.8.1
1 Product Overview.............................................................................................................................4
1.1 Overview...............................................................................................................................4
1.2 Technical Parameters.............................................................................................................5
2 Image and Size.................................................................................................................................6
2.1 Hardware version <3.x.x......................................................................................................6
2.2 Hardware version >=V3.x.x.................................................................................................7
2.3 Case......................................................................................................................................8
3 Interface Description........................................................................................................................9
3.1 Power Supply........................................................................................................................9
3.2 Funcation.............................................................................................................................10
3.3 Relay Contact......................................................................................................................11
3.4 Reset To Factory..................................................................................................................12
3.4.1 Hardware Version <V3.x.x.....................................................................................12
3.4.2 Hardware Version >=V3.x.x...................................................................................13
3.5 Input Output and Power wiring diagram............................................................................14
3.6 Add Spark killer and contractor..........................................................................................15
4 Ethernet Web Page.........................................................................................................................16
4.1 Login...................................................................................................................................17
4.2 Setting Network..................................................................................................................17
4.3 Relay Connect.....................................................................................................................18
4.4 Relay CGI Test....................................................................................................................21
4.5 Relay Task...........................................................................................................................21
4.6 Input.....................................................................................................................................22
4.7 Input Link Relay.................................................................................................................23
4.8 IP WatchDog........................................................................................................................23
4.9 Reset User...........................................................................................................................24
4.10 To Factory..........................................................................................................................24
4.11 Reboot................................................................................................................................25
5 WIFI web Page...............................................................................................................................26
5.1 Login...................................................................................................................................26
5.2 Setting WIFI........................................................................................................................26
5.3 Setting Relay Connect.........................................................................................................27
5.4 Relay CGI Test....................................................................................................................30
5.5 Relay Task...........................................................................................................................31
5.6 Input.....................................................................................................................................31
5.7 Input Link Relay.................................................................................................................32
5.8 IP WatchDog........................................................................................................................32
5.9 Reset User...........................................................................................................................33
5.10 To Factory..........................................................................................................................33
6 IP Finder.........................................................................................................................................34
6.1 Search Device......................................................................................................................35
6.2 Change Static IP..................................................................................................................36
Appendix I How to Test Command..................................................................................................37
step 1: download SDK..............................................................................................................37
step 2: Change NetAssist language...........................................................................................38
step 3: Control relay via NetAssist network tool by wifi module............................................39
step 4: open UDP listen.............................................................................................................41
step 5: control relay via wifi module........................................................................................42
Appendix II How to use Domoticz...................................................................................................43
step 1: install Dingtian plugin to Domoticz..............................................................................43
1 Stop Domoticz................................................................................................................43
2 Copy Domoticz_plugins\dingtian to Domoticz plugin dir............................................43
step 2: config Dingtian Relay board.........................................................................................44
Domoticz Ethernet............................................................................................................44
Domoticz WIFI.................................................................................................................45
step 3: Add Dingtian Relay to Domoticz..................................................................................46
1 Install Python 3.8.2........................................................................................................46
2 Run to Domoticz............................................................................................................46
3 Add Dingtian Relay to Domoticz...................................................................................47
4 Control Dingtian Relay with Domoticz.........................................................................52
step 4: Domoticz mobile application........................................................................................54
1 Set the Location, User name and password on PC Domoticz.......................................54
2 Install Domoticz.............................................................................................................54
3 Set Domoticz Server parameter.....................................................................................55
Appendix III How to MQTT.............................................................................................................56
step 1: Install and config Broker...............................................................................................61
step 2: Install MQTT PC client.................................................................................................61
step 3: MQTTBox Add Client...................................................................................................61
step 4: MQTTBox Publish topic to relay board and subcribe topic.........................................63
Appendix IV How to CoAP..............................................................................................................64
step 1: compile libcoap..............................................................................................................64
step 2: CoAP Get relay status....................................................................................................64
step 3: CoAP Control relay(simple)..........................................................................................64
step 4: CoAP Control relay.......................................................................................................65
Appendix V How to “input mutual control”.....................................................................................67
Appendix VI How to Home Assistant...............................................................................................69
Step 1 config Relay board........................................................................................................69
Step 2 Install MQTT Broker....................................................................................................70
Step 3 Install Home Assistant..................................................................................................70
1 install python.................................................................................................................70
2 install Home Assistant...................................................................................................70
3 Add relay board Switch and input to Home Assistant..................................................70
4 Home Assistant config MQTT Broker..........................................................................72
Appendix VII How to openHAB......................................................................................................76
Step 1 config Relay board........................................................................................................76
Step 2 Install MQTT Broker....................................................................................................77
Step 3 install JDK and openHAB............................................................................................77
1 Download......................................................................................................................77
2 install.............................................................................................................................78
3 Add jdk directory to “start.bat”.....................................................................................79
4 First time init openHAB................................................................................................80
Step 4 Add Dingtian Relay board to openHAB.......................................................................83
1 Change json MQTT broker host, username,password..................................................83
2 Change json SN(example SN 7920) to you relay board SN........................................83
3 Cover openHAB json....................................................................................................87
4 Control relay board with openHAB..............................................................................87
1 Product Overview
1.1 Overview
Support Ethernet, WiFi, RS485, CAN
10/100Mbps ethernet, Auto-MDIX,DHCP ip,Static IP
WiFi 802.11 b/g/n, MAX 150Mbps
Digital input, can be Local Button control(SelfLock/Jogging/Delay)
Support RELAY On/OFF/Jogging/Delay.
Support HTTP GET CGI, UDP, TCP Server, TCP Client
Support Modbus-RTU/ASCII/TCP/UDP/WIFI
Support Modbus-RTU Over TCP/UDP/WIFI
Support Modbus-ASCII Over TCP/UDP/WIFI
Support WEB control
Support MQTT, CoAP
Support NTP, IP Watchdog, Task timer
Support Domoticz, Home Assistant, openHAB

Home Automation System Support:


Name How to
Domoticz Appendix II How to use Domoticz
https://github.com/dtlzp/Domoticz-Dingtian-Relay-Plugin
Software version <=V2.16.xx, please use V1.1 for github
software version >=V2.17.xx, please use V1.2 for github
Home Assistant Appendix VI How to Home Assistant
openHAB Appendix VII How to openHAB
Notice:
1 Close your firewall
2 All command and script run as root/administrator

SDK download link:


http://www.dingtian-tech.com/sdk/relay_sdk.zip
1.2 Technical Parameters
Interface RJ45/ RS485/CAN/WIFI
Baudrate 100M/115200bps/125kbps/150Mbps
Protocol TCP server/client,
UDP
HTTP GET CGI,
Modbus-RTU/ASCII/TCP/UDP/WIFI
Modbus-RTU Over TCP/UDP/WIFI
Modbus-ASCII Over TCP/UDP/WIFI
Function
MQTT
CoAP
Home Automation System Domoticz
Home Assistant
openHAB
Others NTP
IP Watchdog
Task timer
Relay Power AC 250V/10A,DC 30V/10A
Contacts Normally Close(NC)
Normally Open(NO)
Output
Delay 1~65535 seconds
Momentary Pull in 0.5 seconds,
automatically release
Temperature and Storage temperature -40°C to +70°C
Humidity Operating temperature -20°C to +70°C
Relative humidity 25°C @ ≤95%, no condensation
(during operation)
Power Specifications 12/24VDC(recommend)
12/24VAC
Current 2 channel: 0.15A/12V(recommend 1A/12V)
4 channel: 0.25A/12V(recommend 1A/12V)
Power
8 channel: 0.5A/12V(recommend 2A/12V)
Power consumption 2 channel: 2W
4 channel: 3W
8 channel: 5W
2 Image and Size
2.1 Hardware version <3.x.x
Hole size: 3.5mm
2.2 Hardware version >=V3.x.x
Hole size: 3.5mm
2.3 Case
The 2CH,4CH,8CH Case is ABS material, Standard DIN35 rail installation
3 Interface Description
3.1 Power Supply
3.2 Funcation
3.3 Relay Contact
Connect Example:

Normal Close Example

Normal Open Example


3.4 Reset To Factory
3.4.1 Hardware Version <V3.x.x
1. Short-circuit the 2 pin headers under the Default assembly with a jumper cap

2 Power off the relay board


3 Power on the relay board
4 Pull out the Default jumper cap
3.4.2 Hardware Version >=V3.x.x

1 power on relay board,wait 10 second


2 press “FACTORY” button(left light will ON)
3 wait 5 second(right light will ON)
4 release “FACTORY” button
5 relay board will reset all parameter to factory.
3.5 Input Output and Power wiring diagram
LOW HIGH
Hardware Version < V1.8 0V 3.3V
Hardware Version >= V1.8 0V 3.3V~24V
3.6 Add Spark killer and contractor
R1,C1 are used for relay on/off interference suppression, protection control circuit
R2,C2 are used to suppress the Load spark and noise when relay ON/OFF
Most of time the Load comes with the best R2+C2,so we don't need care R2 and C2

Our max current is 10A, if the current of your device is too big, suggest add a contractor
4 Ethernet Web Page
IE is not support, please use firefox and chrome
4.1 Login
Default IP: 192.168.1.100
user: admin
password: admin

4.2 Setting Network


Set network information, NTP Server on Relay setting page
after click “Save” button, device well reboot

Parameter:
Software Version: Relay board firmware version
Model:
2CH is Dingtian IOT RELAY-2
4CH is Dingtian IOT RELAY-4
8CH is Dingtian IOT RELAY-8
Serial Number: Relay board Serial Number
Date Time: current date and time(Need internet because of NTP)
NTP Server: NTP server get time from, suggest use pool.ntp.org
DHCP: Ethernet IP DHCP or Static
IP: Ethernet current IP Address
Netmask: Ethernet current Netmask
Gateway: Ethernet current Gateway
DNS: Ethernet current DNS Server
MAC: Ethernet current MAC address

4.3 Relay Connect


Set control interface parameter of relay board on the Relay connect page and test relay
After click “Save” button, device will reboot
Protocol refers to programming manual_en.pdf

Channel Parameter:
RS485: RS485 protocol, addr, baudrate, databits, stopbits, parity config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU
Modbus-ASCII
Baudrate:
1200bps,2400bps,4800bps,9600bps,19200bps,38400bps,57600bps,115200bps
CAN: CAN protocol, ID, Speed config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU(0x03,0x06),only support Read/Write single register once time
Speed:
5Kbps,10Kbps,20Kbps,25Kbps,50Kbps,100Kbps,125Kbps,200Kbps,250Kbps,500Kbps,800Kbps,888
Kbps,1Mbps
ETH-UDP1: Ethernet UDP1 protocol, Remote Server Address,Remote Server Port,Local Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over UDP
Modbus-ASCII Over UDP
Modbus-UDP
CoAP(need change port to 5683)
Input Mutual Control
ETH-UDP2: Ethernet UDP2 protocol, Remote Server Address,Remote Server Port,Local Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over UDP(use RS485 addr)
Modbus-ASCII Over UDP(use RS485 addr)
Modbus-UDP
CoAP(we suggest enable CoAP at ETH/WiFi-UDP2)
Input Mutual Control
ETH-TCP Server: Ethernet TCP Server protocol, Local Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over TCP(use RS485 addr)
Modbus-ASCII Over TCP(use RS485 addr)
Modbus-TCP
ETH-TCP Client: Ethernet TCP Client protocol, Remote Server Address,Remote Server Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over TCP(use RS485 addr)
Modbus-ASCII Over TCP(use RS485 addr)
Modbus-TCP
ETH-MQTT: Ethernet MQTT protocol, Broker Address, Broker Port, Broker Username, Broker
Password config
Protocol:
MQTT(without tls)

Other Parameter:
Relay Password: use for checking control is valid, only correct password control relay board
Keep Alive Second: send relay status to server with every “Keep Alive Second”, only protocol
Dingtian String and Dingtian binary have Keep Alive Second
Jogging Time: Jogging time, default is 500ms,1=100ms
what is Jogging: ON then delay 500ms OFF,or OFF then delay 500ms ON,
Power Failure Recovery Relay: relay status will restore after re-power
Input Control Relay: Input link relay output

Button Type Parameter:


Selflock: Connect Selflock Button,
press button relay ON,release button relay OFF
Jogging: Connect Momentary Button,
press and release button relay Jogging(ON and delay 500ms OFF)
Momentary: Connect Momentary Button,
press and release button relay ON,press and release button relay OFF
How to Connect button please move to 3.5
4.4 Relay CGI Test
relay CGI test

4.5 Relay Task


Choose “Repeat”, you can ask repeat by second/minute/hour/day/week/month
4.6 Input
4.7 Input Link Relay
Select R1~R8, means you add the relay to link with Input, Click the green button R1~R8 means
delete relay

4.8 IP WatchDog
When Enable IP WatchDog function, all relay ON, when the “Watch IP” offline, relay OFF, after
seconds, the relay ON automatically, “Ping Interval” must be bigger than “Ping Timeout”
4.9 Reset User

4.10 To Factory
4.11 Reboot
5 WIFI web Page
IE is not support, please use firefox and chrome

5.1 Login
Default IP: 192.168.7.1
user:admin
password:admin

5.2 Setting WIFI


Set WIFI information, NTP Server and STA WIFI SSID and password on WIFI Relay setting page
After click “Save” button, device will reboot
Parameter:
Software Version: Relay board firmware version
Model:
2CH is Dingtian IOT WRELAY-2
4CH is Dingtian IOT WRELAY-4
8CH is Dingtian IOT WRELAY-8
Serial Number: Relay board Serial Number
Date Time: current date and time(Need internet because of NTP)
NTP Server: NTP server get time from, suggest use pool.ntp.org
STA WiFi SSID: Your Router WiFi Name,Relay board will access to your router
STA WiFi Password: Your Router WiFi Password, Relay board will access to your router
STA IP: Relay board get IP from your Router
Netmask: WIFI Netmask
Gateway: WIFI Gateway
DNS: WIFI DNS Server
MAC: WIFI MAC address
AP IP: WIFI default address
AP SSID: WIFI default name, as a router, we need to connect the WIFI with your computer firstly
and access the wifi web
AP Password: WIFI default Password
we can use STA IP or AP IP to control relay board via WIFI, only accept to use one browser(Firefox
or Chrome) to access.

5.3 Setting Relay Connect


WIFI-UDP1: WIFI UDP1 protocol, Remote Server Address,Remote Server Port,Local Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over UDP(use RS485 addr)
Modbus-ASCII Over UDP(use RS485 addr)
Modbus-UDP
CoAP(need change port to 5683)
Input Mutual Control
WIFI-UDP2: WIFI UDP2 protocol, Remote Server Address,Remote Server Port,Local Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over UDP(use RS485 addr)
Modbus-ASCII Over UDP(use RS485 addr)
Modbus-UDP
CoAP(we suggest enable CoAP at ETH/WiFi-UDP2)
Input Mutual Control
WIFI-TCP Server: WIFI TCP Server protocol, Local Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over TCP(use RS485 addr)
Modbus-ASCII Over TCP(use RS485 addr)
Modbus-TCP
WIFI-TCP Client: WIFI TCP Client protocol, Remote Server Address,Remote Server Port config
Protocol:
Dingtian String
Dingtian Binary
Modbus-RTU Over TCP(use RS485 addr)
Modbus-ASCII Over TCP(use RS485 addr)
Modbus-TCP
WIFI-MQTT: WIFI MQTT protocol, Broker Address, Broker Port, Broker Username, Broker
Password config
Protocol:
MQTT(without tls)
Other Parameter:
Relay Password: use for checking control is valid, only correct password control relay board
Keep Alive Second: send relay status to server with every “Keep Alive Second”, only protocol
Dingtian String and Dingtian binary have Keep Alive Second

Jogging Time: Jogging time, default is 500ms,1=100ms


what is Jogging: ON then delay 500ms OFF,or OFF then delay 500ms ON
5.4 Relay CGI Test
5.5 Relay Task
Choose “Repeat”, you can ask repeat by second/minute/hour/day/week/month

5.6 Input
5.7 Input Link Relay
Select R1~R8, means you add the relay to link with Input, Click the green button R1~R8 means
delete relay

5.8 IP WatchDog
When Enable IP WatchDog function, all relay ON, when the “Watch IP” offline, relay OFF, after
seconds, the relay ON automatically, “Ping Interval” must be bigger than “Ping Timeout”
5.9 Reset User

5.10 To Factory
6 IP Finder

Notice:
please close all firewall,security software(windows defender/firewall alse must close)
otherwise nothing will be find
6.1 Search Device
Note: When you use IP Finder to check your relay board ip, please keep your computer just
connect with one relay board and the communication of relay board just has one(only Ethernet
or WIFI)

Then we can find computer ip is 192.168.1.88, relay board ip is 192.168.1.100


If your computer ip is not the same network segment as relay board, you can change the IP in
Ethernet Static IP
6.2 Change Static IP

Change Static IP and Click”Write IP”, then your relay board ip is 192.168.12.100
Appendix I How to Test Command
step 1: download SDK
we can find network tool in SDK
http://www.dingtian-tech.com/sdk/relay_sdk.zip
unzip relay_sdk.zip
network tool name is net_test
rs485 tool name is rs485_test

Access directory “net_test”


step 2: Change NetAssist language
step 3: Control relay via NetAssist network tool by wifi
module
open NetAssist.exe
Shown in red box, open expansion panel
step 4: open UDP listen.
now relay board send relay status to pc via wifi module

step 5: control relay via wifi module


NetAssist tool saved preset command
we only need send to relay board via netAssist
like below set relay 1 on
Appendix II How to use Domoticz
Notice:
1 Close your firewall
2 All command and script run as root/administrator
3 please step by step

Please install domotiz first


https://releases.domoticz.com/releases/release/domoticz_windows_x86.zip

step 1: install Dingtian plugin to Domoticz


Dingtian plugin find in SDK or github
http://www.dingtian-tech.com/sdk/relay_sdk.zip
https://github.com/dtlzp/Domoticz-Dingtian-Relay-Plugin

1 Stop Domoticz

2 Copy Domoticz_plugins\dingtian to Domoticz plugin dir

to Domoticz install dir

now Dingtian Relay plugin install to Domoticz successfully.


step 2: config Dingtian Relay board
1 config relay board UDP Server,Remote Port,Local Port,Keep Alive Second and Relay Password
(firmware version <= 2.16.xx)
2 config relay board UDP Server, Remote Port,Local Port and Relay Password (firmware version is
2.17.xx)

Domoticz Ethernet
Domoticz WIFI

Dingtian Relay board web page Relay Connect


set UDP Server, Remote Port,Local Port,Relay Password and Keep Alive Second(donot need to
set for firmware 2.17.xx)
Notice: UDP Server set to Domoticz Server IP Save config
step 3: Add Dingtian Relay to Domoticz
1 Install Python 3.8.2
download link:
https://www.python.org/ftp/python/3.8.2/python-3.8.2.exe
Notice: Domoticz only support 32bit Python

after download,install it

Add Python to environment

2 Run to Domoticz
3 Add Dingtian Relay to Domoticz
1 Find Hardware Menu

2 Input Dingtian Relay config(Ethernet)


3.Input Dingtian Relay config(WIFI)

Type,IP Address,Port,Channel Count,Password must correct,


Password is 1 config relay board UDP Server,Remote Port,Local Port,Keep Alive Second and Relay
Password

now check parameters is ok,


click “Add” to save

Now your can find Hardware and Relay


4 Multiple Relay board Add to Domoticz
Domoticz Need 2 UDP port for each Relay board
default is:60000 and 60001
you can add mutiple with difference UDP port like:
60002 and 60003
60004 and 60005
60006 and 60007
below is example 60002 and 60003
5 Add Relay to Switches Page

Click Add Device to use Relay


Click Add Device to confirm

result
4 Control Dingtian Relay with Domoticz
Switch “Switches” page

Click light icon to control relay


step 4: Domoticz mobile application
Please follow up step 1/2/3 firstly to confirm PC Domoticz connect

1 Set the Location, User name and password on PC Domoticz

2 Install Domoticz
Android google play “Domoticz Home Automation Lite”, which is free of charge and cannot
refresh automatically. So please refresh by manual after do it
3 Set Domoticz Server parameter

Domoticz mobile connect successfully, then you can control the switch by mobile phone
Appendix III How to MQTT
MQTT Ethernet
MQTT WIFI
Relay board Ethernet MQTT Client Id
dingtian-relay+SN
Relay board WiFi MQTT Client Id
dingtian-wrelay+SN

example:
below relay board “Serial Number” is 1868
so ETH MQTT client id is:dingtian-relay1868
so WiFI MQTT client id is:dingtian-wrelay1868
Relay board MQTT Topic and Publish format:
below V2.15.869
/dingtian/relay/in/control
/dingtian/relay/out/relayX
above V2.15.869
/dingtian/relaySN/in/control
/dingtian/relaySN/out/relayX
above V2.17.xx
ETH
/dingtian/relaySN/in/control
/dingtian/relaySN/in/rX
/dingtian/relaySN/out/rX
/dingtian/relaySN/out/iX
/dingtian/relaySN/out/relayX
/dingtian/relaySN/out/inputX
/dingtian/relaySN/out/ip
/dingtian/relaySN/out/sn
/dingtian/relaySN/out/mac
/dingtian/relaySN/out/input_cnt
/dingtian/relaySN/out/relay_cnt

WiFi
/dingtian/wrelaySN/in/control
/dingtian/wrelaySN/in/rX
/dingtian/wrelaySN/out/rX
/dingtian/wrelaySN/out/iX
/dingtian/wrelaySN/out/relayX
/dingtian/wrelaySN/out/inputX
/dingtian/wrelaySN/out/ip
/dingtian/wrelaySN/out/sn
/dingtian/wrelaySN/out/mac
/dingtian/wrelaySN/out/input_cnt
/dingtian/wrelaySN/out/relay_cnt
example:
below V2.15.869
/dingtian/relay/in/control
/dingtian/relay/out/relay1
/dingtian/relay/out/relay2
/dingtian/relay/out/relay3
/dingtian/relay/out/relay4
/dingtian/relay/out/relay5
/dingtian/relay/out/relay6
/dingtian/relay/out/relay7
/dingtian/relay/out/relay8

above V2.15.869
/dingtian/relay1868/in/control
/dingtian/relay1868/out/relay1
/dingtian/relay1868/out/relay2
/dingtian/relay1868/out/relay3
/dingtian/relay1868/out/relay4
/dingtian/relay1868/out/relay5
/dingtian/relay1868/out/relay6
/dingtian/relay1868/out/relay7
/dingtian/relay1868/out/relay8

above V2.17.xx
ETH
/dingtian/relay1868/in/control
/dingtian/relay1868/in/r1~8
/dingtian/relay1868/out/r1~8
/dingtian/relay1868/out/i1~8
/dingtian/relay1868/out/relay1~8
/dingtian/relay1868/out/input1~8
/dingtian/relay1868/out/ip
/dingtian/relay1868/out/sn
/dingtian/relay1868/out/mac
/dingtian/relay1868/out/input_cnt
/dingtian/relay1868/out/relay_cnt

WIFI
/dingtian/wrelay1868/in/control
/dingtian/wrelay1868/in/r1~8
/dingtian/wrelay1868/out/r1~8
/dingtian/wrelay1868/out/i1~8
/dingtian/wrelay1868/out/relay1~8
/dingtian/wrelay1868/out/input1~8
/dingtian/wrelay1868/out/ip
/dingtian/wrelay1868/out/sn
/dingtian/wrelay1868/out/mac
/dingtian/wrelay1868/out/input_cnt
/dingtian/wrelay1868/out/relay_cnt

Relay board MQTT Topic to subscribe:


/dingtian/relay/in/control
or
/dingtian/relay1868/in/control

type:ON/OFF,DELAY,JOGGING
idx:1~8
status:ON,OFF
time: (ON/OFF)0,(DELAY)1~65535second,(JOGGING)1~255*100ms
pass:0~9999

example:
{"type":"ON/OFF",'idx':'1',"status":"ON","time":"0","pass":"0"}
{"type":"DELAY",'idx':'2',"status":"ON","time":"5","pass":"0"}
{"type":"JOGGING",'idx':'3',"status":"ON","time":"5","pass":"0"}
{"type":"ON/OFF",'idx':'4',"status":"OFF","time":"0","pass":"0"}

Relay board MQTT Topic to publish:


/dingtian/relay/out/relay1
/dingtian/relay/out/relay2
/dingtian/relay/out/relay3
/dingtian/relay/out/relay4
/dingtian/relay/out/relay5
/dingtian/relay/out/relay6
/dingtian/relay/out/relay7
/dingtian/relay/out/relay8
or
/dingtian/relay1868/out/relay1
/dingtian/relay1868/out/relay2
/dingtian/relay1868/out/relay3
/dingtian/relay1868/out/relay4
/dingtian/relay1868/out/relay5
/dingtian/relay1868/out/relay6
/dingtian/relay1868/out/relay7
/dingtian/relay1868/out/relay8
or
/dingtian/relay1868/out/r1~8
/dingtian/relay1868/out/i1~8
/dingtian/relay1868/out/relay1~8
/dingtian/relay1868/out/input1~8
/dingtian/relay1868/out/ip
/dingtian/relay1868/out/sn
/dingtian/relay1868/out/mac
/dingtian/relay1868/out/input_cnt
/dingtian/relay1868/out/relay_cnt

idx:1~8
status:ON,OFF

example:
{“idx”:”1”,”status”:”OFF”}

step 1: Install and config Broker

1 config “mosquitto.conf”
bind_address 0.0.0.0
port 1883

2 start windows Service “mosquitto”

step 2: Install MQTT PC client

step 3: MQTTBox Add Client

Protocol:mqtt/tcp
Host:192.168.1.88:1883(Broker server ip and port)
Username:mqtt
Password:123
Broker MQTT V3.1.1 compliant
Config Relay board Web page MQTT parameter
step 4: MQTTBox Publish topic to relay board and subcribe
topic
Appendix IV How to CoAP
you need linux system

step 1: compile libcoap


git clone --recurse-submodules https://github.com/obgm/libcoap
./autogen.sh
./configure --disable-manpages --enable-examples --enable-tests
make

step 2: CoAP Get relay status


Relay Status(1:ON, 0:OFF)
./coap-client -m get coap://192.168.1.100/dingtian/r1
./coap-client -m get coap://192.168.1.100/dingtian/r2
./coap-client -m get coap://192.168.1.100/dingtian/r3
./coap-client -m get coap://192.168.1.100/dingtian/r4
./coap-client -m get coap://192.168.1.100/dingtian/r5
./coap-client -m get coap://192.168.1.100/dingtian/r6
./coap-client -m get coap://192.168.1.100/dingtian/r7
./coap-client -m get coap://192.168.1.100/dingtian/r8

Input Status(1:High, 0:Low)


./coap-client -m get coap://192.168.1.100/dingtian/i1
./coap-client -m get coap://192.168.1.100/dingtian/i2
./coap-client -m get coap://192.168.1.100/dingtian/i3
./coap-client -m get coap://192.168.1.100/dingtian/i4
./coap-client -m get coap://192.168.1.100/dingtian/i5
./coap-client -m get coap://192.168.1.100/dingtian/i6
./coap-client -m get coap://192.168.1.100/dingtian/i7
./coap-client -m get coap://192.168.1.100/dingtian/i8

step 3: CoAP Control relay(simple)


./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r1 # relay1 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r1 # relay1 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r2 # relay2 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r2 # relay2 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r3 # relay3 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r3 # relay3 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r4 # relay4 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r4 # relay4 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r5 # relay5 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r5 # relay5 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r6 # relay6 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r6 # relay6 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r7 # relay7 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r7 # relay7 OFF
./coap-client -e "1" -m put coap://192.168.1.100/dingtian/r8 # relay8 ON
./coap-client -e "0" -m put coap://192.168.1.100/dingtian/r8 # relay8 OFF

step 4: CoAP Control relay


format:
status:type:time:password
status:0,1
type:ON/OFF,DELAY,JOGGING
time:(ON/OFF)0,(DELAY)1~65535second,(JOGGING)1~255*100ms
password:0~9999

example:
1:ON/OFF:0:4660
status:1
type:ON/OFF
time:0
password:4660

ON/OFF example:
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r1
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r2
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r3
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r4
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r5
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r6
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r7
./coap-client -e "1:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r8
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r1
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r2
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r3
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r4
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r5
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r6
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r7
./coap-client -e "0:ON/OFF:0:4660" -m put coap://192.168.1.100/dingtian/r8

DELAY example:
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r1
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r2
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r3
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r4
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r5
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r6
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r7
./coap-client -e "1:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r8
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r1
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r2
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r3
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r4
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r5
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r6
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r7
./coap-client -e "0:DELAY:5:4660" -m put coap://192.168.1.100/dingtian/r8

JOGGING example:
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r1
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r2
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r3
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r4
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r5
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r6
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r7
./coap-client -e "1:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r8
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r1
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r2
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r3
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r4
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r5
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r6
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r7
./coap-client -e "0:JOGGING:5:4660" -m put coap://192.168.1.100/dingtian/r8
Appendix V How to “input mutual control”
Example param:
DevA IP: 192.168.1.100
DevB IP: 192.168.1.101

web config “Input Control Relay”


“No”:input only control remote output
“Yes”:input control local output and remote output

DevA web config:


DevB web config:
Appendix VI How to Home Assistant
Notice:
1 Close your firewall
2 All command and script run as root/administrator
3 please step by step

Step 1 config Relay board

The “192.168.1.9” is MQTT broker IP


Step 2 Install MQTT Broker
Link step 1: Install and config Broker for details how to install MQTT Broker

Step 3 Install Home Assistant


1 install python
Python download link:
https://www.python.org/ftp/python/3.10.0/python-3.10.0.exe

2 install Home Assistant


Windows install command:
python -m pip install --upgrade homeassistant tzdata met

3 Add relay board Switch and input to Home Assistant


Home assistant default config yaml path:
C:\Users\Administrator\AppData\Roaming\.homeassistant\configuration.yaml

example is 2 channel relay board, SN is 100


when you use it please replace with you relay board SN

SDK path:
MQTT\home_assistant_example.yaml

add below lines to configuration.yaml


######################### start #########################
switch:
- platform: mqtt
unique_id: dingtian100-r1
name: "Dingtian Ethernet Switch1"
state_topic: "/dingtian/relay100/out/r1"
command_topic: "/dingtian/relay100/in/r1"
availability:
- topic: "/dingtian/relay100/out/lwt_availability"
payload_available: "online"
payload_not_available: "offline"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: false

- platform: mqtt
unique_id: dingtian100-r2
name: "Dingtian Ethernet Switch2"
state_topic: "/dingtian/relay100/out/r2"
command_topic: "/dingtian/relay100/in/r2"
availability:
- topic: "/dingtian/relay100/out/lwt_availability"
payload_available: "online"
payload_not_available: "offline"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: false

binary_sensor:
- platform: mqtt
unique_id: dingtian100-i1
name: "Dingtian Ethernet Input1"
state_topic: "/dingtian/relay100/out/i1"
availability:
- topic: "/dingtian/relay100/out/lwt_availability"
payload_available: "online"
payload_not_available: "offline"
payload_on: "ON"
payload_off: "OFF"
qos: 0

- platform: mqtt
unique_id: dingtian100-i2
name: "Dingtian Ethernet Input2"
state_topic: "/dingtian/relay100/out/i2"
availability:
- topic: "/dingtian/relay100/out/lwt_availability"
payload_available: "online"
payload_not_available: "offline"
payload_on: "ON"
payload_off: "OFF"
qos: 0
######################### end #########################

4 Home Assistant config MQTT Broker


Windows open Home Assistant command:
hass –open-ui

Home Assistant web link:


http://127.0.0.1:8123/
config MQTT Broker
step 1

step 2
step 3

step 4
step 5

step 6
restart Home Assistant
Ctrl+C hot key to Stop Home Assistant
hass –open-ui to start Home Assistant
step 6
new Home Assistant can control relay and get input status
Appendix VII How to openHAB
Notice:
1 Close your firewall
2 All command and script run as root/administrator
3 please step by step

Step 1 config Relay board

The “192.168.1.9” is MQTT broker IP


Step 2 Install MQTT Broker
Link step 1: Install and config Broker for details how to install MQTT Broker

Step 3 install JDK and openHAB


1 Download
JDK download link:
https://cdn.azul.com/zulu/bin/zulu11.54.25-ca-jdk11.0.14.1-win_x64.msi

OpenHAB download link:


https://openhab.jfrog.io/artifactory/libs-release-local/org/openhab/distro/openhab/3.2.0/
openhab-3.2.0.zip

OpenHAB add-on download link:


https://openhab.jfrog.io/artifactory/libs-release-local/org/openhab/distro/openhab-addons/
3.2.0/openhab-addons-3.2.0.kar
2 install
unpack zip directory tree as below image(Example install directory is “D:\tool\openHAB”):
Notice:
The openHAB install directory must contain no spaces
3 Add jdk directory to “start.bat”
Add “set JAVA_HOME=D:\tool\openHAB\zulu11.54.25-ca-jdk11.0.14.1-win_x64”
to file start.bat as below
4 First time init openHAB
1 double click “start.bat”
2 First time init openHAB
use Firefox open URL “http://localhost:8080”(my computer chromium can’t open openHAB web
page)
after first time config,you can get main web page like below
Notice:
please save username and password
3 install MQTT-binding

4 Stop openHAB
Step 4 Add Dingtian Relay board to openHAB
2ch_config for 2 channel relay board
4ch_config for 4 channel relay board
8ch_config for 8 channel relay board

1 Change json MQTT broker host, username,password


change file “org.openhab.core.thing.Thing.json”

2 Change json SN(example SN 7920) to you relay board SN


Change file:
“org.openhab.core.thing.Thing.json”
“org.openhab.core.thing.link.ItemChannelLink.json”
“org.openhab.core.items.Item.json”
org.openhab.core.thing.Thing.json
org.openhab.core.thing.link.ItemChannelLink.json
org.openhab.core.items.Item.json
3 Cover openHAB json
OpenHAB json path: “D:\tool\openHAB\openhab-3.2.0\userdata\jsondb”

Notice:
example openHAB install path “D:\tool\openHAB\openhab-3.2.0”

4 Control relay board with openHAB


1 double click “start.bat”
Wait 1 minute for openHAB startup
2 Open openHAB web page
It shows MQTT broker and Relay board 7920 is online

control relay

You might also like