Home Automation Newbie

Hello to all,

I’m after some advice and some initial pointers in the right direction.

I’ve been playing with Raspberry Pis and Arduinos for a little while now playing with buttons, sensors, relays, etc. I’ve even bought a roller shutter door sensor as below and written a simulation for sensing when our garage door is open / closed.


Now it’s time to progress a bit further and make these “Real World” solutions and hence I’ve stumbled upon openHAB. I’ve played around a bit the last couple of days to get familiar and it’s good as now it looks like I have a handy platform to check and notify me if my webserver goes down :slight_smile:

I have a working openHAB server on a Pi3, I’ve also installed Mosquitto and subsequently have the MQTT Broker connected.

So my next conundrum is how I get my thus far standalone garage door systems connected and “talking” to openHAB, and this is where I could do with an experienced voice please.

My queries are:

  • How do I get the Arduino (nano or uno) to connect to openHAB? If this is even possible!!!
  • My research has highlighted another possible platform, the ESP8266 or ESP32. What are these? Are they like a slimmed down version of the Arduino but with inbuilt WIFI?
  • Can you program the ESP8266 like the Arduino?
  • Is there a steep learning curve moving from the Arduino to the ESP8266 or are they much the same?
  • Is moving platform even what I should be looking at?

Initially all I want to do is display in openHAB whether the Garage Door is open, i.e. the sensor is open or closed much the same as the Network Binding shows whether a device is on or off. Hopefully from there I’ll be able to fly as I’m sure working back the other way to control the opening will be a logical step.

I have tons of Raspberry Pis knocking around so could use one of these to get going or to learn, but long term it seems that having a Raspberry Pi running for a garage door sensor and switch seems a little overkill.


  • Platform information:
    • Hardware: RaspberryPi 3 Model B
    • OS: Raspbian Stretch
    • Java Runtime Environment: Java™ SE Runtime Environment (build 1.8.0_65-b17)
    • openHAB version: openHAB 2.4.0 Release Build

Hey welcome to the forum :slight_smile:

Your questions are mainly about IoT platforms and not so much about openHAB. There is an own category for this here in the forum.

To answer some questions:

When the ESP8266 came out, it had way more CPU power and memory then the normal Arduinos. Nowadays there are also x86 and Arm Arduinos though, so the distinction is hard to draw.

Yes. See https://github.com/esp8266/Arduino

But if you are still using the Arduino IDE you must like pain a lot. Nowadays you would use Visual Studio Code or Atom with PlatformIO. The later one allows you to pull in libraries for example MQTT which allows you to easily talk to openHAB.

Cheers, David

Hi and welcome to the world of openHAB. OpenHAB is extremely flexible so you could link the sensor in many ways. MQTT is widely used and others can advise. What you actually choose will probably depend on what else you want to do in the future. I pick up such sensors by linking them using z-wave. So in this method you need a usb z-wave dongle eg https://www.vesternet.com/z-wave-me-usb-stick then a z wave sensor such as this https://www.vesternet.com/z-wave-fibaro-universal-sensor. I went the z wave direction as it is pretty solid on reliability and there is a good range of options.
In openhab “speak” the universal sensor s a “thing” and each input can be linked as items which can be displayed and use as “items”. I use a setup for similar things to your garage door sensor for door sensors and also a doorbell - the latter can do anything from flash a light, speak or send a messsage with a cctv snapshot to our phones.

Yes you can with an Ethernet shield. With MQTT code on the arduino and send payloads though the networks.
You could also connect the arduino serial port to the raspberry pi serial port and talk through that. With openHAB with the serial binding.

As David mentionned above. ESP8266 when is came out was much more powerful than an arduino UNO for example BUT the number of IO is lower. The ESP32 is very powerful indeed. There are now arduinos with the same kind of processing power. ALL the ESP have Wifi and the ESP32 also has bluetooth (But it’s WiFi OR bluetooth NOT both)

Absolutely. There are thousands of examples on the tinternet.
Although the arduino IDE is a bit clunky, If you are comfortable with it you can easily set it up for ESPs. Again there are 100s of tutorials on how to do that on the interweb.

Much the same…

Depends what you are using the hardware for. If there is easy access to the network, then stick to Ethernet. You can even use PoE to bring power to your arduino that way.
If access to the LAN is difficult then ESPs are ideal.


Thanks, I was a little concerned that after being used to the low level speed of the Arduinos that using the ESPxx range would be a compromise in power / speed just to get the WIFI capabilities, but it sounds like that’s not the case.

I think I’ll take a closer look thanks :+1:


Thanks for the info Mark, whilst I have no experience of it I’m a little against the idea of going down the Z-Wave route (or any other proprietary system) at the moment mainly because of cost. I can definitely see the benefits of such a solution least not there’s bound to be a high level of reliability, but half the fun of this for me is the learning how to design and code my own Things, which is why I’m currently in the conundrum of how to connect.

You say about your garage door setup, do you mean that’s using Z-Wave or you’ve made your own Things?


Thanks for all the great info, specifically addressing my queries.

I knew about the Ethernet shields and thought that might be a solution but similar to me steering away from Z-Wave as per @markle suggestion I didn’t see the point of the added cost involved considering I have tons of Pis knocking around which have inbuilt Ethernet (yes I know the RPi has a bulky OS which interrupts and slows the low level processing response times but this isn’t going to be that critical).

This is great to know. For the cost of the ESPxx system the reduced number of IO is not going to be an issue as I’d be looking at one board per sensor / switch anyways purely because of locality of each sensor anyway.

I have both wired Ethernet and WIFI running throughout the property but looking long term I’m likely to have sensors and switches everywhere so I like the idea of WIFI enable ESPs otherwise there’s going to be cable everywhere.

And especially as the garage is detached from the property and I have no wired Ethernet running to it at present.

Just to clarify for anyone who’s been kind enough to help or take the time to look.

Long term my aim is to have openHAB:

  • switch on and off devices and lights - the Sonoff look’s a good option and is “cheap” :smiley:
  • monitor if we’ve left the garage door open - possibly give us an alarm “if the door is open after a set time” - ESPs appear to be winning for this but happy to be persuaded otherwise
  • allow us to open / close the garage door - it’s already motorised so that won’t be too difficult to interface with - again ESP with a simple contact should do the job
  • after this then I’ll get more adventurous, we have solar panels with smart meter, I’ve already connected to the serial data with an Pi but I could possibly use this data in openHAB to switch on devices like the dishwasher when we’re generating a surplus
  • I have a weather station so some of this data will be handy
  • especially as we have an allotment so an irrigation system would be handy :slight_smile:

See, I’m going to be a busy boy for a while so would love to share some ideas with you all, and hopefully soon I can be the one sharing some solutions and code :+1:

  • An Ethernet shield and MQTT libraries
  • An ESP8266 (https://medium.com/@cgrant/using-the-esp8266-wifi-module-with-arduino-uno-publishing-to-thingspeak-99fc77122e82)
  • Serial connection to a computer like an RPi that acts as the gateway to the Arduino(s) to your IP network. I think the Serial Binding can work if that gateway computer is running OH, though you would probably have better luck with writing this in Python.
  • Some other wireless connection like RFM69HW. You will still need a gateway machine but this gateway can be an Arduino or a single RPi and they don’t need to be wired directly to all the Arduinos.

You can think of them like that. They are really popular because they are so cheap and if you get something like the NodeMCU versions there are plenty of easy to use GPIO pins. They are tiny too. Unless you have the need to drive 5V or need a ton of GPIO or have really complicated firmware, it is probably the best tool for the job.

Yes but most users will use Tasmota, ESP Easy or one of the other premade firmwares that allow for OTA updates and configuration through a web interface. Why code when you can configure?

This combined with actually controlling the opener was my first home automation project. I used an RPi as the controller. I might replace it with an ESP8266 at some point, but I’m also running a camera off the RPi so maybe not.

An ESP8266 running Tasmota or ESP Easy would be the way I would recommend.

Unless you have other jobs to give it. :wink: I also used my RPi for a time as a sort of BT proximity sensor to help with presence detection. I don’t need to do that any more so I’ve since stopped using it for that. But it is still serving as an IP camera.

Also consider the Shellys. Also cheap but the Shelly 1s will let you turn dumb light switches into smart light switches.

When you are ready, search the forum. I’ve posted my OH Rules code for this at least half a dozen times.

All you need is a relay wired to the controller and the wall button for the opener. If you get an ESP, make sure to get a 3.5v controllable relay, not the 5v ones because the ESP doesn’t have a 5v power out (at least the NodeMCUs don’t).

See the Cascading Timers DP posting when you are ready for those Rules.


Thanks so much for the information there’s some great ideas in there, some I’d thought of and some I had no idea about.

Coincidentally I watched a great video earlier tonight which was a comparison of the shelly1 vs Sonoff so it was good to hear that others on here recommend the shelly too but I’ve ordered a Sonoff from China so I can experiment with that at some point (again price won out for me) :moneybag: :

I’m definitely going to search for your garage code in the morning as this sounds like it could be a great starting point. I don’t actually have a wall button at the moment but that was on the to do list anyway so might become part of the project.

There’s been some amazing help on here tonight and I just want to thank everyone, it definitely looks like I’m going to order an ESPxx and have a play and in the meantime I think I’m going to fire up another Raspberry Pi as the controller in the garage just so I can play some more with openHAB and start to experiment with the rules.

Clearly I’ve found a great solution with openHAB if the community is this great :trophy:

1 Like

You can write it directly to the opener if you need to. the relay basically simulates someone pushing the button.

I may be biased but I think we have the best community around. Welcome aboard! :passenger_ship:

To answer the z wave question - I do use those components - I went z wave due to my legacy setup (Vera - never going back!) based on z wave the number of mains switching devices and need for the automation to be discrete.
I’ve done the solar panel integration, initially using the http binding and fronius API and latterly the fronius bonding - it’s rock solid and as you are thinking having it control when to run dishwasher, car charger, washing machine etc is quite easy. Do give some thought to integrating the forecast weather - this was somthing I missed in the early days. (The weather forecast allows you to predict when you might get how much power - for example there’s no point in delaying the washing of there’s no hope of a surplus later). Also look at the section on persistence - it’s very useful for measuring the energy consumption profile of all sorts of things. Based on that not only can you control the power usage of a device you can also report where it is in its cycle - example if I’m home the washing machine sends a pushover message to my phone to tell me it’s done). Have fun!

1 Like

@barracuda Welcome to openhab! I am also just getting started. My Raspi is running with openhab and I got an ESP8266 here on my desk. Lets work the magic. I look forward to hearing more on your progress and getting inspired by it. :slight_smile:

Hi @Freiheit, I’ve just ordered some ESP8266, in the meantime I’m using a spare Raspberry Pi.

This morning I’ve set the Pi up to run a Python script which subscribes to a MQTT topic and turns an LED light on and off depending on the payload of the MQTT message which I send from a standalone client.

Now I’m trying the next step which is to get openHAB to publish the message so OH is switching the LED on and off but I’m struggling with trying to get an MQTT Thing configured.

I might have to resort to text configuration but all the docs, etc suggest it should be possible to do from PaperUI but I can’t get past configuring the MQTT broker which is ONLINE.


Continuing the discussion from Home Automation Newbie:

Hi @barracuda,

great to hear from you! You are way ahead of me. I also want to use MQTT.

I am currently trying to connect a DHT11 temperature and humidity sensor with the ESP8266.

Was not able to program the ESP8266 as all my Chinese Arduino Nano replica uses the CH340G usb to serial chip instead of the FT232RL. I was not able to install the drivers on my windows or linux machines.

I now got an original nano and will let you know how I get on. Keep GOING. MQTT broker will bend to your will soon.

You need a Generic MQTT Thing with a Switch channel. Paper UI is not that easy to use, that is correct, but believe me there are more pitfalls with textual configuration.

A small typo and your item file does not match with your thing file and you will spend 5 hours to debug that. While Paper UI will always create working items for you (just an advice: don’t use auto linking. to be found on the configuration page).

Cheers, David

Thanks for the advice David. That was exactly what I was trying to create but for some reason when I went to Configuration > Things > + MQTT Binding > Add Manually (no auto detection) > ??? I was getting an empty list, there was nothing to select.

When I went back to it the next day to have another go (I would have turned off the RPi so a reboot would have occurred), I was finally getting the list of Things to select, from which I could finally select Generic MQTT Thing and from there it was fairly plain sailing as I’d done my reading up already.

As for textual configuration I’m trying to use PaperUI as much as possible, mainly because I don’t yet know the text config syntax yet, but alas the old school in me does like the control of the text config as I know exactly what’s going on. But I get what you say about the debug, I’ve been there before :sob:

I assume you mean Configuration > Item Linking > Safe Mode? I actually have this on at the moment, at the recommendation of the Docs / Tutorials for beginners and so far it’s been good. The only downside is the naming convention it uses. I’m sure once I’ve played some more with Items and Sitemaps that’ll be the next thing I turn off and configure myself.

Thanks very much for the Binding, it works great and I’m sure I’ll be using it a fair bit as I start to build my own devices :+1:


I got the MQTT working in the end. It wasn’t too painful when I went back to it the next day as I was finally able to select Generic MQTT Thing which wasn’t there before.

Once I was able to create the Thing all was well. I’d already tested my MQTT device from a standalone client so I knew that worked, and as soon as I had created my Thing, and subsequent “Switch” Channel it worked first time :smile:

Good luck with your project, I’m going to be doing similar soon. Any problems with the MQTT post back to the community or feel free to get in touch and I’ll help if I can.