Have you installed the GPIO binding and added the script to /etc/openhab2/scripts? You will also need to create an item in the items file for the temp, humid, and pressure. A transformation addon such as JSON or REGEX may also be needed for OH to display the reading.
That folder is intended for openHAB Scripts, not external shell or python or such scripts. There used to be a problem when you put your external scripts in that folder that has long since been fixed, but the fact still remains that folder is not really intended for these sorts of scripts.
Hello yeah i know this that IT can handle spi and i2c… And I connected the bme280 to my i2c bus. So can you please help me how do I setup this device in my openhab to display the values via i2c?
Lots of good advice here, but if you have a running python script, then I guess there are two ways:
MQTT
REST API
both would require adding some lines to your program and if you use MQTT you would need to install and configure the MQTT broker as well, so maybe in your case REST API is the easiest.
In this post I explained how to do it for a DHT, but for the BME280 the part of the REST API works similar.
You would need 3 lines like: requests.put('http://192.168.xxx.yyy:8080/rest/items/<YOUR HUMIDITYITEM>/state',value) requests.put('http://192.168.xxx.yyy:8080/rest/items/<YOUR TEMPERATUREITEM>/state',value) . requests.put('http://192.168.xxx.yyy:8080/rest/items/<YOUR PRESSUREITEM>/state',value)
and you might need to install the ‘requests’ module in Python by
. .pip install requests
In your items file you then define an item like Number YOURHUMIDITYITEM "Humidity [%d] <youricon> etc for temperature and pressure. Use
‘f’ rather than ‘d’ if you want decimals.
Okay perfect thanks for the best helping but I got an error
Traceback (most recent call last):
File "./bme280.py", line 173, in <module>
main()
File "./bme280.py", line 171, in main
requests.put('http://192.168.178.57:8080/rest/items/Sensor_BME280_humidity/state',humidity)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 131, in put
return request('put', url, data=data, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 524, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 637, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 469, in send
for i in request.body:
TypeError: 'float' object is not iterable
Need some help here. The tutorial show how to read value by command line cat /sys/devices/platform/dht11@0/iio:device0/in_temp_input but this does not exist for i2c.
What is the way to call the values of the bme280 over i2c?