In my previous post https://olimex.wordpress.com/2012/11/21/raspberry-pi-gpio-to-breadboard-and-uext-adapter/ I wrote about the Raspberry pi adapter we designed which allow Raspberry Pi to have access to the modules we have like Relay modules, Thermocouple sensor modules, 3-axis magnetometer and accelerometers, Zigbee, WiFi, GSM, GPS etc.
The RPI-UEXT adapter is already in stock and you can wire it to your Raspberry Pi with any 26-pin ribbon cable, we do offer 15 cm cable also which you can use with RPI-UEXT
On this video you can see how Raspberry PI is controlling MOD-IO 4 relays with the help of the RPI-UEXT adapter: http://www.youtube.com/watch?v=vuHU2SmLYBI
to make MOD-IO control as on above video with your RPi you should do as follows:
step 1:
sudo vi /etc/modprobe.d/raspi-blacklist.conf
The file should look like:
# blacklist spi and i2c by default (many users don’t need them)
blacklist spi-bcm2708
#blacklist i2c-bcm2708
step 2:
sudo vi /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.
i2c-dev
snd-bcm2835
step 3:
sudo apt-get install python-smbus
step 4:
sudo vi modio.py
import smbus
import time
bus = smbus.SMBus(0)
address = 0x58
while 1:
bus.write_byte_data(address, 0x10, 0x0F)
time.sleep(1)
bus.write_byte_data(address, 0x10, 0x00)
time.sleep(1)
step 5:
sudo python modio.py
and you will see how the relays go ON and OFF 🙂
have fun!
ultimateohm
Dec 20, 2012 @ 14:22:05
Should four spaces be added before all lines in while loop? White space seems to be duifficult to be written properly in WordPress.
OLIMEX Ltd
Dec 20, 2012 @ 15:26:09
wordpress formatting 😦
iulian
Mar 14, 2013 @ 20:58:13
hello, how can I go ON only one relay? best regards
cristian
Aug 13, 2013 @ 10:54:34
I have the same question. How can I can I address a specific relay? Example: I want to turn on the second one…
Thank you!
cristian
Aug 13, 2013 @ 16:34:49
Ah sorry! I’ve found in the Readme.txt
dddd – bitmap of the output states, i.e. bit0 corresponds to REL1, bi1 to REL2 and so on. ‘1’ switches the relay ON, ‘0’ switches to OFF state.
So
0x00 (0000) will switch off all 4 REL
0x0F (1111) will switch on all 4
…
0x08 (1000) will switch on the first and off the second, third and forth
john
Mar 14, 2013 @ 21:54:08
how I read relays status? thank you
imran
Mar 18, 2013 @ 17:56:07
the raspberry pi pack was promised, please provide the same
OLIMEX Ltd
Mar 18, 2013 @ 18:05:29
can’t search on our web 😉 ?
https://www.olimex.com/Products/Modules/Adapters/RPi-UEXT/
skunkyjay
Aug 10, 2013 @ 11:39:47
I have this adapter and am preparing to use it. However, I am not sure how to plug it in. My breadboard it’s just the right size, so it doesn’t have the power plugging to anything. Do I need to have power flowing to it when the olimex and rpi both have their own power?
I am using the RGB LED controller: https://www.olimex.com/Products/Modules/LED/MOD-RGB/open-source-hardware
With this adpater you have in the tutorial and the RPI
Cosmin
Sep 01, 2013 @ 20:33:50
Hello.
Is it possible to connect multiple relay boards to the same Raspberry Pi?
If yes, what is the maximum number of controllers that can be linked?
Thank you
iulian
Sep 05, 2013 @ 15:26:03
Hello,
How can read the values from AN1 to AN4 and how to calculate volts?
Best regards
Daniel Marius Mossad
Oct 07, 2013 @ 13:33:14
Code:
” sudo python modio.py
File “modio.py”, line 6
bus.write_byte_data(address, 0x10, 0x0F)
^
IndentationError: expected an indented block
”
sorry, but i cant make it work. I install all is need it, and on i2cdetect i see the Mod-IO atached, but i cant make it work. Please give me some direction.
ggfdooh
Oct 07, 2013 @ 15:56:07
Since the error message says, it expects an indented block, did you try to indent the line or block? Not a Python programmer here, but I’ve read that Python is indentation sensitive. 🙂
Daniel Marius Mossad
Oct 07, 2013 @ 20:22:30
Oh yeah, thanks. Not a python programmer here too. Fixed now.
But i have another issue now.
Code:
“Traceback (most recent call last):
File “modio.py”, line 7, in
bus.write_byte_data(address, 0x10, 0x0F)
IOError: [Errno 5] Input/output error
”
i dont get it why. I check with i2cdetect -y 0 and 1 and i see them and all looks ok. 😦
Daniel Marius Mossad
Oct 07, 2013 @ 21:42:15
ok, fixed. Now seems to work with the soft from here: https://github.com/ccontavalli/python-olimex-modio
But i have one Q. If i open let’s say 1 relay and then i open second, first one is going to close automatically. the Q is, can i have both or more in the open status? Or i can open just one at the time?
Moldoveanu Marius
Oct 18, 2013 @ 16:54:31
my relay board is detected on 0x21. I send it commands to turn on the relay but nothing happens. any idea why?
OLIMEX Ltd
Oct 18, 2013 @ 16:56:25
use suport@olimex.com
Nabb .
Jan 14, 2014 @ 12:59:16
I managed to turn on the first relay using
i2cset -y 1 0x21 0x40 0x01
How can i found out the status of the relays? I tried with
i2cget -y 1 0x21
but it always returns 0x00 regardless if the relays are turned on or off.
Nabb .
Jun 03, 2014 @ 10:05:53
nobody answers questions here?? 😦
OLIMEX Ltd
Jun 03, 2014 @ 11:02:10
please send your questions to support@olimex.com this blog is not for support questions