Local MQTT broker on esp8266

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Local MQTT broker on esp8266

#1 Post by happytm » 23 Sep 2017, 01:36

Hi all,

I am trying new MQTT broker on esp8266.

The broker code is located at https://github.com/martin-ger/esp_mqtt.

Iam using what the developer of this code call fast-and-dirty hack.I was able to get broker running and tested with MQTT Spy
software.Mqtt spy connect to this broker but when I try to connect from other Espeasy device using different controller protocols it fails every time giving me message :

MQTT : Connection lost
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker

But odd thing is on my MQTT Spy software I get following on topic /livingroom/status :

/livingroom/status with message Connection Lost.

So broker is connecting Espeasy device called livingroom with my MQTT Spy client.But there are no other messages exchanged.
every minute I am publishing IP from my livingroom device using rules from Wiki.

I believe this local broker will be very useful when there is no internet connection to use device on LAN without deploying any other hardware for MQTT broker.

I tried to resolve this by changing some code in controller.ini file but was not able to solve it.

Please help me resolve the problem.

Ken

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Local MQTT broker on esp8266

#2 Post by AndrewJ » 23 Sep 2017, 09:16

One thing I can suggest to check (from bitter experience! ;) ).
Make sure that the client name is different in each ESP or other device connecting to your MQTT broker. Otherwise it won't work.
Hope this helps.

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Local MQTT broker on esp8266

#3 Post by papperone » 23 Sep 2017, 11:02

Having said that you don't need internet connection to use any MQTT broker, as I do run happily one on my Raspberry Pi and it works even with just internal Lan...
Project is interesting to check as it can bridge to an existing broker, so can be nice as a backup not to stop any of my home automation devices/automatism while I'm doing maintenance or upgrade to the main server/broker :)
thanks, will look into it!
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Local MQTT broker on esp8266

#4 Post by happytm » 24 Sep 2017, 08:09

#2 Post by AndrewJ » 23 Sep 2017, 09:16

One thing I can suggest to check (from bitter experience! ;) ).
Make sure that the client name is different in each ESP or other device connecting to your MQTT broker. Otherwise it won't work.
Hope this helps.
Right now I am just testing with 2 esps and there is only one client with espeasy firmware & another esp is using mqtt broker sketch with generic advanced webserver example from arduino ide examples. but thank you for the pointer.
#3 Post by papperone » 23 Sep 2017, 11:02

Having said that you don't need internet connection to use any MQTT broker, as I do run happily one on my Raspberry Pi and it works even with just internal Lan...
Project is interesting to check as it can bridge to an existing broker, so can be nice as a backup not to stop any of my home automation devices/automatism while I'm doing maintenance or upgrade to the main server/broker :)
thanks, will look into it!


You are right about working without internet.But it is still good choice to have relatively less power consuming device with 1/4 of price of RPI W for location like remote cabin in woods or vacation home etc. for local control using rules engine.



Top
papperone
Normal user
Posts: 257
Joined: 04 Oct 2016, 23:16
Re: Local MQTT broker on esp8266
Quote

Top
Post Reply
3 posts • Page 1 of 1

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Local MQTT broker on esp8266

#5 Post by happytm » 29 Sep 2017, 01:14

I found another MQTT broker on espeasy which is little easier to implement at iotcentral.eu.

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Local MQTT broker on esp8266

#6 Post by papperone » 29 Sep 2017, 06:43

happytm wrote: 29 Sep 2017, 01:14 I found another MQTT broker on espeasy which is little easier to implement at iotcentral.eu.
this looks like just a bridge between local network and an a cloud based broker... I prefer the previous solution you highlight (that I still need to find time to test it!)
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Local MQTT broker on esp8266

#7 Post by happytm » 30 Sep 2017, 20:11

Yes it is a bridge but it is also local MQTT broker on esp8266 and can be used locally without ever requiring cloud broker.Only problem is it is bin file provided by author so there is no chance of changing topics or assign fixed IP for broker. Looks like it use DHCP to assign IP automatically. I was able to test it locally using MQTT Spy and use software's pre defined topic and IP. I had to put that predefined topic in front of espeasy topic structure on controller page like :

predefined topic name/%sysname%/#
predefined topic name/%sysname%/%tskname%/%valname%

I used Openhab MQTT controller for test.

It worked as it would connecting to local raspberry pi or cloud broker but in this case the broker software (bin file ) is running on second esp8266 (dedicated as Mqtt Broker).Too bad it is not open source otherwise we could change it to use GPIO of this esp8266 to do some extra tasks.

Hopefully this is useful to someone looking for local broker without using linux machine like pi.

Drum
Normal user
Posts: 300
Joined: 07 Feb 2016, 11:56

Re: Local MQTT broker on esp8266

#8 Post by Drum » 08 Oct 2017, 10:39

It would be interesting to see what kind of volume something like this would handle, and if it could handle additional tasks as well and what effect that would have on that volume.

I don't yet have use for something like this, but who knows what the future brings. I still need the ability to store the data, perhaps on a SD card, but it might also be interesting to have a more complex rules engine giving up other functionality if needed, just receiving MQTT, determining actions and send MQTT to units to carry out actions.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 40 guests