Page 1 of 1

### How to get the Serial USB comunication with a 4 channel relay board to work ???

Posted: Wed Dec 26, 2018 4:13 am
Hi there i'm Julius and i have one Problem with my raspberry pi 3 b+.

So i'm trying to let the pi controll this rellay board
(https://www.amazon.com/SainSmart-USB-Ch ... elay+board)

for my school project with a Python code so that i can modify it easily.
But i tried alot of programs and dirvers and reinstalling the operating system (rasbian)(is this the right operating system for that would be great?) and stuff like that, so could please anybody help me and could tell where i have to start and how.

And i don't wan't to make any presure but it would be nice if we could solve that problem as fast as possible, do you understand?

If there are any questions you are free to ask.

Dear Julius.

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 6:40 am

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 6:48 am
afaik you shouldnt need any drivers to use serial ftdi coms

to use python for serial coms Install PySerial, either

Code: Select all

``````
sudo apt-get install python-serial
``````
for Python2, or

Code: Select all

``````
sudo apt-get install python3-serial
``````
for Python3.

from the amazon page linked to
Open comm port at 9600 baud, 8 bit, no parity, 1 stop bit
no flow control. Mr. Merryman was correct in his command determination. The relays are selected by
binary where:
0001 = relay 1 on = Dec 1
0010 = relay 2 on = Dec 2
0100 = relay 3 on = Dec 4
1000 = relay 4 on = Dec 8
Let relayvalue = decimal value of relay desired
ie: relayvalue = 1 for relay one.
Then send chr\$(relayvalue) to the comm port.
If you want multiple relays add their decimal values together,
1 & 4 would be relayvalue=9
To then turn relay 4 off, subtract 8 from relayvalue and send relayvalue=1, turning
off relay 4 and leaving relay 1 on.

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 12:01 pm
Hi thanks for that first help but the last thing what I would need is a python code that turns some relays on and of(you can decide which relay) and that runs without errors on the raspberry3 b+. And it would be great if someone could explain how to find the com port were the rellay board is connected. So that i can edit that in the code.

Thank you so much

We are getting closer to the finishline!!

Quick response would bee great because it is a schoolproject

Dear Julius

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 6:18 pm
They don't seem to work directly using Pyserial, but here's a library with example code that should work for you: PyRelayCtl.

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 7:25 pm
"Quick response would bee great because it is a schoolproject"

So....you want everyone to drop everything and hurry up and do the work YOU were supposed to do so YOU can get credit???

Happy New Year...

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 8:37 pm
/dev/ttyUSB#
or
/dev/ttyACM#

# being a number.
What and why and which.. have a look.

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 8:53 pm

viewtopic.php?t=216670#p1336648

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Wed Dec 26, 2018 9:02 pm
JuliusCesar2017 wrote:
Wed Dec 26, 2018 4:13 am
And i don't wan't to make any presure but it would be nice if we could solve that problem as fast as possible, do you understand?
There is no pressure on anyone here. A lack of foresight on your part does not constitute an emergency for anyone else. Please show that you have done the work you should have done, including consulting with your instructor. And, by the way, if someone here tells you how to do your work, then you should arrange that they get your course credit for doing it.

### Re: How to get the Serial USB comunication with a 4 channel relay board to work ??? HELP PLEASE SCHOOL PROJECT

Posted: Fri Dec 28, 2018 8:34 am
He came, He asked, but did He conquer?