1

I bought this module but I don't know how to use it. The supplier provides this example:

Setting virtual serial port parameters:

/bin/stty -F /dev/ttyUSB0 9600 raw -echo

Device initialization:

echo -ne "x50x51" > /dev/ttyUSB0

Example relay state change:

echo -ne "x51xA0" > /dev/ttyUSB0

echo -ne "x51xAB" > /dev/ttyUSB0

Could anyone explain to me what this command does?

echo -ne "x51xA0" > /dev/ttyUSB0

I understand that the last digit controls the state, but it is not clear if it is the last digit of the hex number, bearing in mind that the following example is x51xAB, so the last digit of the number 1100 is taken into account?

And, under these conditions, how do I know which relay I'm changing the state for? Is it related to the first hex number?

ocrdu
  • 8,705
  • 21
  • 30
  • 42
Sederato
  • 11
  • 1
  • 1
    We will need more information in order to help; What module did you purchase? Please provide a link or relevant excerpt from the manual you are referencing. echo is a common unix command, and the dev/ttyUSB0 is a common name for a USB-UART adapter on a linux computer – Brendan Simpson Sep 02 '22 at 19:36

1 Answers1

2

I would guess that the bits 0..3 map into relays 1..4.

So echo -ne "x51xA0" > /dev/ttyUSB0 de-energizes all 4 relays.

and echo -ne "x51xAB" > /dev/ttyUSB0 energizes relays 4, 2, 1

(assuming the relays are numbered 1..4) since hex b is binary 1011

Easy enough to try it and confirm (or not).

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842