Desparate for a simple GPIO tutorial "hello world"?

Hi. I’m new to OH and thought I was savvy enough to get things up and running quickly. However, OH has proven to be much more difficult and complicated than anything I ever could imaging.

I have a fresh install of OpenHabian which seems to be working perfect. There seems to be zero documentation or tutorials on how to get things up and running for a simple GPIO LED/button test similar to “hello world” in the program world.

Any help or suggestions appreciated.

GPIO is not one of the more common addons used, particularly for those who use openHABian.

However, the GPIO readme is fairly thorough on getting GPIO to work in OH.

For working with OH in general and understanding how it all works together, see the Beginner’s Tutorial and the Introduction and Concepts sections of the User Manual.

It would be very helpful to also set up the Demo package (you can choose it the very first time you bring up the web page or by editing services/addons.cfg) which includes an example configuration.

1 Like

Hi. Thanks for your help.

I have critical pump controllers that are hard wired to my Raspberry Pi.
I previously had a simple setup working perfectly using the easyIOT
project (http://iot-playground.com/). It was extremely easy to setup (1
hr) and get the GPIO’s working. However, I needed automation that
easyIOT could not provide. Before proceeding the OH2, i reviewed the
online documentation and it seemed like a straightforward process to
make GPIO’s work. Unfortunately, its seems like a nightmare of bits and
pieces of OH community help snipets and consuming far too many hours of
my time for such a simple feature to function. So far I’m only able to
display an on/off pump switch on the Basic UI , but no pin changes on
the RPI. I tried to follow the GPIO readme, which seems to create more
questions than answers. I need to confirm that I can actually use GPIO
control in OH before committing myself to OH and my final solution to
build out my full home automation system. I will attempt once more
before giving up entirely.

So if you don’t mind, my first basic question: Doesn’t the latest
Openhabian install image satisfy the prerequisites mentioned in the GPIO
readme?

Thanks
Brent

If there is any doubt in your mind about openHABian, you can install a stock raspbian which will have all of the groups and such already installed and configured.

Lots of people have successfully made this work so it is possible.

It is also possible to outsource the GPIO to an external program (e.g. a python script) and interact with OH through a higher level protocol like MQTT or HTTP.

Brand new user here. I installed OH2 on Rpi that will be used to open and close a door on the hen house. After digging in, I see that my OH2 instance really needs to be in the house, and the client in the hen house. So, I’ve been looking for some simple examples of things that can be automatically discovered. Is MQTT the general use case for discoverable things on an OH2 network?

Hi just a suggestion i am using node red to talk to IOT devices , its much more simplier


this is not a replcamnet for OH, its addon for me but it plays a very big role

No. the MQTT binding has not yet been successfully rewritten as a 2.x version binding. Since there is only a 1.x version binding there is no support for Things with MQTT.

But that doesn’t make MQTT particularly hard. MQTT Binding (v1.11) Getting Started 101

Okay, so let’s assume I want to write a trivial RPi client. What would the preferred method be? I’m asking, because for the hen house, I know how to execute a shell command to make actuation work. Would it be a web interface? MQTT? I’d like to make it automatically discoverable. For now, it’s a simple door. Open at dawn, and close at dusk. In the future, I’ll want to turn on a light bulb to keep them laying during the short winter days, and also control a heater.
I like easy.

I know of no way to make it automatically discovered. There is no 2.0 binding that supports this.

If you like easy you need to buy off the shelf. Any diy approach is going to take some learning and work on your part.

There are lots and lots of approaches but they will all require editing text files and understanding at least the basics of the technologies you are using.

Personally I would have a python script running on the pi that sends data and received commands over mqtt.

Today is my first day working with this, and there is a steep learning curve. For the time being, I’m trying something akin to a “Hello World” example. If I can get the plumbing figured out, I can figure out the MQTT interface.
I set up a network binding, and created a thing, “my pingable phone”. So next is making an item, and it got populated for me, and the item is called “online”, and I made it a switch. Back to my “thing” (the pingable phone), it now has three channels, with one being “online”. That part I think is working. I installed the rules engine from the misc addons. I made a rule to send mail. I edited the mail.cfg file, and I also see that I can test that rule.
When I try to test, I get, “updated: UNINITIALIZED (HANDLER_INITIALIZING_ERROR): Getting handler ‘script.ScriptAction’ for module ‘2’ failed: Type is missing in the configuration of module ‘2’.”
I’m not seeing any entries in my mail server log, but I think I’m getting close.

Did you install the mail action?

Is someone working on it? I don’t really see how you would create a standard mqtt binding that allows things to be added unless you create a huge project like one I saw being worked on called homie?

You could use my binding espmilighthub do auto find mqtt devices if u were happy faking as a globe and having the controls of the globes showing up in openhab.

Yes but I don’t know the status. It is an ambitious effort and will include a broker do you won’t be required to run a separate server if you don’t want to.

I don’t know what the hold up is.

I did, and after looking closer, it appears I need to write an actual script to access the mail action. In the rule engine, there is no way to access API functions directly.

So yesterday was productive. After trying to narrow the scope, I verified that I could receive events, and send commands. Everything else is now a detail to make it function properly. I started by trying to detect an Android phone on the network, but there are some network issues to address with DHCP, because ping is not a good indicator for a device on low power battery management. I also tried email, and dropped back to sounding a .wav file and watching the server logs.
For a simple start, I’d like to detect when an Android device associates with the WiFi. When that occurs, send a notification, probably an SMS or push to my personal phone.
I’ve seen a lot of examples of people doing something, but I don’t have those devices. It would be nice to find an example of something everyone has, and that would be a internet, and email. Or something along those lines.

???

https://docs.openhab.org/addons/actions/mail/readme.html

rule "Test mail message"
when
    // some rule trigger
then
    sendMail("address@domain.com", "This is an alert from openHAB", "The body of the email")
end

Phone detection is tricky. The Network binding is only part of the approach. Some use iPhone Presence Detection with hping3 and ARP or even better the arping capability of the Network Binding which can wake up an asleep phone and get a response back even when the phone is in a deep sleep. Others use BT detection or GPS.

For alerts, I think that most people use the openHAB Cloud Connector with myopenhab.org and the phone app. Most of us use myopenhab.org to access our OH remotely anyway so it is pretty natural to use it for alerting.

Please note that the notification part of myopenhab is presently out of service because there were problems with it.