# \[SOLVED\] Displaying bme280 information

**URL:** <https://community.openhab.org/t/solved-displaying-bme280-information/55485>\
**Category:** Beginners\
**Created:** [November 2, 2018, 12:22pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485 "2018-11-02T12:22:36Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [November 2, 2018, 12:22pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/1 "2018-11-02T12:22:36Z")

</div>

- Platform information:

- Issue of the topic:  
Hello, I am using a phyton script to display the BME280 information in the console. the script is called bme280.py [https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python/](https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python/)

How Can I display these information in my openhab?? Sorry I started today with openhab and i can’t program

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [November 2, 2018, 12:39pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/2 "2018-11-02T12:39:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [November 2, 2018, 12:42pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/3 "2018-11-02T12:42:34Z")

</div>

GPIO binding is installed and how do O process further on??

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [November 2, 2018, 12:47pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/4 "2018-11-02T12:47:11Z")

</div>

Make sure openhab is a member of gpio group. If not add the group using  
`sudo adduser openhab gpio`

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [November 2, 2018, 1:04pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/5 "2018-11-02T13:04:30Z")

</div>

Here’s tutorial for setting up the RPI and using GPIO for one wire sensors. Their using a different sensor but the BME280 is one wire also.[https://community.openhab.org/t/gpio-1-wire-temp-sensors-on-raspberry-pi-with-openhabian/20941?u=h102](https://community.openhab.org/t/gpio-1-wire-temp-sensors-on-raspberry-pi-with-openhabian/20941)

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [November 2, 2018, 3:25pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/6 "2018-11-02T15:25:07Z")

</div>

> [@H102](#):
>
> Have you installed the GPIO binding and added the script to /etc/openhab2/scripts?

I just posted on this over on another thread [Exec binding PaperUI Thing with Parameter - #4 by rlkoshak](https://community.openhab.org/t/exec-binding-paperui-thing-with-parameter/55389/4).

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.

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [November 2, 2018, 3:33pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/7 "2018-11-02T15:33:03Z")

</div>

The bme280 ist a i2c device…Just to make clear

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [November 2, 2018, 7:11pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/8 "2018-11-02T19:11:55Z")

</div>

The bme280 can use either I2C or SPI…Just to make it clear. If you need further info regarding documentation just Google it.

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [November 3, 2018, 9:09am UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/9 "2018-11-03T09:09:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [November 3, 2018, 12:35pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/10 "2018-11-03T12:35:09Z")

</div>

@milo have you looked at the link I posted above. if so, what part are you having issues with?

---

<div class="post-metadata">

**Author:** ![Kees\_van\_Gelder](https://community.openhab.org/user_avatar/community.openhab.org/kees_van_gelder/32/17497_2.png) [@Kees\_van\_Gelder](https://community.openhab.org/u/Kees_van_Gelder)\
**Post date:** [November 3, 2018, 1:14pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/11 "2018-11-03T13:14:53Z")

</div>

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.

> [@Reading a DHT11/22 with 'overlay' and send result via REST API](https://community.openhab.org/t/reading-a-dht11-22-with-overlay-and-send-result-via-rest-api/44827):
>
> In an earlier tutorial I showed how to read the popular DHTxx sensor on a Raspberry Pi and then to MQTT that into Openhab. [https://community.openhab.org/t/reading-a-dht11-22-on-a-raspberry-and-send-the-results-by-mqtt/40582?u=kees\_van\_gelder](https://community.openhab.org/t/reading-a-dht11-22-on-a-raspberry-and-send-the-results-by-mqtt/40582) However, there are more ways to skin a cat So what I like to do this time is: Read the sensor with a device tree overlay on a Raspi and then Send the data to OpenHab with the REST-API I am not saying one method is better than the other, but suppose you …

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [November 3, 2018, 7:09pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/12 "2018-11-03T19:09:24Z")

</div>

Okay perfect thanks for the best helping but I got an error

```auto
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

```

```auto
requests.put('http://192.168.178.57:8080/rest/items/Sensor_BME280_humidity/state',humidity)

```

and

```csv
Number Sensor_BME280_humidity "Systemhumidity" [%f]

```

can you help ones more??

---

<div class="post-metadata">

**Author:** ![milo](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://community.openhab.org/u/milo)\
**Post date:** [November 3, 2018, 7:28pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/13 "2018-11-03T19:28:11Z")

</div>

> [@milo](#):
>
> ‘float’ object is not iterable

solved it with

```auto
humidity_string = "%.2f" % humidity

```

---

<div class="post-metadata">

**Author:** ![Kees\_van\_Gelder](https://community.openhab.org/user_avatar/community.openhab.org/kees_van_gelder/32/17497_2.png) [@Kees\_van\_Gelder](https://community.openhab.org/u/Kees_van_Gelder)\
**Post date:** [November 4, 2018, 6:37am UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/14 "2018-11-04T06:37:25Z")

</div>

great! so everything working now?  
If so can you indicate this post as ‘Solved’

---

<div class="post-metadata">

**Author:** ![semaf](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/f9ae1b/32.png) [@semaf](https://community.openhab.org/u/semaf)\
**Post date:** [June 19, 2019, 5:58pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/15 "2019-06-19T17:58:30Z")

</div>

Need some help here. The [tutorial](https://community.openhab.org/t/reading-a-dht11-22-with-overlay-and-send-result-via-rest-api/44827) 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?

` tfile='/sys/devices/platform/dht11@0/iio:device0/in_temp_input'`  
`hfile='/sys/devices/platform/dht11@0/iio:device0/in_humidityrelative_input'`

---

<div class="post-metadata">

**Author:** ![Kees\_van\_Gelder](https://community.openhab.org/user_avatar/community.openhab.org/kees_van_gelder/32/17497_2.png) [@Kees\_van\_Gelder](https://community.openhab.org/u/Kees_van_Gelder)\
**Post date:** [July 22, 2019, 2:05pm UTC](https://community.openhab.org/t/solved-displaying-bme280-information/55485/16 "2019-07-22T14:05:02Z")

</div>

> [@\[SOLVED\] Setting up BME280 sensor with Paper UI errors](https://community.openhab.org/t/setting-up-bme280-sensor-with-paper-ui-errors/69183):
>
> I got rid of all the old MQTT ver 1 stuff. Reloaded everything and installed the upgrades bringing me up to MQTT 2.5. I am trying to set up the BME280 sensor in Paper UI. I have made the main MQTT broker connection in Things and pointed it to my IP of the Rpi. I have set up a generic MQTT connection to the ESP8266 reading the BME280 using the Bridge connection to the main MQTT broker. I click on the Add channel button to add a number value so I can get the temperature reading. I add BME280-1T f…
