Page 1 of 2

Help! GPio, 8 relays...

Posted: Monday 06 April 2015 21:58
by BarryT
I have one small problem i guess.

RaspBerry 2B + 8 Channel Relays Module
Everything is working, all 8 relays are doing its job, but its working in the wrong direction.
Ofcourse i've made the gpio settings in the scripts (gpio export 17 out, etc) and i've made 2 relays in Domoticz, for testing.
When the raspi is starting up, all relays going to ON with a lot of noise :P and in Domoticz they are OFF while the leds are on.
When i click to OFF they are going to ON, and viceversa..

And, how to setup the relays to stay OFF while booting, now they going all to ON while the state in domoticz is OFF?

Thank you.

Re: Help! GPio, 8 relays...

Posted: Monday 06 April 2015 22:14
by RayAmsterdam
That is the way the relay board works. The relay board is 'active low' (relay active when signal is grounded, while the pi is active high (3,3v = On, 0v = Off).
There is a way to fix that, but you have to desolder the resistors and diodes on the relay board and solder some new resistors and bridges. Do you have a picture of the relay board?

Re: Help! GPio, 8 relays...

Posted: Monday 06 April 2015 22:27
by BarryT
Well, i'm a technician so i know how a relais works, but... It's working "spiegelbeeld"?
the state of the relais is ON while in domoticz the state is OFF.
Also, all relais are going to ON while booting up the raspi. I don't think thats the way it has to be.
Ofcourse:
20150406_222814.jpg
20150406_222814.jpg (117.33 KiB) Viewed 15889 times

Re: Help! GPio, 8 relays...

Posted: Tuesday 07 April 2015 22:07
by RayAmsterdam
This board isn't designed to be used with the pi. It needs ground to switch the relay on. The pi is grounded when off and 3,3v when on. That is why it acts reversed.
Here is what I did:
I removed the led and the lower resistor. I soldered in a bridge and a 100 Ohm resistor as in the first picture. You have to do this for all 8 relays! I put the jumper between ground and vcc (second picture). 5v from the pi is connected to jd-vcc. The vcc pin on the left pinrow is unused (I cut it away).
IMG_20150407_212948~2.jpg
IMG_20150407_212948~2.jpg (38.42 KiB) Viewed 15866 times
IMG_20150407_212948~3.jpg
IMG_20150407_212948~3.jpg (28.13 KiB) Viewed 15866 times
IMG_20150407_212948~4.jpg
IMG_20150407_212948~4.jpg (39.81 KiB) Viewed 15866 times

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 12:27
by BarryT
Oh gosh.. Its what they said on the website, thats it fully worked with the arduino AND raspberry..
Perhaps, it IS working, only in the wrong direction. It seems like a software (reversed) issue/protocol.
Now i can use this relaisboard, if i use the nc/no relais in reversed state, but thats not the way it should be ofcourse.
Grrrrr, why they sell it if it isnt designed to work with a raspi? :roll:

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 12:35
by ThinkPad
You could also look at a Ethernet relay board like this user has: http://domoticz.com/forum/viewtopic.php?f=17&t=5984

A bit more expensive than the board you have now, but the Ethernet one has the benefit that it doesn't need to be connected directly to the Pi. Thus, it can be placed anywhere as long as it can be connected to the Pi through network.

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 13:32
by BarryT
ThinkPad wrote:You could also look at a Ethernet relay board like this user has: http://domoticz.com/forum/viewtopic.php?f=17&t=5984

A bit more expensive than the board you have now, but the Ethernet one has the benefit that it doesn't need to be connected directly to the Pi. Thus, it can be placed anywhere as long as it can be connected to the Pi through network.
Looks cool ThinkPad, thanks..
The reason i need a fully functional 'oob' board, is because i want to (make and) test a fully operational sun-controller (for heatpipes) and/or also do some heating stuff..
Maybe its done before, maybe it doesnt, but i guess it is not impossible?
Want to use some code in domoticz (temperatures and stuff) and open/close some relays related to temperatures to turn on pumps, a valve and stuff?

Let me clearify some stuff>
I have, 1 collector pump
1 heating system (atag Q)
1 3 way valve, to send return water trough boiler (when boilertemp is > then system return temp) or otherwise trough the atag heating (gas)
1 electronic heat (3.2kwh) to warm up a 1000 liter boiler (at night) - We also have 43 pv panels to make power at day to use at night (for the electric heater as example)
Image

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 13:45
by StanHD
Although more expensive :( it's worth taking a look at Devantech Relay Boards. I use the Eth008 8 channel Relay Board. It's reliable and easy to make work with domoticz using simple HTTP commands. The Eth020 has "Hardware" already defined within Domoticz.

I use it to:-
Turn my heating thermostat from Occupied to Non-Occupied.
Operate a modified RF Remote to control my ceiling fan - On / Off / reverse.
Operate a Velux Interface for my roof windows.

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 13:51
by BarryT
StanHD wrote:Although more expensive :( it's worth taking a look at Devantech Relay Boards. I use the Eth008 8 channel Relay Board. It's reliable and easy to make work with domoticz using simple HTTP commands. The Eth020 has "Hardware" already defined within Domoticz.

I use it to:-
Turn my heating thermostat from Occupied to Non-Occupied.
Operate a modified RF Remote to control my ceiling fan - On / Off / reverse.
Operate a Velux Interface for my roof windows.
Awesome Stan! But there is one problem.
It needs to be wireless, or placed by/on the raspi otherwise i cant use it.
The raspberry is completely wireless include a zwave v2 stick (for metering electra/gas/water), and placed into the main heating room where also my boiler stands.
The only thing that i have is the powercable ofcourse.
There is also no planning of making a ethernet cable trough the house, or install a second wifi switch due some reasons.

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 14:01
by BarryT
https://www.youtube.com/watch?v=9T10hyfSri8

Here you can see what i mean..
If it doesnt work then i have to send these boards back to the seller, and tell him its not working for raspberry! :)

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 14:48
by RayAmsterdam
Barry, can't you do the modification as I did? Works like a charm.

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 14:54
by BarryT
RayAmsterdam wrote:Barry, can't you do the modification as I did? Works like a charm.
Hi Ray,

it is a option to do but i wish i had more time to do it..
i dont want to do some modification because i want to buy a lot more of some stuff so i really need board that works oob with raspberry.
i just dont have the time to solder on the circuits, i just want to 'plug and play' so its up and running in some minutes :)
this is just a start, many things more to come!
*edit if it works like the way it should be ofcourse.. haha

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 16:30
by ThinkPad
For this kind of setup i wouldn't let it control entirely by Domoticz. Too much risks when Domoticz freezes (which isn't a very uncommon condition unfortunately).
This is more a task for a PLC or so... or if you dare to take the risk and want to build it cheap: Arduino

Domoticz is too clumsy for a setup you want to rely on. For this you need some setup which is much more low-level and doesn't run a fullblown OS like a Pi. And which can also run the same code over and over again, 24/7

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 18:36
by BarryT
ThinkPad wrote:For this kind of setup i wouldn't let it control entirely by Domoticz. Too much risks when Domoticz freezes (which isn't a very uncommon condition unfortunately).
This is more a task for a PLC or so... or if you dare to take the risk and want to build it cheap: Arduino

Domoticz is too clumsy for a setup you want to rely on. For this you need some setup which is much more low-level and doesn't run a fullblown OS like a Pi. And which can also run the same code over and over again, 24/7
ahwww..
i already have 3 pi's running with (on 2 of them) the latest beta of domoticz, and they running for several days/weeks now without problems so far...
1 for logging temperatures (heating/water) with DS18B20 sensors, 1 for metering stuff like electra/gas through the zwave, and 1 (this one) for building/testing stuff.
the only problem so far was when rebooting my system (router/modem/etc) it has no re-connection to the wifi, but that has been solved by the "ifupdown.original" code..
so arduino is better for a stable system, then rpi running domoticz, to make an ethernet accessible controller, for logging and stuff?
beat me, then i'm lost! ha :o
i thought it was a great idea to do it through the rpi/domoticz hardware / interface because i can do some other tricks (like lights and stuff) to..
didnt work with arduino so far :(

Re: Help! GPio, 8 relays...

Posted: Wednesday 08 April 2015 19:34
by BarryT
Btw, the boards i used are raspberry pi 2 model b, and they look very stable so far. really nice, smooth and fast board anyway!
but a question is on my mind: What can go wrong, and why can a rpi/domoticz hang, what is the reason?
I have no other hardware attached, only the zwave and a usb wifi stick.
since it is the linux core, there are not many things that could go wrong?
i have a very good sd card, and ofcourse an 2A power supply, if that make any sence..

Re: Help! GPio, 8 relays...

Posted: Saturday 11 April 2015 14:04
by BarryT
It's solved!!

This did the trick, and everything is working like it should be, include the relais state stay OFF on powerup boot... >

In /etc/init.d/domoticz.sh

sudo sh -c 'echo # > /sys/class/gpio/export'
sudo sh -c 'echo high > /sys/class/gpio/gpio#/direction'
sudo sh -c 'echo 1 > /sys/class/gpio/gpio#/active_low'

Where # is gpio pin.

*Edit The only thing needed to do was to enter the codes all up in the startupscript, domoticz.sh
I was entering it into the latest line, so when domoticz started up it didnt see the gpio ports.
Now it does, and everything works!

Happy!

Re: Help! GPio, 8 relays...

Posted: Thursday 28 May 2015 11:20
by Degui
Please where exactly in startup script of domitcz.sh i should be putting this code-edited for my gpio pins?
I tried several places.

Could you paste an example? It would be awsome.

Its very important relays dont turn on on reboot as its controlling my garage door..

I tried your solution and:

sudo sh -c 'echo 22 > /sys/class/gpio/export'
sudo sh -c 'echo out (Instead of HIGH)> /sys/class/gpio/gpio22/direction'
sudo sh -c 'echo 1 > /sys/class/gpio/gpio22/active_low'

And also:
sudo sh -c 'echo 22 > /sys/class/gpio/export'
sudo sh -c 'echo out > /sys/class/gpio/gpio22/direction'
sudo sh -c 'echo 1 > /sys/class/gpio/gpio22/value'(Instead of active_low)

Any help would be much appreciated

Re: Help! GPio, 8 relays...

Posted: Friday 10 July 2015 11:35
by macieiks
BarryT, Any update with that? I run these relays too and I would like to invert values. Could you give us an example how to manage to do that?

Re: Help! GPio, 8 relays...

Posted: Saturday 25 July 2015 15:13
by mathiasc
Or just buy this active high board as i did (replaced 3 active low boards, if anyone needs one let me know ;))

http://www.ebay.com/itm/191294891032

Replace the active low with this one and you don't need to modify, Cut or solder anything :)

Re: Help! GPio, 8 relays...

Posted: Saturday 31 October 2015 17:36
by hasan