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:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UDP MQTT to Openplotter with ESP32
#15
Ok I'm stuck.

Here is my code:

Code:
#include "WiFi.h"
#include "AsyncUDP.h"

const char * ssid = "hidden";
const char * password = "hidden";

AsyncUDP udp;

void setup()
{
   Serial.begin(115200);
   WiFi.mode(WIFI_STA);
   WiFi.begin(ssid, password);
   if (WiFi.waitForConnectResult() != WL_CONNECTED) {
       Serial.println("WiFi Failed");
       while(1) {
           delay(1000);
       }
   }
   if(udp.connect(IPAddress(10,10,10,1), 3333)) {
       Serial.println("UDP connected");
       udp.onPacket([](AsyncUDPPacket packet) {
           Serial.print("UDP Packet Type: ");
           Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast");
           Serial.print(", From: ");
           Serial.print(packet.remoteIP());
           Serial.print(":");
           Serial.print(packet.remotePort());
           Serial.print(", To: ");
           Serial.print(packet.localIP());
           Serial.print(":");
           Serial.print(packet.localPort());
           Serial.print(", Length: ");
           Serial.print(packet.length());
           Serial.print(", Data: ");
           Serial.write(packet.data(), packet.length());
           Serial.println();
           //reply to the client
           packet.printf("Got %u bytes of data", packet.length());
       });
       //Send unicast
       udp.print("Hello Server!");
   }
}

void loop()
{
   delay(1000);
   //Send broadcast on port 3333
//    udp.broadcastTo("this is now working", 3333);
   Serial.println("Sending packages....    ");
   Serial.println(millis()/1000);
//    udp.print("$INMTW,17.9,C*1B");

 udp.print("{\"updates\":[{\"source\":{");
 udp.print("\"values\":[{\"path\":\"environment.outside.temperature\",\"value\":");
 udp.print(millis()/1000);
 udp.print("}]}}]}");
}

On my PI, I can use netcat on the 3333 port and see the JSON-DELTA UDP sentence, so I know it transmitting and recieving. If I copy the netcat output into the SignalK datafiddler it is valid, so I know the format is correct. I have added the connection in SignalK as a Signalk connection on port 3333 with "no self mapping" and logging disabled. When I look in the SignalK diagnose tool there is no temperature readings. What am I missing?

Kind Regards,
Peter
Reply


Messages In This Thread
UDP MQTT to Openplotter with ESP32 - by Peter— - 2020-11-09, 03:57 PM
RE: UDP MQTT to Openplotter with ESP32 - by Peter— - 2020-11-10, 08:18 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)