OpenGarage › Forums › Comments, Suggestions, Requests › MQTT and OG
Tagged: MQTT
- This topic has 28 replies, 6 voices, and was last updated 7 years, 4 months ago by Gompka.
-
AuthorPosts
-
October 13, 2016 at 9:16 pm #105
AnonymousGuestI figured that having MQTT support might be of use to a few people, including myself. The addition of MQTT was pretty trivial (using PubSubClient http://pubsubclient.knolleary.net/)…thus far. Is this something you want to incorporate into the released version? If so please let me know I’m happy to share what I have.
October 16, 2016 at 3:44 am #154
RayKeymasterI am not very familiar with MQTT (followed a few tutorials and so on). Please share what you have, and we are definitely interested in incorporating MQTT into future firmwares. I am sure many users would appreciate it too.
December 29, 2016 at 9:00 pm #278
tomgleParticipantI have been playing with MQTT and some MQTT topics for open Garage as well. I’m also tossing the blynk stuff and cloud integration overboard and hopefully will use Nodered in it’s place. I have the open Garage hardware and am anxious to program it with straight Arduino code without nodemcu or esptool. Can I do that without bricking the thing? I’m hoping I can eventually program it like an Adafruit Huzzah i.e. hookup the programmer and upload it straight from the IDE.
January 3, 2017 at 7:47 am #282
RayKeymasterYou should be free to explore without worrying about bricking the thing — ESP8266 comes with a built-in bootloader that’s very robust. I’ve never seen a case where the bootloader is corrupted. Because OpenGarage firmware supports over the air (OTA) update, there is actually no need to update firmware through the USB cable — of course you still need the USB cable to provide power — but the firmware can be uploaded through the webpage. Also, OpenGarage firmware is written in Arduino with ESP8266 core, it does not use Lua / nodemcu at all.
- This reply was modified 7 years, 10 months ago by Ray.
January 3, 2017 at 10:52 am #284
chickenmadParticipantWould love any code you have as a starting point and would share back what I make. I have an audio notification that announces the garage door as opened and MQTT would align with the ESP8266/nrlf24l01 sensor network in the greater house.
Also – as the device is overhead i use the distance as a triple state – distance to garage door = open, distance to car roof = closed and dads car is home, distance to floor is closed and dads car is gone. Had to move the sensor to be directly over the flat part of my Suburban as over my wifes MDX the reflection would cause the readings to be all over the place.
Garageio appears to be similar to this product but using a laser mounted to the bottom of the garage door opener. I am ordering a PIR sensor and using it with an 8266 to see if I can sense when a car is approaching the garage and alert that someone has arrived (we have no windows to see our driveway)- This reply was modified 7 years, 10 months ago by chickenmad.
January 6, 2017 at 12:45 pm #290
GompkaParticipantAlso interested in the mqtt code, would like to run my own mqtt server instead of relying on blynk.
January 15, 2017 at 3:23 pm #300
DynamoBenParticipantI have had working MQTT code for a few months now. What is missing at this point is the UI config options. If someone wants to work on that part I can post my code someplace. Just let me know.
NOTE: I’m sending unencrypted messages to the server, I’ve not tried to do anything with TLS.
- This reply was modified 7 years, 10 months ago by DynamoBen.
January 19, 2017 at 5:27 pm #318
GompkaParticipantBen if you could send me your code or upload it here i would appreciate it. My email is [email protected]
January 22, 2017 at 5:37 pm #322
DynamoBenParticipantWill do, however I tried merging the latest changes to the project with my code and now it’s broken so I need to fix that first.
- This reply was modified 7 years, 10 months ago by DynamoBen.
January 22, 2017 at 11:59 pm #324
DynamoBenParticipantOK things are now functional; the rearchitecting of Blynk threw things off a bit.
This is the latest version from Github with MQTT added. The only files that change are main.cpp and you need a modified Arduino parent file (it needs the PubSubClient include).
The MQTT server IP is at the top of main.cpp along with the topic, you will want to update those (if you are doing access control username/password are there too). If “Button” is sent on the topic then the door will be activated; this is hardcoded right now so if you need to change it it’s in “void mqtt_callback.”
It’s worth noting that I’ve hard coded the MQTT port number to 1883 (the default), if you are using a different port you will need to change that too.
Enjoy and let me know if you have any questions.
- This reply was modified 7 years, 10 months ago by DynamoBen.
- This reply was modified 7 years, 10 months ago by DynamoBen.
Attachments:
You must be logged in to view attached files.January 23, 2017 at 12:07 am #327
chickenmadParticipantAwesome thanks!!!
January 23, 2017 at 10:05 am #329
GompkaParticipantBen thank you for the code, it will same me a lot of time and swearing lol. I will load it up when i get home and let you know how it goes.
January 27, 2017 at 5:50 pm #332
DynamoBenParticipantI’ve added distance, the only file that changed was main.cpp. Enjoy!
Attachments:
You must be logged in to view attached files.February 2, 2017 at 1:59 pm #349
GompkaParticipantHey Ben, thank you for the files, i compiled and uploaded and seems like everything opengarage relate is working but i’m not getting anything on my mqtt broker. The topic is just “GarageDoor” right? I changed the mqtt server and added my username and password, am I missing anything else?
February 2, 2017 at 2:28 pm #350
DynamoBenParticipantYes just “GarageDoor” no slashes. Also its worth noting that I’ve not tested user/pass since I’m not doing access control on my server at the moment.
February 2, 2017 at 2:30 pm #351
GompkaParticipantBen, I have a spare esp8266 that i will rig up as a pseudo open garage so that i don’t have to run back and forth to the garage when its 14F here in Chicago lol. I’ll do some testing and report back. Thanks again.
February 14, 2017 at 10:47 am #373
chickenmadParticipantGompka and DynamoBen – using the Arduino IDE and getting errors of:
redefinition of ‘BlynkWifi Blynk’
main.cpp:519: error: ‘class UpdaterClass’ has no member named ‘reset’
main.cpp:815: error: no matching function for call to ‘BlynkWifi::begin(const char*)’
and others….assuming I have the wrong libraries loaded or IDE wont work here….my brain tells me this is something really obvious and dumb.
February 14, 2017 at 10:50 am #374
DynamoBenParticipantHave you done the Blynk modification?
https://github.com/OpenGarage/OpenGarage-Firmware/tree/master/Modifications
February 14, 2017 at 2:34 pm #375
chickenmadParticipantnope and that would explain it!!!!
February 21, 2017 at 10:03 am #389
GompkaParticipantBen, i removed the user/pass and it seems to be working. Not sure if it was just the user pass or the way i have mosquito setup. Anyway, now that open garage is publishing to mqtt the issue i’m having is the distance variables it is printing are strange. I have it on my test bench and sitting stationary and it publishes 147, 256, 145,260 and like that back and forth which causes open/close/open close messages. However, if i go to the built in OG webpage that Ray made the distance is a steady 147 and the status stays closed. Any idea, what could be causing this strange distance behavior?
February 21, 2017 at 10:41 am #390
DynamoBenParticipantI’m not sure what the root cause might be; I’m using the same variable (“distance”) that is being written to the log, webpage, and to Blynk.
On mine I’m seeing the number move a little (from 145-147) but not wide changes like you are seeing on your bench.
February 21, 2017 at 1:05 pm #391
GompkaParticipantI’m not sure what the root cause might be; I’m using the same variable (“distance”) that is being written to the log, webpage, and to Blynk.
On mine I’m seeing the number move a little (from 145-147) but not wide changes like you are seeing on your bench.
Ben, OG is setup to take readings every 4 seconds via the webpage, however it looks like mqtt is reporting readings every 1 second. Do you know how to get mqtt to publish every 4 seconds and so i can test if this fixes the issue?
- This reply was modified 7 years, 9 months ago by Gompka.
February 21, 2017 at 1:15 pm #393
DynamoBenParticipantOG is setup to take readings every 4 seconds via the webpage, however it looks like mqtt is reporting readings every 1 second. Do you know how to get mqtt to publish every 4 seconds and so i can test if this fixes the issue?
I put the MQTT publish commands in the same function as the OG readings (void check_status()), so if you are set to 4 seconds it sends every 4 seconds. Not sure why you are seeing 1 second updates.
Sounds to me like there are bigger issues going on that are outside the MQTT code changes, I’m wondering if the issues have to do with your Mosquitto server config or maybe another device is publishing to that same topic? Not sure.
February 21, 2017 at 2:06 pm #394
GompkaParticipantBen, i think you just nailed it. I put your mqtt code on my main opengarage that is setup in my garage last month, but it wasn’t working. I am now working with another open garage on my test bench, and i just realized that now that mqtt is working, i bet that both open garage units are sending mqtt messages to the same topic. I will test this when i get home. Thanks for your help, its always the simple things that cause these issues lol. I am learning a great deal as I go thought.
That is exactly what is happening, they are both publishing to the same topic! I was able to log in remotely and take a look. I will report back once i change the topic names, i’m certain things will work properly though. Thanks again Ben!
April 5, 2017 at 10:47 am #418
GompkaParticipantI have been using your mqtt addition with home assistant for 2 garages for over a month now and it is working flawlessly. Thanks again for the help Ben!
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenGarage › Forums › Comments, Suggestions, Requests › MQTT and OG