Raspberry Pi can now work with UEXT modules


Image

In my previous post http://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!

22 Comments (+add yours?)

  1. Trackback: Olimex สาธิตการใช้ RPI-UEXT | Raspberry Pi Thailand
  2. 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.

    Reply

  3. Trackback: 3.95 Euros RPI-UEXT Breadboard & UEXT Adapter for Raspberry Pi is Now Available
  4. iulian
    Mar 14, 2013 @ 20:58:13

    hello, how can I go ON only one relay? best regards

    Reply

    • 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!

      Reply

    • 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

      Reply

  5. john
    Mar 14, 2013 @ 21:54:08

    how I read relays status? thank you

    Reply

  6. imran
    Mar 18, 2013 @ 17:56:07

    the raspberry pi pack was promised, please provide the same

    Reply

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

    Reply

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

    Reply

  9. iulian
    Sep 05, 2013 @ 15:26:03

    Hello,
    How can read the values ​​from AN1 to AN4 and how to calculate volts?
    Best regards

    Reply

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

    Reply

    • 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. :-)

      Reply

      • 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. :(

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

    Reply

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

    Reply

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

    Reply

  14. Nabb .
    Jun 03, 2014 @ 10:05:53

    nobody answers questions here?? :(

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 550 other followers

%d bloggers like this: