JuliusCesar2017
Posts: 2
Joined: Wed Dec 26, 2018 3:57 am

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

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.
:roll: ;)

User avatar
DougieLawson
Posts: 35793
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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

Wed Dec 26, 2018 6:40 am

Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

PhatFil
Posts: 1342
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

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

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.

JuliusCesar2017
Posts: 2
Joined: Wed Dec 26, 2018 3:57 am

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

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

:D :P

User avatar
scruss
Posts: 2419
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

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

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.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

pws
Posts: 91
Joined: Mon Apr 11, 2016 4:16 pm

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

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...

User avatar
bensimmo
Posts: 4152
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

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

Wed Dec 26, 2018 8:37 pm

/dev/ttyUSB#
or
/dev/ttyACM#

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


W. H. Heydt
Posts: 10755
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

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

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.


Return to “General discussion”