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
#3
So when you say send it to signalK do you mean 10.10.10.1:3000 ("hostip":3000) then? I tried that but it will does not work. Is there something wrong in my code I don't get it ? (your code is pretty similar). Is there a good guide on this somewhere?

I would love to use micropython but I don't fully understand it yet. Could you give a high level overview of what your *.py scripts do?

I see your boot.py points at webrepl and already there I'm lost. If your boot doesn't point at your main.py how does it get executed then? Also, do you use MQTT or UDP? And does it go through the internet or local wifi?

I just want to be able to establish the connections, the programming of the sensors should be easy. I just don't understand how to commination work and have never programmed it before...

Kind Regards,
Peter

I now changed the code to the following:

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

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

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(5000);
   //Send broadcast on port 3333
   udp.broadcastTo("this is now working", 3333);
   Serial.println("Sending packages....");
}

If I open a terminal on my PI and write:
Code:
netcat -ul 3333

Then I pickup the message from my client (the ESP32) - so that is working which is great.

Now, why the h*** can I not pick up this message using KPLEX? And how do I send it to signalK? And finally, how do I get it into OpenCPN as a wind measurement?

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-09, 06:13 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)