This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run mqtt locally?
#1
Is it possible to run MQTT locally on the Pi without being on the internet?

I'm playing around with an ESP8266 as a 4 channel voltmeter with a ads1115, it works so far transfering data using UDP but it might be easier to use mqtt. Seems a long way round to have to go via cloudmqtt and back again. 

Also, inside openplotter does it actually do anything at the moment? There doesn't seem to and way to do anything with it, nothing in the actions. Just curious, I use it with node-red. 

Thanks
  Reply
#2
Hi Paddy,

certainly you can run MQTT locally, you just need a MQTT-Broker. The most common one is mosquitto (https://mosquitto.org/).
It is very simple to use and there are tons of tutorials out there. If you need assistance feel free to ask.

Currently I'm not running OpenPlotter but I guess the MQTT-data can be handled by SignalK (https://github.com/tkurki/signalk-mqtt-gw) and therefore used by OpenPlotter.

Have a nice weekend
  Reply
#3
(10-14-2017, 02:48 AM)shark24 Wrote: Hi Paddy,

certainly you can run MQTT locally, you just need a MQTT-Broker. The most common one is mosquitto (https://mosquitto.org/).
It is very simple to use and there are tons of tutorials out there. If you need assistance feel free to ask.

Currently I'm not running OpenPlotter but I guess the MQTT-data can be handled by SignalK (https://github.com/tkurki/signalk-mqtt-gw) and therefore used by OpenPlotter.

Have a nice weekend

Thanks, mosquitto is actually installed in openplotter and running already -

Quote:pi@openplotter:~ $ mosquitto  -h
mosquitto version 1.3.4 (build date 2017-05-29 22:25:09+0000)

mosquitto is an MQTT v3.1 broker.

Usage: mosquitto [-c config_file] [-d] [-h] [-p port]

 -c : specify the broker config file.
 -d : put the broker into the background after starting.
 -h : display this help.
 -p : start the broker listening on the specified port.
      Not recommended in conjunction with the -c option.
 -v : verbose mode - enable all logging types. This overrides
      any logging options given in the config file.

See http://mosquitto.org/ for more information.

I just don't know the passwords / user name etc. I remember sailoog talking about this a while ago but can't find the posts now.

Ta
  Reply
#4
All sorted Cool

You just use the same user/password as the cloud based broker in the MQTT tab in open plotter then for the server either use 127.0.0.1:1883 or the Pi IP address (find it on the wifi AP tab) , 192.168.X.X:1883.

Sorted Cool

Thinking that might be a better way to send data instead of UDP as it's easier to configure on any machine running node red on the wifi network.

How fast is it though? I might be running up to voltage readings up to 100Hz to se what happens with voltage drop when the engine starts or whatever.

I shall investigate and report back to the audience. Smile
  Reply
#5
i have never used a cloud based broker Smile
in the mqtt tab i have it set up as localhost:1883 user pi and a password..i think the esp8266 is set to 10.10.10.1:1883 for the broker..
http://forum.openmarine.net/showthread.php?tid=396 post #9 shows a 4 relay board connected esp mqtt to pi..
jim
mare liberum
  Reply
#6
(10-14-2017, 07:51 AM)jim321 Wrote: i have never used a cloud based broker Smile
in the mqtt tab i have it set up as localhost:1883 user pi and a password..i think the esp8266 is set to 10.10.10.1:1883 for the broker..
http://forum.openmarine.net/showthread.php?tid=396    post #9 shows a 4 relay board connected esp mqtt to pi..
jim

Ta for the post, I have a victron which really should be talking to the Pi! 

Looks like it doesn't matter what you put in the MQTT tab for remote broker/port fields , it uses the local 127.0.0.1 (localport) and 1883 as well as the remote broker and the same password.

One good thing about having a remote broker is you can look at the mqtt online or  using FRED, the web based node-red but it turns itself off if you don't log on once a day so you loose any graphs.
  Reply
#7
You got it.

To set the local broker in 10.10.10.1:1883 (mosquitto) you have just to set name and password on MQTT tab, if you also define a remote broker, topics will be defined local and remote at the same time. If you are on board connect to the local broker, if you are at home connect to the remote broker.

Looking forward to saying people RTFM but I am afraid first I should WTFM Smile
  Reply
#8
Could you post a bit more about the hardware setup and especially the code you are running on the ESP8266 ?
Thanks!
  Reply
#9
(10-14-2017, 12:45 PM)JD1 Wrote: Could you post a bit more about the hardware setup and especially the code you are running on the ESP8266 ?
Thanks!

Will do, so far it's a esp8266, 128 x 64 oled display and an ads1115 4 channel adc with an acs712 current sensor. 
https://www.sparkfun.com/products/8882

So the plan is to have a box which can log either 4 channels of voltage or voltage and current either way so can log a battery either being charged or discharged. I also have some ttl fet transistors so hoping to be able to control current which would be ideal to make a constant current battery capacity tester.
I have the esp8266 spitting out random numbers via udp at  the moment bit I think mqtt would be better all round, easier to control the esp8266 from node red as well. If mqtt is  quick enough, should be, just haven't checked yet. Another plus of mqtt is that you can monitor it from anywhere either just on a web based mqtt site or make your own on FRED,  the web based node-red site. Liking FRED more and more each day Cool

Just had another thought - is there any kind of mqtt - signalk converter around.? Maybe not, bit of a vague conversion.

But it's all exciting stuff, openplotter on its own is fantastic, add to that node red and for the cost of a few beers what you can do really is quite incredible, amazingly accurate sensors logged and graphed Cool
Ten years ago I started cruising full time and even then it was a good few years before coming across some world charts and laptop charting software. Raspberry pi,  Opencpn, arduinos/esp changed all that. With sailoog making it within the reach of so many of us sailors who don't write a thousand lines of programming code before breakfast Cool
  Reply
#10
(10-14-2017, 02:47 PM)PaddyB Wrote: Just had another thought - is there any kind of mqtt - signalk converter around.? Maybe not, bit of a vague conversion.

Take a look at my first post. Never tried it out but from my understanding this is what you are looking for
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)