element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog "Remember Me Always!" - Part 018
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: COMPACT
  • Date Created: 2 Oct 2014 10:28 PM Date Created
  • Views 353 views
  • Likes 1 like
  • Comments 0 comments
  • forget_me_not
  • remember_always
Related
Recommended

"Remember Me Always!" - Part 018

COMPACT
COMPACT
2 Oct 2014

Are you in a Bind?

 

The poor documentation can make things seem more complicated than they really are.

Getting an Raspberry Pi output pin working on OpenHAB is actually much easier than you are led to believe.

 

Here's a quick example on how to get an LED and current limiting resistor connected to Pin 11 (GPIO17) up and going.

All one needs to do is to;

1. Ensure that the GPIO is not exported and used by another process.

2. Connect the LED and resistor.

3. Copy the gpio binding and io files to the openhab addons directory.

4. Create an switch item in the items file to represent the LED

5. Insert the new item into a sitemap file where you want to control it.

6. Test it

 

The LED anode is connected to Pin11, the LED cathode is connected to the resistor, the other end of the resistor is connected to Pin 39 -GND for Model B+ (or Pin 25 for Model B)

 

The files to copy are from the openhab bindings .zip file which is downloadable from the openhab.org website.

The filenames are:

    org.openhab.io.gpio*

    org.openhab.binding.gpio*

 

* indicates the release suffix.

 

An item entry is as simple as:

Switch gpio_led17 "LED17" { gpio="pin:17" }

 

A sitemap entry is as simple as:

  Switch item=gpio_led17

 

For the Raspberry Pi the GPIO number scheme is the assigned GPIOxx pin name and not the physical pin number.

e.g. Pin 11 of the expansion header is GPIO17

 

Be aware that when shutting down openhab you'll need to unexport the GPIOs used by openhab to free them up so they can be reinitialised by openhab if you should decide to restart openhab.

 

Notes:

The /sys/class/gpio is a standard Linux feature and is not specific to the Raspberry Pi.  What is specific to the Raspberry Pi are the actual GPIOs present.

 

echo 17 > /sys/class/gpio/export can be used to export GPIO17

echo out > /sys/class/gpio/gpio17/direction can be used to set the GPIO17 as an output pin

echo 1 > /sys/class/gpio/gpio17/value can be used to set the output pin high

echo 0 > /sys/class/gpio/gpio17/value can be used to set the output pin low

echo 17 > /sys/class/gpio/unexport can be used to unexport GPIO17

 

This is applicable to other GPIOs

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube