4 python script + i2c at one time

Hi, everybody
I found strange bug :frowning: I have four termo-sensors LM75, they connected to Rasperry
over i2c, and to read values i use python scripts. Everythink works Ok, if i start (manual from shell or openhab) scripts one-by-one. BUT, if i create 4 items whitch starts it’s own script, some times i have an error:

Error: Read failed
Traceback (most recent call last):
File “lm75_2f.py”, line 11, in
rawData = int(output , 16)
ValueError: invalid literal for int() with base 16: ‘’
And this error appeears not regular Once error have one script, then, since few minutes, error have another script. There is no any order. I think what there is a some “time lag” when i2c switch from one script to another. Becouse, when I change interval and timeout properties of items, so errors appears rarely.

Is it normal? How can i change this time delay, or maybe i use

String Temp_1f_it "real temp on 1 floor [%s]" (TempSensors) {channel="exec:command:4f2e900f:output"}
String Temp_2f_it "real temp on 2 floor [%s]" (TempSensors) {channel="exec:command:3ed52c8c:output"}
String Temp_outdoor_it "real temp on outdoor [%s]" (TempSensors) {channel="exec:command:4f2e900f:output"}

What version of openHAB? If the recommended version 2.5.2 what is the contents of your whitelist?

I think it’s likely that only one script can access the I2C device at a time. You see this error when two or more of your scripts are trying to access I2C at the same time.

There really is no way to prevent this using more than one script. You can make it happen more or less often but to completely eliminate it you need to only have one script that gathers all four values and then parse the four values out of the script in OH Rules.

1 Like

Yes, I think so.
Do you know is this feature of i2c or openhub? What do you think, if I create single script, witch will crate 4 files with values of sensors. And four scripts with wil read data from this files. Will it work?

Crackers. Have your one script send four values to openHAB in the same package.

Only one program can access any piece of hardware at a time. This is a universal limitation.

I agree, that’s a really ineffecient and brittle approach.

Just have your single script print out the four values and parse those four values and update Items in an OH Rule.