Help, Controlling the chip pcf8574 (Port expander) via I2C from Raspberry Pi from openHAB

I would love to get this binding to work.
Totall new to Rpi and OpenHab
pcf8574control

Fresh install RPi 3, all update run etc, i2c enabled and working.

2017-12-01 17:10:07.590 [ERROR] [org.openhab.binding.pcf8574control  ] - FrameworkEvent ERROR - org.openhab.binding.pcf8574control
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.pcf8574control [181]
  Unresolved requirement: Import-Package: org.openhab.core.binding
	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]

In karaf console i idid a “feature:install openhab-transport-serial” not sure why, red it some where,

openhab> bundle:list | grep openHAB
166 | Active    |  90 | 2.1.0                  | openHAB Core
167 | Active    |  80 | 2.1.0                  | openHAB Karaf Integration
169 | Resolved  |  80 | 2.1.0                  | openHAB Sound Support, Hosts: 111
170 | Active    |  80 | 2.1.0                  | openHAB Dashboard UI
178 | Resolved  |  75 | 2.1.0                  | openHAB Basic UI Fragment, Hosts: 176
180 | Resolved  |  75 | 2.1.0                  | openHAB Paper UI Theme Fragment, Hosts: 177
181 | Installed |  80 | 1.0.0                  | openHAB PCF8574Control Binding

But item Contact led { pcf8574control=“38;0;out” } wont work,
python code;
i2cset -y 1 0x38 0xFE
i2cset -y 1 0x38 0xFF
will toggle the Led

https://docs.openhab.org/developers/development/compatibilitylayer.html#how-to-use-openhab-1x-add-ons-that-are-not-part-of-the-distribution

How to use openHAB 1.x Add-ons that are not part of the distribution

While the openHAB distribution already contains many add-ons of openHAB 1, there are still quite some of them missing - please help testing them - if they are confirmed to be working, they can be included in the distribution. Test a not included add-on is very straight forward:

Start your runtime
Install the 1.x compatibility layer by running feature:install openhab-runtime-compat1x in the openHAB console
As with openHAB 1.x, simply take the jar file of your add-on and place it in the ${openhab.home}/addons folder.
Copy your personal openhab.cfg file to ${openhab.home}/conf/services/openhab.cfg.

If that’s the solution?
Then I only have todo;

feature:install openhab-runtime-compat1x in the openHAB console
Then take the jar file of your add-on and place it in the ${openhab.home}/addons folder.

I think i dont have to do anything whit openhab.cfg file?

That’s what the readme of the binding says :grinning:

reinstalling oh2,
so will test soon if it will work.
But how could i know it was a old binding?

Because it is not listed in the docs:

http://docs.openhab.org/addons/bindings.html

2017-12-01 19:29:06.276 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/led' with an invalid status value 'ON'.
2017-12-01 19:29:07.085 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/led' with an invalid status value 'OFF'.

Item type Contact does not accept ON/OFF, only OPEN/CLOSED, use a Switch item.

Oke the error is gone,
but the led won’t go on, nor the motion sensor updates

What is it I’m missing here

[19:33:34] openhabian@openHABianPi:~$ i2cset -y 1 0x38 0xfe
[19:33:54] openhabian@openHABianPi:~$ i2cset -y 1 0x38 0xff
works,

items;

Contact motionSensor { pcf8574control="3c;0;in" }
Switch led { pcf8574control="38;0;out" }

sitemap

sitemap default label="My first sitemap"
{
  Switch item=led
  Text item=motionSensor label="motionSensor: [%s]"
}

I really hope this or a other way is gonna work, I have a almost complete wired system in my house

Sorry, I have not the slightest idea, I’m not using that binding …

It looks like the developer does not maintain the binding anymore:

i did see that, to bad it isnt working.

please someone how to connect wired push buttons, a lot of them and other inputs door window pir etc all wired

Search the forum for I2C, there seem to be a couple of options to do that.

read most of them, but i was hoping to use the hardware i have.
will surly read more, but any pointers are of course welkom

From your first post I assumed you have I2C compatible hardware.

it is, most of the hardware is i2c based,
I am at this for for a week or so read trying.
for what i think now is that maybe OH is not my environment, mostly al of it is wireless.

any suggestions what i could look into next?

pimatic.org
maybe Pinmatic on a second pi OH om other Pi, Pinmatic isnt that good in DMX, and i would love to have DMX up and runing to

is there then a good way to communicate between them? or should i use a Aduino?

I am very new to all of this

Hi,
My homenetwork is a i²c bus running all over the home. Mostly I use pcf8574 bidirectional ports. Nodes are installed at the places in need for controlling. This bus is controlled by some code written in python, running on PI3 side by side with OH2 and MQTT.
OH2 is talking to MQTT which on it’s turn talks to python, driving the i2c bus.
I took me a long time to get it working due to the wrong address.
Maybe this could help you;
i2cdetect -y 1 gives you a list of all addresses hooked up to the bus.

By the way, where did you find this binding “pcf8574control” as I couldn’t find it.

2 Likes

Oh wow,

pcf8574control

please tell me how to setup your system, its all i need, I2c is up and running, np there only binding it all together
is the goal here.

[00:39:56] openhabian@openHABianPi:~$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 39 3a -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

MQTT Binding need to be installed. I have done this with the paper UI in the binding tab; OH needs to publish message, so MQTT Actions is installed at the actions tab.
From that moment it is possible to send and receive mqtt messages with OH. mqtt has been developed to transfer data in a most effective way. See the net for additional info on MQTT.

Items data looks like this:

Switch gar 		"Garage" 		<garage> 		(Lights) 			{mqtt=">[hoco:home:command:ON:gar1],>[hoco:home:command:OFF:gar0],<[hoco:home:state:ON:garst1],<[hoco:home:state:OFF:garst0]"}

The gar0 and gar1 is collected and processed by the python program.
The garst0 and garst1 is the status comming from python.
The “>” sends a message; the “<” receives a message

Probably I will stay with the mqtt setup, as the pcf8574 is only one item part off the i²c circuits available. Python gives the possibility to use other i²c circuits, more complex units, such as volume and equalizer circuits and led/display controllers and many more…

Rik

Dear Rik,
Can you say something more about the communication rules in your method? How do you define the right pin of pcf8574 module with your method? Did the python code is your own specyfic one for your home system and the “transating” part of comunication with MQTT using?

Hi Marcin,
Do you mean the rules in OH or the protocol used between OH<==>mqtt<==> python?
A pcf8574 consist of a byte wide latch; by using a number between 0 and 255 it is possible to select one or more pins on the IC (some info http://www.ti.com/lit/ds/symlink/pcf8574.pdf)
all pins can be used as input or output pins. The here above pin gar0/gar1 is used as an output, the garst0/garst1 is used as input. By sending a command in OH it will set(ON) or reset(OFF) the pin. This is reflected on the input pin. OH reads the remote switch.
Off coarse this needs to be translated by the python program. How this is done can be seen in the python code. We will try to distillate the communication part, but need some time to prepare it and will post it here.