Added MQTT support

Brian

Thanks for the quick turnaround. Unfortunately I will not be able to test it since my mosquitto uses authentication (username/pass).

Thanks
Renato

I forgot to add that
will do that now
stand by

done that now, download again…

Brian, it works.

3 questions

  1. Here is the message I see:
    bH9IkmPF7Lhvh5kgPLk5NhZ!12345 0.5 0.0 344 8.7 54 1017.1 0.0 11.4 254.5 0.00 0.00 20.9 47 100.0 13 0.0 0 0 0.0 -54.4 255.0 -65.0 -67.8 -100.0 -100.0 -100 -100 -100 22 49 16 N3KJE-10:49:16_PM 0 0 10 4 0.00 0.00 100 100 100 100 100 8.7 6.5 16.3 4.2 13 Night_time/Dry/Cloudy_with_clear_patches_ 1.5 1 1 2 2 2 2 1 1 1 1 1 0 0 0 0 0 0 0 0 0 10.0 -0.1 3625.5 4/10/2019 15.3 2.8 16.3 4.2 0.0 0 1 0 1 0 1 1 0 1 0 9.9 9.8 9.7 9.5 9.4 9.3 9.2 9.0 8.8 8.7 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 16.3 4.2 8.7 6.0 0 — — 308 0 0 -100.0 -100.0 0 -100 -100 -100 -100 0.0 22.4 20.0 7.4 1017.1 1006.3 7 9:49_PM 2:43_PM 23.5 3.1 6.9 -0.6 2 2019 0.0 -1 1 -1 199 92 67 87 89 73 214 215 252 344 0.0 255.0 0.3 5.2 40.18528 75.02556 0.0 91 38 0.0 5:49_AM 0.0 0.0 0.0 0.0 0.0 0.0 35.1 2:06_PM 5:49_AM 308 !!C10.37S94!!

I noticed that the message starts with a unique identifier and not !12345. Is that by design?

  1. Messages are published every 1 min. If I wanted to publish at the 2.5 sec interval supported by the Davis station, how would I do that?

  2. The windows task manager shows 2 instance of crowndmqtt.exe running at all times. Is this by design? Should it just be one?

Thanks again for adding this great new feature.

Renato

I could make it where you can set the identifier (clientID) (which is followed by a !)

re udpate rate, yes,i could make it where you set the update rate
there should be just the one running…maybe one has got stuck…kill it off?

download a new zip again
where I have added ability to set the clientID and the update rate (seconds)

Brian

Excellent job. Works as advertised.

May I make a suggestion? Perhaps the MQTT page most logical access should be from the “Control Panel” along with the other publications. My 2c.

Thanks again
Renato

maybe
but it is for the more advanced users, hence why its in the advanced setup

Brian

some new feedback. My MQTT server became unavailable earlier in the day. Later this evening I started the Task Manager on the machine running WD and noticed that there were hundreds of cronwdmqtt.exe processes running!

Are you starting a new process every time? Also, you may want to consider adding exception handling logic.

Renato

1 Like

i do have exception handling logic in place
the program should be closing after the data is sent
(and yes then a new one is spawned)
but what I could do is add a time out → close

try this update
http://www.weather-display.com/downloadfiles/cronwdmqtt.zip

Brian

would it make more sense to have the connection only be established at startup and leave it connected?

For example, I have built about a dozen IOT devices using ESP8266 which publish to an MQTT server every sec. I establish a connection as the ESP boots up. The only time I re-estaglish the connection is if the connection dies (i.e. wifi becomes unavailable, mqtt pod crashes etc) at which point, I try to reconnect every 5 mins.

I am not trying to tell you how to code, just a suggestion.

Renato

i was not really envisaging people wanting to send data frequently, that was all
otherwise yes I would do it that way, and still could yet
anyway , make sure to use this new update and see how that goes

Brian

I tried the new program, but it does not publish any messages. I replaced the new one with n-1 and messages started showing up.

Renato

my bad
try again

http://www.weather-display.com/downloadfiles/cronwdmqtt.zip

once this runs stable then can work on having it stay logged in and running

Yep, that did it.

Tomorrow morning (my time) I am going to simulate MQTT going offline and will keep an eye on the total number of mqtt processes.

Thanks again
Renato

actually download yet again
as I need to have added a time out
because if no connection then it will not close

Brian

I have downloaded the latest one.

I shut down the pod that MQTT is running in. Immediately, I noticed that WD started 3 new cronwdmqtt processes. Then a forth one started but shorty after was terminated. The creation/termination of a new process kept on going leaving at anytime 3-4 of these processes.

Renato

yeah, that is because the time out is set to 10 seconds

I will now work on leaving it running…if say the frequency to send is less than the default of 60 seconds say?

1 Like

Do you expect the overhead to be significant if you just left it always connected?

Here is another idea…

What if you were to look at the overall app as a collection of “microservices” where the functionality of the main code would be to generate and publishing the data (clientraw). Then each other microservice (i.e. wu upload, mysql upload, ftp etc) would be its own microservice that would subscribe to the message and “take it from there”.

The advantage of this would be

  1. gain granularity of control as to when each process runs
  2. distribute the microservices across multiple os/hw.
  3. facilitate the creation of “3rd party” plugins

Renato