Java Runtime Environment: which java platform is used and what version
openHAB version: 2.4
Issue of the topic:
Using the gpio1 binding, running OH 2.4 on my RPi, I cannot get the status of the input to be read correctly.
I have installed binding, updated items and sitemap files, connected a normally-ope push button across a 3.3v pin and a GND pin, but I cannot get a consistent read of the input.
What i mean by consitent read, is that it has worked on a very few occasions, i.e. OPEN/CLOSED is shown when button is NOT PRESSED/PRESSED. but the majority of the time it does not respond to button presses.
I have even added "openhab’ to the GPIO group, but still does not work.
Am I missing something?
No I’m not using a pull up resistor. Just a straight wire to button.
The reason for this is I used the approach taken by MKSmartHome on his blog, with the most basic update of item and sitemap files. This worked perfectly for me.
I then used the same Hardware setup but ported the code to the sitemaps and items files I’m developing for my home (extracts shown in my original post).
I just don’t see why the behaviour would change with effectively the same code (in different files) and the same hardware layout.
It will cost me one penny where I come from!!! (UK-based)
Actually, with the comment from H102 there I updated my circuit and incorporated a 10k pull-up resistor into the input pin, as suggested and shown in the link provided by H102. though there was overall improvement, I still had some issues.
These issues being that the state is not correctly reported after an action predominately on the momentary normally-open push button, the reported state remain closed after release of button. It does not change state until another push of the button is exectuted.
Any ideas of what the issue may be?
Also though (and more importantly) the status of the switch is not in sync with the status of the event & UI. i.e. switch OPEN; status showing CLOSED.
See attached picture showing status CLOSED, but button is released, i.e. OPEN.
The UI’s are always a bit strained to keep up with refreshing data. There’s a bunch of ways to mess it up as well, make sure for example that your sitemap is error free e.g. look in openhab.log for “sitemap loaded” and check for any following warnings.
In the case you illustrate though, the most significant thing I think is that your Item changed state twice in less than 10mS. I’m not at all surprised the UI missed that.
openHAB would have sent two event notifications to the UI but when that close together there is absolutely never any guarantee they would arrive at the UI in the original order, let alone get processed in the same order.
openHAB isn’t a realtime system, we are never going to get sub-10mS displays.
The timestamps are cropped out of your second picture, but I wouldn’t mind betting the same kind of thing is going on. Rapid changes have fired multiple events in openHAB and which one got acted on last is pot luck.
I reckon you have an electrical noisy switch, it happens. I’m a hardware guy so I would put a 0.1uF capacitor across the contacts.
However I also would expect that simply changing to debounce=100 will sort this out.