Configure mqtt

2,224 views
Skip to first unread message

metro...@gmail.com

unread,
Oct 14, 2015, 11:14:15 AM10/14/15
to weewx-user
Hello friends.
I need use the mqtt protocol to save bandwith in my 3G transmission.
I read this wiki and installed the extension: https://github.com/weewx/weewx/wiki/mqtt

But now a i have doubts about the configuration.
I installed mosquitto in my PC, but i prefer use the http://iot.eclipse.org/ as broker.

Someone can help, please?

metro...@gmail.com

unread,
Oct 17, 2015, 12:13:24 AM10/17/15
to weewx-user
Please, someone can help me this is very important for me.
Thanks

gjr80

unread,
Oct 17, 2015, 1:28:21 AM10/17/15
to weewx-user
Hi,

You might need to wait for Matthew (mwall), I think it is fair to say he is the resident mqtt expert.

Gary

Thomas Keffer

unread,
Oct 17, 2015, 3:01:39 AM10/17/15
to weewx-user
You're trying to implement a sophisticated solution with very limited skills. You may get lucky and find a volunteer who will walk you through it, but you're basically asking someone to do a consulting job. Don't be surprised if no one offers.

-tk

On Sat, Oct 17, 2015 at 7:13 AM, <metro...@gmail.com> wrote:
Please, someone can help me this is very important for me.
Thanks

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mwall

unread,
Oct 17, 2015, 10:27:33 AM10/17/15
to weewx-user


On Wednesday, October 14, 2015 at 11:14:15 AM UTC-4, metro...@gmail.com wrote:
But now a i have doubts about the configuration.
I installed mosquitto in my PC, but i prefer use the http://iot.eclipse.org/ as broker.

Someone can help, please?

assuming that iot.eclipse.org is your broker, then use this in your weewx.conf:

[StdRESTful]
    [[MQTT]]
        server_url = mqtt://username:pass...@example.com:1883


replace 'username' with your username, replace 'password' with your password, and replace 'example.com' with the hostname for the broker, i.e., localhost if you are running your own broker on the same computer as weewx, or iot.eclipse.org if you have an account on iot.eclipse.org.  the port is required only if you use a non-standard port.

btw, this is step 2 in the readme.txt that comes with the mqtt extension, and it is also on the weewx wiki page for mqtt extension.

m
Message has been deleted
Message has been deleted

metro...@gmail.com

unread,
Oct 19, 2015, 11:25:11 AM10/19/15
to weewx-user
Thanks mwall for your care.

I configured my weewx.conf:
[[MQTT]]
        server_url
= mqtt://iot.eclipse.org:1883
        topic
= weewx/vitor



# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt


# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, rc):
 
print("Connected with result code "+str(rc))
 
# Subscribing in on_connect() means that if we lose the connection and
 
# reconnect then subscriptions will be renewed.
 client
.subscribe("weewx/vitor")


# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
 
print "Topic: ", msg.topic+'\nMessage: '+str(msg.payload)


client
= mqtt.Client()
client
.on_connect = on_connect
client
.on_message = on_message


client
.connect("iot.eclipse.org", 1883, 60)


# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client
.loop_forever()


When i run my subscrider i don't receive nothing from weewx.

I whan't use mqtt because i use 3G modem and need to sabe bandwith.
I need save data from mqtt in a data base.

This is output weewx (mqtt):

data: {
   
'rain24_in': '0.0',
   
'barometer_inHg': '31.0779202224',
   
'outHumidity': '79.3376066706',
   
'interval_minute': '1.0',
   
'dewpoint_F': '24.496253969',
   
'rain_in': '0.0',
   
'cloudbase_foot': '4489.94913573',
   
'heatindex_F': '30.1050485174',
   
'altimeter_inHg': '34.826236951',
   
'dayRain_in': '0.0',
   
'windrun_mile': '0.0287244445624',
   
'inDewpoint': '30.7286642442',
   
'outTemp_F': '30.1050485174',
   
'windchill_F': '30.1050485174',
   
'windGustDir': '356.025640023',
   
'hourRain_in': '0.0',
   
'rainRate_inch_per_hour': '0.0',
   
'humidex': '30.1050485174',
   
'windGust_mph': '0.132478665889',
   
'pressure_inHg': '31.0779202224',
   
'inTemp_F': '63.4367203872',
   
'usUnits': '1.0',
   
'ET_in': '0.320804136611',
   
'appTemp': '25.5071786162',
   
'windSpeed_mph': '0.110398888241',
   
'UV': '6.10549869347',
   
'dateTime': '1444932960.0',
   
'windDir': '356.025640023',
   
'inHumidity': '29.1265592257',
   
'radiation_Wpm2': '436.107049534'
}


Thanks = )

mwall

unread,
Oct 19, 2015, 5:28:39 PM10/19/15
to weewx-user


On Monday, October 19, 2015 at 11:25:11 AM UTC-4, metro...@gmail.com wrote:
Thanks mwall for your care.

I configured my weewx.conf:
[[MQTT]]
        server_url
= mqtt://iot.eclipse.org:1883
        topic
= weewx/vitor


so what happens?

you almost certainly need to specify a username and password in your server_url.

where did you put the [[MQTT]] section?  it must be in the restful services section (if you ran the extension installer it would have put it there for you).

is the MQTT service specified in the restful service list in the [Engine] section?  (if you ran the extension installer it would have put it there for you)

what do you see in the log file when you run weewx?  it will indicate whether mqtt uploads succeed or fail.

m


metro...@gmail.com

unread,
Oct 19, 2015, 6:20:19 PM10/19/15
to weewx-user
I installed the service following the instructions of the Wiki: 

The installer put the  [[MQTT]]  for me.

In my log i don't have any errors.
The MQTT service run and output this "json":
In my mosquitto localhost i don't set the password and username.
Yes, log indicate mqtt upload succeed but i don't received anything in my subscrider

mwall

unread,
Oct 19, 2015, 7:46:32 PM10/19/15
to weewx-user
On Monday, October 19, 2015 at 6:20:19 PM UTC-4, metro...@gmail.com wrote:
I installed the service following the instructions of the Wiki: 

The installer put the  [[MQTT]]  for me.

In my log i don't have any errors.

then the upload is successful, and you should see the data in your account at the broker you specified in the MQTT configuration.

if this is not the case, then post the log.  describing the log is not productive.

 
The MQTT service run and output this "json":

from where are you getting the json output?
 
In my mosquitto localhost i don't set the password and username.

what is "my mosquitto localhost"?
 
Yes, log indicate mqtt upload succeed but i don't received anything in my subscrider

what is "my subscriber"?

m

metro...@gmail.com

unread,
Oct 19, 2015, 8:23:30 PM10/19/15
to weewx-user
Sorry for my bad english.
My native language is portuguese, i am from Brazil.

I don't have account of iot.eclipse.org
I don't find anything about account in the iot.eclipse.org website.

I see this json output in my syslog (tail -f /var/log/syslog).

When i say: ""my mosquitto localhost" i want say i installed the mosquitto package (sudo apt-get install mosquitto and sudo apt-get install mosquitto-client) in my machine. 

The "subscriber" i want say is a small code in python to receive the message from my publisher (weewx).

Thanks = )

mwall

unread,
Oct 19, 2015, 9:05:56 PM10/19/15
to weewx-user
On Monday, October 19, 2015 at 8:23:30 PM UTC-4, metro...@gmail.com wrote:
Sorry for my bad english.
My native language is portuguese, i am from Brazil.

I don't have account of iot.eclipse.org
I don't find anything about account in the iot.eclipse.org website.

I see this json output in my syslog (tail -f /var/log/syslog).

When i say: ""my mosquitto localhost" i want say i installed the mosquitto package (sudo apt-get install mosquitto and sudo apt-get install mosquitto-client) in my machine. 

The "subscriber" i want say is a small code in python to receive the message from my publisher (weewx).



if you run your own broker, then put the url to that broker in the MQTT section of weewx.conf.  for example, if you are running a broker on the same computer as weewx, and that broker is on the default port of 1883, and the username is 'user' and the password is 'pass', then you would have:

server_url = mqtt://user:pass@localhost:1883

are you certain that your broker works properly?  you might want to try a free, hosted broker before you run your own, just to be sure that everything works.  for example

https://www.cloudmqtt.com/

m

mwall

unread,
Oct 20, 2015, 4:27:21 AM10/20/15
to weewx-user
for those of you interested in using mqtt to get your data from weewx into 'the cloud', please see the following:

mqtt.org is the canonical source:

http://mqtt.org/

here is a list of brokers (servers):

https://github.com/mqtt/mqtt.github.io/wiki/servers

and a comparison of those brokers:

https://github.com/mqtt/mqtt.github.io/wiki/server-support

note that none of these are very useful right out of the box - you'll have to do some development if you want data storage or any graphic display of the data.

m

metro...@gmail.com

unread,
Oct 20, 2015, 9:39:35 AM10/20/15
to weewx-user
I created a account in: cloudmqtt.com and setup in my Weewx.

[StdRESTful]
     
[[MQTT]]
        server_url
= mqtt://mypassword:myuse...@m11.cloudmqtt.com:myport
    topic
= weewx



Checking the syslog (/var/log/syslog) we had this output:

Oct 20 10:42:37 raspberrypi weewx[32002]: engine: Loading service user.mqtt.MQTT
Oct 20 10:42:37 raspberrypi weewx[32002]: restx: MQTT: service version is 0.9
Oct 20 10:42:37 raspberrypi weewx[32002]: restx: MQTT: topic is weewx
Oct 20 10:42:37 raspberrypi weewx[32002]: restx: MQTT: Data will be uploaded to mqtt://mypassword:myuse...@m11.cloudmqtt.com:myport
Oct 20 10:42:37 raspberrypi weewx[32002]: engine: Finished loading service user.mqtt.MQTT
Oct 20 10:42:37 raspberrypi weewx[32002]: engine: Starting up weewx version 3.2.1
Oct 20 10:42:37 raspberrypi weewx[32002]: engine: Clock error is -0.25 seconds (positive is fast)
Oct 20 10:42:37 raspberrypi weewx[32002]: engine: Starting main packet loop.
Oct 20 10:44:37 raspberrypi weewx[32002]: manager: added record 2015-10-20 10:44:00 BRST (1445345040) to database 'weewx.sdb'
Oct 20 10:44:37 raspberrypi weewx[32002]: manager: added record 2015-10-20 10:44:00 BRST (1445345040) to daily summary in 'weewx.sdb'
Oct 20 10:44:37 raspberrypi weewx[32002]: restx: MQTT: data: {'rain24_in': '0.32', 'barometer_inHg': '31.099999405', 'outHumidity': '79.9999821513', 'interval_minute': '1.0', 'dewpoint_F': '27.1832189366', 'rain_in': '0.0', 'cloudbase_foot': '4459.42710406', 'heatindex_F': '32.6577165457', 'altimeter_inHg': '34.8504541967', 'dayRain_in': '0.32', 'windrun_mile': '0.000468325880368', 'inDewpoint': '31.0795245766', 'outTemp_F': '32.6577165457', 'windchill_F': '32.6577165457', 'windGustDir': '359.999892908', 'hourRain_in': '0.0', 'rainRate_inch_per_hour': '0.0', 'humidex': '32.6577165457', 'windGust_mph': '3.56973503379e-06', 'pressure_inHg': '31.099999405', 'inTemp_F': '63.0000118991', 'usUnits': '1.0', 'ET_in': '0.466552506793', 'appTemp': '28.4367381251', 'windSpeed_mph': '2.97477919542e-06', 'UV': '12.4826907711', 'dateTime': '1445345040.0', 'windDir': '359.999892908', 'inHumidity': '29.9999762018', 'radiation_Wpm2': '891.620769362'}
Oct 20 10:44:38 raspberrypi weewx[32002]: restx: MQTT: Published record 2015-10-20 10:44:00 BRST (1445345040)


I am using the MQTTLens chrome extension (https://chrome.google.com/webstore/detail/mqttlens/hemojaaeigabkbcookmlgmdigohjobjm) to analyze my subscription and don't received anything.

When i run other aplicatin using the same mqtt configuration is works fine.

I don't know why my weewx don't work using mqtt. 

metro...@gmail.com

unread,
Oct 24, 2015, 10:23:26 PM10/24/15
to weewx-user
Is possible change the form output?
I wan't all information a only one publish.
I need sabe this data in database.


Em quarta-feira, 14 de outubro de 2015 12:14:15 UTC-3, metro...@gmail.com escreveu:
Reply all
Reply to author
Forward
0 new messages