Heh, I’m not really into the whole “instructable” style thing but would be happy to share parts or all of my sketch and wiring. I basically sifted through a couple of different blogs and library examples to piece together my stuff anyway. I’m not a programmer or a electrical engineer so I have to figure out as I go on both sides.
I’m actually still finishing up the project at this point so the code will change more and I haven’t taken the time to properly comment and clean it. I dumped my current code here: Arduino code. I’ll try to update it as I finalize the code.
The .items are here: MQTT items
I’m using an arduino mega with ethernet shield. The sketch is too big for an uno. My project basically has 3 relays on a relay board, Motion Detector, Pair of DHT11 (will be upgrading to DHT22, the 11 isn’t accurate enough), an IR receiver and a relay (driven by my doorbell) to drive a pin to ground. The wiring is all super standard and follows any of a million examples easily found by searching each sensor.
I wrote handlers to listen to and update OH via MQTT for the relays, temp sensors, motion sensor and doorbell.
The automation logic is split between the arduino and OH. Some things I choose to have the arduino make decisions about such as turning on/off the sub (don’t want to wait for OH to respond) where as other things like room temperature is reported to OH and OH decides when to turn on the fan in the room. That being said, I started automation with vera and z-wave. Z-wave has nothing on the speed of this arduino with mqtt… nothing close… it’s super fast.
The IR stuff is separate from OH for the moment. It simply turns my sub relay on and off. The action of doing so does send mqtt back to OH to let it know the sub is on. As for the harmony hub, I setup a new device and just put in a manufacturer and model I knew wouldn’t be in their list such as my subwoofer which doesn’t have IR so obviously would be missing. It asks if you have the original remote… say yes… find some junk remote you know doesn’t interfere with other devices you have, choose buttons on it to “map” to on/off and have it learn them. I used this IR example to spit out the code. You can see a case statement in my sketch that listens for and handles receiving those codes.
Please let it be known that I reused several code snippets from all over the web. I’m not in any way passing this off as all my work. I just pulled it together and customized it. I can’t keep track of all the places I found BUT, I want to link to here. This guy who is likely a member of this forum really helped a lot with the MQTT stuff. The blog has a lot of extra stuff going on but if you run through the first three parts, I pieced it together.
Let me know if you have any questions, I would be happy to help you with your project. Sorry for the brain dump, I’m a tech guy not a tech writer