I want to integrate a I2C sensor connected to the RaspPI that is running OpenHAB (BPE280: temperature + humidity + pressure).
I’m looking for some guidance to start in the right direction since I’m new to OpenHAB.
In general my Java knowledge is rusty but I work daily with C# and I’m willing to dig deeper.
I have some java code to read the sensor data using pi4j.
What are my options to realize a native integration?
Is a binding the right way? Is an Action an option? What are other best practice approaches?
I don’t won’t a workaround solution via python or console command hacks…
However, it might be an option to write some kind of adapter to integrate the sensor via MQTT, but then it would not help anybody else…
I read the developer documentation but I’m unsure if I go with a binding in the right direction.
Welcome. On what machine are you running your openHAB? Would you want to connect the BPE280 directly to that machine, or do yo want/need the sensor remote from the openHAB machine?
In the latter case I would definitely recommend connecting the BPE280 to an Arduino or ESP8266/ESP32 and then using MQTT to integrate this small sensor setup. I have several such MQTT sensors/actuators, not exactly with a BPE280 though.
OpenHAB is running on a RaspPI V4 and I wanted to connect the sensor locally to the RaspPI.
I didn’t like the idea of another board if it’s not necessary.
I know I could write an app for the RasPI that maps I2C to MQTT, just thought there is a more elegant solution.
@hafniumzinc: Good tip with www.mysensors.org. Didn’t know that option. With native i meant: It could in theory be integrated in the official OpenHAB build.
AFAIK there is no native solution based on your definition. Besides MySensors, if you go with the ESP8266 approach, you can also try EspHome. It handles the software part for you. The sensors communicate with OpenHab through MQTT. Or you can roll your own C++ code as you mentioned. I also write my own code for the ESP8266 :).
Direct access to lower level bus is possible via third party libraries. There is no direct support for these in openHAB 2.x, however there is library called jdk.dio which is Java level interface for it. So far it did not become part of standard library so you have to obtain it from maven repositories hosted by Eclipse foundation: https://mvnrepository.com/artifact/org.eclipse.kura/jdk.dio.
This library is used in Eclipse Kura so there is pretty big chance it works just fine.