Page 1 of 1

Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 14:05
by geotravel
Hello,

I have relay as attached picture and USB<->serial port base on CP2102 . Is it possible use together these devices with domoticz ?? How to create
this software switch in domoticz to switch On/OFF relay via USB serial port ??

Regards

Waldek

Re: Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 17:31
by SweetPants
geotravel wrote:I have relay as attached picture and USB<->serial port base on CP2102 . Is it possible use together these devices with domoticz ?? How to create this software switch in domoticz to switch On/OFF realy via USB serial port ??
No you cannot connect the CP2102 to the Relay. The CP2102 is a serial port adapter unless it has RTS/DTR pins, then it might be possible.

Re: Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 17:51
by geotravel
Hi,

As attached picture USB serial converter have output RTS (in bottom output pins). So I can connect RTS pin to IN in board relay and send
command under linux to SET HI or LOW RTS line ???

Re: Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 18:08
by SweetPants
geotravel wrote:Hi,

As attached picture USB serial converter have output RTS (in bottom output pins). So I can connect RTS pin to IN in board relay and send
command under linux to SET HI or LOW RTS line ???
It's DTR/RST not RTS.

Name Pin # Type Description
...
RST 9 D I/O Device Reset. Open-drain output of internal POR or VDD monitor. An
external source can initiate a system reset by driving this pin low for
at least 15 μs.

Re: Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 18:13
by SweetPants
Take a look at the FF32 (FlyFish) http://www.flyfish-tech.com/FF32/index.php

Re: Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 18:39
by geotravel
Please find attached picture where I marked green square DTR/RTS and this converter have output RTS line marked by red square
or it is mistake description on board

Re: Relay via USB serial port CP2102

Posted: Sunday 07 May 2017 19:28
by geotravel
Ok by if I have usb/serial converter with RTS line how to create bash or python script to send /dev/ttyUSB0 to set HI or LOW RTS line?

Re: Relay via USB serial port CP2102

Posted: Saturday 21 October 2017 16:00
by DoubleHP
I have published a detailed answer here: https://forums.gentoo.org/viewtopic-p-8 ... ml#8132756

Here is the short version:

Code: Select all

#!/bin/bash
MySerialPort="/dev/ttyUSB0"
MyLatency="2"
echo "#include <fcntl.h>
#include <sys/ioctl.h>
main()
{ int fd; fd = open(\"${MySerialPort}\",O_RDWR | O_NOCTTY );
int RTS_flag; RTS_flag = TIOCM_RTS;
ioctl(fd,TIOCMBIS,&RTS_flag);
sleep (${MyLatency});
ioctl(fd,TIOCMBIC,&RTS_flag);
close(fd); } " | tcc -run -
Note that sending data on TX will probably mess RTS; see the Gentoo forum for details.