Hello openHAB community,
Just discovered openHAB and I’m hoping this community can point me in the right direction.
My plan is to monitor our boats in our boathouse with Raspberry Pi’s using various Grove sensors. Ideally I’m hoping to find a solution whereby my grove sensors can all “talk” to a Raspberry Pi gateway. The Raspberry Pi gateway will have VPN client on it so I can securely connect the Raspberry Pi to my home server. From my home server I’d like to have a local install of software that will talk to my Raspberry Pi gateway and control my various grove sensors. I like the grove sensors because of their ease of connectivity but I’m not married to only using grove. Ideally I’m looking for a way to make a grove sensor run on a small battery and last for a year or more and send the data ‘wirelessly’ to my Pi gateway. But that part of my setup is not for this community to answer.
Does this setup sound like something openHAB can help me accomplish with regards to installing openHAB on a home server and controlling through my Pi Gateway the various sensors or whatever else I decide to install? If so I’m more than willing to dive into openHAB and learn more but if anyone is inclined to point me in the right direction on where to begin I would be greatly appreciative of the head start!
Yes, this can be put to work in openHAB, but there’s multiple possibilities. You have to decide how.
The most common setup would be to run openHAB on your home server and have it talk MQTT to your local boathouse Pi.
That one can run another openHAB instance, but it could as well be just a simple python (or other) script to talk MQTT to the outside, or an Arduino or ESP8266 based sensor bank (with or without Pi inbetween). I guess your choice depends on the availability of interfaces of the Grove software, which I don’t know. If it can’t do MQTT, you could also use HTTP or remote command execution to access it from your home server.
I’d say that while OH may not be the perfect fit for this it isn’t a bad choice either.
Your challenge will be bridging from what ever you choose for your Grove communications (it looks like you have a plethora of choices from 433 MHz to WiFi) and the IP network your Pi is on. From a brief looking on the website they spend a lot of time talking about the hardware aspects, not so much on how to integrate it with things outside the Grove ecosystem. I’m not saying it can’t be done but it might take some doing.
Once you can set up the bridge between the Grove network and your Pi, you can basically convert the messages into a format that works for the other.
For example, I have an RFM69HW network. The Arduinos publish sensor readings and a Pi with an RFM69HW transceiver hooked up is running a Python script that picks up these messages, parses the values out, and publishes them as Strings to an MQTT topic. OH subscribes to these topics and updates its Items accordingly. When/if I do two way I’ll reverse the flow with OH publishing a message, the Python script subscribing to the message and publishing the message over the RFM69HW wireless.
I use MQTT largely because I was already using it for other things and it is super simple to set up and get working. You can also use OH’s REST API directly to have your bridge push Item updates directly into OH by making API calls.
The UI for OH is not super sophisticated though, which is one area where I wonder if OH is a perfect fit. You might want to look into something like Nagios which is designed more for monitoring devices than OH which is designed more for controlling devices. The over all approach would be the same though no matter what you use.
I suspect the 433 MHz will be more energy efficient but the WiFi will be way easier to integrate since you need nothing more than an off the shelf WiFi dongle on the Pi (or get a Pi 3 which includes WiFi).
Thank you very much for these replies.
A few more questions about using openHAB come to mind now.
Something new that we’ve just worked on is we’ve been testing using Tart Sensors(https://www.tartssensors.com/). These are small battery powered wireless sensors that talk to a gateway hat/addon that sits on a Raspberry Pi. Not as many sensors as Grove but still very useful. We’ve just received these Tart sensors and they are working very well for us in that we can have multiple sensors talk back to our Pi Gateway which collects all the data from each sensor.
- How would I take this data collected on the Pi and send all this data to our openHAB server (which is remote and not on the PI)? You mention that MQTT is used. Is this a hat or addon that needs to sit on the Pi or is this software that runs on the Pi and talks to our openHAB server?
- You also mention that I could use a script (python or something). I’m not familiar with python or scripting. Are there examples of scripts that send collected data to openHAB?
- What about a dashboard on openHAB? I read that I could use the openHAB rest API on a website. Are there examples of how this could be setup?
Thank you in advance for any more advice you can give me.
MQTT is a protocol that several IoT applications do can already talk to each other, openHAB being among them.
What you will need is that your Grove or Tart software (to read the sensors) can send sensor output in MQTT form to your openHAB server. If they cannot, you can either run a script on that gateway Pi (be it Python or any other script language) to do that for your, i.e. extract the sensor values and forward them to the openHAB server encapsulated in MQTT. Here’s an example that reads input from a Pi’s GPIO pins and forwards this in MQTT.
A third option would be to use the HTTP binding (= a software module running on the openHAB home server) to pull data from that openHAB server off a webserver running on your gateway Pi (I assume your sensor software will have a web interface).
But as you can see, there’s more than one solution, and it all depends on the software you want to run on the gateway.
Well, there’s no off-the-shelf dashboard, but you can tailor how your UI does look like. As a starting point, a demo set of items and a matching demo UI are provided as part of the default installation, see
sitemap directories. Further docs on UI config are here.
MQTT is software. It consists of a Broker program and clients. The Broker would presumably run on the same machine as your OH server, though not required. OH (using the MQTT binding) and your Pi Gateway would have software running using an MQTT library (Paho has an MQTT library for pretty much all programming languages and getting this set up, in Python at least, is about 20 lines of code).
OH comes with several UIs.
Or you have have or make a third party program that uses MQTT or REST.
Once you have OH 2 installed with the REST Docs you can find the API and test it out at the following link:
https://<ip address of OH server>:8080/doc/index.html
Just wanted to give a quick reply here to thank you all for your help! I’m blown away by how helpful you are being in your responses. There is a steep learning curve here for me to get my head around openHab and how to use it for my little IOT project. I will be back to ask more questions but in the meantime I thought I should be a little more clearer in my intended setup:
- In the boathouse I’ll have my Raspberry Pi (I’ll call it my gateway) with a Tart Sensor Addon.
- In the boathouse I’ll have my various Tart Sensors all talking to the Raspberry Pi.
- The Raspberry Pi and the Tart Sensors will not have a website running on them (at least I didn’t want to run any web interface). I want to limit the amount of software installed/running on my Raspberry Pi. My hope is to run the Pi using an O/S like dietPi (running all in Ram using Ramlog) so if the power gets pulled no damage done to the O/S.
- My plan was to have the Pi Gateway collect the data using Tart Sensor library/scripts. I’ve confirmed that the Tart scripts are working well in that they auto discover new Tart devices and with a simple update of the Tart config file will begin collecting data for me. So the Pi is talking and collecting data from the tart sensors.
- What I’d like to achieve is while the Pi is collecting the Tart Sensor Data, this sensor data is immediately sent from my Pi to my openHab server at my home. So I’ll have an OpenVPN server running at home and the Pi will have OpenVPN client running that is always attached to my OpenVPN server. Over this OpenVPN connection the Tart Sensor data will be transferred to my openHab server.
Now that’s my proposed setup…now I need to digest all your responses to see if what I plan to do can be done using either MQTT or perhaps python scripts to continually update my openHab database.
I’ll definitely be back soon with more noob questions.
Just to make one clarification, it is not necessarily an “either or” with MQTT and Python. I use Python scripts to publish the MQTT messages.
Did you have any success using the Tarts sensors with your project? I am considering doing something similar and haven’t been able to find a great deal of information on how to set everything up.
Let me know.