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.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signal K/MQTT issue - Help!
#1
Hi all,

I've got a bit of a problem and I hope some one might be able to help. It might be a bug or just me.

I'm running Openplotter 1.2.0 alpha, fresh from an updated img.

I am trying to display on Signal K instruments using MQTT data derived from ESP8266 connected temperature sensors.

I can connect a single MQTT topic and SignalK will create instruments and display data successfully (tempA).

I configure this on the MQTT tab of the OpenPlotter control panel.

As soon as I configure my second topic (tempB) the pi's CPU usage goes up to around 70%.

HTOP shows mqyy_d.py up at 130% cpu usage, the Signal K dashboard indicates 100+ deltas/sec.

As soon as I delete either topic everything settles down.

The mosquitto broker accepts the two topics with no problem, I can dedug with mosquitto_client.

(added) P.S. Node RED displays both topics OK so this might be a bug.

Huh Any ideas?
Reply
#2
(2018-12-02, 07:51 PM)scuby Wrote: Huh Any ideas?

What about sending the data straight to signalk? 


Code:
#include <WiFiUdp.h>
#include "ArduinoJson.h"

WiFiUDP Udp;

IPAddress remoteIp(10, 10, 10, 1);  //
unsigned short remotePort = 55561;  // Signalk listens on this port
unsigned short localPort = 6667;    // local port to listen for UDP packets




void sendSigK(String sigKey, float data) {    //    send SigK via UDP *****************************************


DynamicJsonBuffer jsonBuffer;
String deltaText;

//  build delta message
JsonObject& delta = jsonBuffer.createObject();

//updated array
JsonArray& updatesArr = delta.createNestedArray("updates");
JsonObject& thisUpdate = updatesArr.createNestedObject();   //Json Object nested inside delta [...
JsonArray& values = thisUpdate.createNestedArray("values"); // Values array nested in delta[ values....
JsonObject& thisValue = values.createNestedObject();
thisValue["path"] = sigKey;
thisValue["value"] = data;

thisUpdate["Source"] = "ESP11";

// Send UDP packet
Udp.beginPacket(remoteIp, remotePort);
delta.printTo(Udp);
Udp.println();
Udp.endPacket();
}
Reply
#3
Thanks for the reply.

Using MQTT is attractive as a "standards" based approach widely used elsewhere in IOT projects. UDP is a bit of a scattergun approach as I intend using several ESP units which might cause contention problems.

I will try your solution, I hadn't thought of it and it will force me to learn some JSON. I notice SK will accept TCP sources as an alternative transport, also interesting.

This still leaves the question, is there a bug in the system?

Cheers
Reply
#4
You can still use mqtt and signalk, udp is so fast it's unlikely collisions will be an issue, mqtt is much slower. Also , mqtt sends data as text so display options are limited, the lovely gauges and dials in the KIP app aren't available for text, they need numeric data.
I've just set up 2 inputs into openplotter set up in the mqtt tab, no problems at all - sounds like you have created a loop somewhere.
MQTT is handy though, I'm slowly creating a generic esp sketch sending the data as signalk UDP but using mqtt for diagnostics from an ESP and for control for when the esp is mounted hidden away somewhere. Working well so far, but for data - signalk UDP works much better than mqtt, no need to waste resources changing mqtt data into signak.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)